var CANVAS = function(){
	var m_canvas=this;
	return {
		UI:{
			TextBox:{
				Focus:function(sender,cssClass){
					if(arguments.length===2){
						if(sender!=='undefined'&&sender!==null&&sender.type==='text'){
							var css = typeof(cssClass)==='string'?jQuery.trim(cssClass)!==''?cssClass:'cs-focused':'cs-focused';
							if(sender.value===sender.defaultValue){
								sender.value='';
								jQuery(sender).toggleClass(css,true);
							}
						}
					}
				},
				Blur:function(sender,cssClass){
					if(arguments.length===2){
						if(sender!=='undefined'&&sender!==null&&sender.type==='text'){
							var css = typeof(cssClass)==='string'?jQuery.trim(cssClass)!==''?cssClass:'cs-focused':'cs-focused';
							if(sender.value.length===0||jQuery.trim(sender.value)===''){ 
								sender.value=sender.defaultValue;
								jQuery(sender).toggleClass(css,false);
							}
						}
					}
				}
			},
			Tabs: {
				DefaultTab:'',
				Initialize:function(collection,selected){
					if(typeof(jQuery)!=='undefined'&&window.jQuery){
						jQuery(function($){	
							if(typeof(collection)==='object'&&collection!==null){
								var $c = collection,$a,$tab;
								$c.click(
									function(e){
										$a=$(this);
										$tab=$('#'+$a.attr('rel'));
										$a.addClass('cs-tab-selected').parent().siblings().find('a').removeClass('cs-tab-selected');
										$tab.show().siblings('div.cs-tab').hide();
										e.preventDefault();
									}
								);
								if(typeof(selected)!=='undefined'&&typeof(selected)==='string'&&$.trim(selected).length > 0){
									$c.filter('a[rel="'+selected+'"]').click();
								}
							}
						});
					}
				}
			},
			Helpers:{
				EqualizeHeights:function(){
					if(typeof(jQuery)!=='undefined'&&window.jQuery){
						var m_args=arguments,m_arg=null,$item,$array=[],$el,m_height=0,ri=0;
						if(m_args.length>0){
							for(var i=0,L=m_args.length;i<L;i++){
								m_arg=m_args[i];
								if(typeof(m_arg)==='string'&&m_arg.length>0){
									$item=jQuery(m_arg);
								}else if(typeof(m_arg)==='object'&&m_arg!==null&&m_arg.each){
									$item=m_arg;
								}
								$item.each(function(){
									m_height=Math.max(jQuery(this).css('height','auto').outerHeight(),m_height);
									$array.push(jQuery(this));
								})
								if(m_height > 0 && $array.length>0){
									for(var j=0,K=$array.length;j<K;j++){
										$el=$array[j];
										if($el.outerHeight()<m_height){
											$el.height(m_height-($el.outerHeight()-$el.height()));
										}
									}
									ri=m_height;
								}
							}
							return ri;
						}
					}
				},
				EqualizeWidths:function(){
					if(typeof(jQuery)!=='undefined'&&window.jQuery){
						var m_args=arguments,m_arg=null,$item,$array=[],$el,m_width=0,ri=0;
						if(m_args.length>0){
							for(var i=0,L=m_args.length;i<L;i++){
								m_arg=m_args[i];
								if(typeof(m_arg)==='string'&&m_arg.length>0){
									$item=jQuery(m_arg);
								}else if(typeof(m_arg)==='object'&&m_arg!==null&&m_arg.each){
									$item=m_arg;
								}
								$item.each(function(){
									m_width=Math.max(jQuery(this).css('width','auto').outerWidth(),m_width);
									$array.push(jQuery(this));
								})
								if(m_width > 0 && $array.length>0){
									for(var j=0,K=$array.length;j<K;j++){
										$el=$array[j];
										if($el.outerWidth()<m_width){
											$el.width(m_width-($el.outerWidth()-$el.width()));
										}
									}
									ri=m_width;
								}
							}
							return ri;
						}
					}
				
				},
				AddClickEventFromSrcLink:function(target,linkref){
					if(typeof(target)==='object'&&target!==null){
						if(typeof(linkref)==='string'&&linkref.length>0){
							if(typeof(jQuery)!=='undefined'&&window.jQuery){
								var link=jQuery(linkref);
								if(link.length > 0 && target.length > 0){
									target.eq(0).click(function(){
										location.href=link.eq(0).attr('href');
									});
								}
							}
						}
					}
				}
			},
			GoogleSearch:{
				m_Search:null,
				Create:function(id,resultsID,fn){
					if(typeof(google)!=='undefined'&&google!==null){
						m_Search=new google.search.SearchControl();
						m_Search.setResultSetSize(google.search.Search.LARGE_RESULTSET);
						if(typeof(fn)==='function'){
							m_Search.setSearchCompleteCallback(this, fn, this.results)
						}
						var m_options = new google.search.SearcherOptions();
						var m_ws = new google.search.WebSearch();
						m_ws.setSiteRestriction('www.canvassystems.com');
						if(typeof(resultsID)==='string'){
							m_options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
							m_options.setRoot(document.getElementById(resultsID));
						}
						m_Search.addSearcher(m_ws, m_options);
						if(typeof(id)==='string'){
							m_Search.draw(id);
						}
					}
				},
				Execute:function(q){
					if(typeof(q)==='string'&&q.length>0){
						m_Search.execute(q);
					}
				}
			}
		}
	}
}();