
	//读取cookie及压缩空格
	var Base={
		setCookie:function(sName, sValue){
			var date=new Date();
			date.setTime(date.getTime()+31536000000);
			document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
		},
		delCookie:function(sName){
			if(Base.getCookie(name)){
				document.cookie=sName+"="+((domain)?"; domain="+dm:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
			}
		},
		getCookie:function(sName){
			var aCookie = document.cookie.split("; ");
			for (var i=0; i < aCookie.length; i++)
			{
				var aCrumb = aCookie[i].split("=");
				if (sName == aCrumb[0]) 
					return unescape(aCrumb[1]);
			}
			return "";
		},
		trimL:function(txt){
			return txt.replace(/^\s*/,"");
		},
		trimR:function(txt){
			return txt.replace(/\s*$/,"");
		},
		trim:function(txt){
			return this.trimL(this.trimR(txt));
		}
	};
	
	//标签切换
	function moduleTabs(_tabsId){
		this.emId   = _tabsId + "_tabs";
		var tabs    = this.tabs = jQuery("#"+ this.emId + " li");
		var totals  = this.tabs.length;
		var tabsId  = _tabsId + "_content_";
		
		this.inits = function(){
			this.tabs.each(function(i){
			   	jQuery(this).children().bind("mouseover",function(){	   
					for(var a=1;a<=totals; a++){
						document.getElementById(tabsId+a).style.display="none";
					}
					document.getElementById(tabsId+(i+1)).style.display="";
					tabs.removeClass("cur");
					jQuery(this).parent().addClass("cur");
				});
			});
		}
	}
	
	//页面左栏+-号 高度滑动
	function moduleSlide(_divId){
		this.emId   	= _divId;
		
		//true打开 false闭合
		var isOpen 		= true;
		var obj_		= jQuery("#" + this.emId);
		var obj			= {
			objName		:obj_,
			divHeight	:obj_.height(),
			objPList	:obj_.find("p"),
			titleHeight	:obj_.find("h4").height()+1,
			btmAdd		:obj_.find("h4 .add"),
			objNotice	:obj_.find(".notice"),
			overState   :0
		}
		
		this.inits = function(key){
			
			//如果参数大于1，说明当点击-号闭合时不是完全闭合，根据第二个参数计算闭合状态有多少高度不闭合
			var tmpArguments	= arguments.length>1 && arguments[1];
			var staticHeight	= arguments.length>2 && arguments[2];
			var noticeHeight	= 0;
			if(obj.objNotice.length>0) noticeHeight = obj.objNotice.height()+11;
			obj.objName.css("overflow","hidden");
			//key为开关 0为闭合状态 1为打开状态
			if(key==0){
				//alert(arguments[2]);
				if(!!tmpArguments){
					if(arguments.length>2)
						obj.objName.css({height:obj.titleHeight+(arguments[2]+1)*tmpArguments+noticeHeight});
					else
						obj.objName.css({height:obj.titleHeight+(jQuery(obj.objPList[0]).height()+1)*tmpArguments+noticeHeight});
				}else{
					obj.objName.css({height:obj.titleHeight});
				}
				isOpen = false;
			}
			obj.btmAdd.bind("mouseover",function(){
				if(obj.overState ==0 && !isOpen){
					 obj.objName.animate({height:obj.divHeight}, 1000, function(){isOpen = true;});
					 obj.btmAdd.addClass("remove");
					 
					 obj.overState =1;
				}
				else
				{
					if(isOpen){
						if(!!tmpArguments){
							if(!!staticHeight){
								tmpHeight = obj.titleHeight + (staticHeight+1)*tmpArguments + noticeHeight;
							}else{
								tmpHeight = obj.titleHeight + (jQuery(obj.objPList[0]).height()+1)*tmpArguments + noticeHeight;
							}
						}else{
							tmpHeight = obj.titleHeight;
						}
						obj.objName.animate({height:tmpHeight}, 1000, function(){isOpen = false;});
						obj.btmAdd.removeClass("remove");
						
						obj.overState =0;
					 }
					
				}
			});
			
		}
	}
	
	//由右到左文字滚动
	function moduleFontRock(_fontId){
		this.emId   	= _fontId + "_rock";
		this.btmId   	= _fontId + "_btms";
		var 
			  obj		= jQuery("#" + this.emId),
			  objBtm	= jQuery("#" + this.btmId),
			  btmPlay	= objBtm.find(".play"),
			  btmPause  = objBtm.find(".pause"),
			  objW		= obj.width(),
			  timerid	= -1;

		this.inits		= function(){
			try{

				for(var a=0;a<3;a++){
					obj.append("　<li>"+jQuery(obj.find("li")[a]).html()+"</li>");
				}
				btmPlay.bind("click",function(){funPlay()});
				btmPause.bind("click",function(){funPause()});
				
				obj.find("li a").bind("mouseover",function(){funPause()}).bind("mouseout",function(){funPlay()});
				funPlay();
			}catch(ex){}
		}
		
		function funPlay(){
			clearInterval(timerid);
			timerid = setInterval(moveli,70);
		}
		function moveli(){
			var t= obj.css("left");
			t = parseInt(t)-1;
			if(t<=-objW) t =0;
			obj.css("left",t+"px")
		}
		function funPause(){
			clearInterval(timerid);
		}
	}

	//搜索栏下拉菜单
	function modulSreachCCTV(_divId){
		this.emId 		= _divId;
		var obj			= {
			sreach		:jQuery("#"+_divId),
			sreachList	:jQuery("#"+_divId+" .menu a"),
			sreachKey	:jQuery("#"+_divId+" #keyword")
		}
		this.inits = function(){
			obj.sreachList.each(function(){
				jQuery(this).bind("click",function(){
					with(obj){
						sreachList.removeClass("cur");
						jQuery(this).addClass("cur");
						sreachKey.html(jQuery(this).html());
						sreachList.parent().hide();
					}
				});		 
			})
			
			with(obj.sreach){
				bind("mouseover",function(){obj.sreachList.parent().show();});
				bind("mouseout",function(){obj.sreachList.parent().hide();})
			}
		}
	}
	
	//首页轮播效果
	function moduleRotatingShow(_themeId, opts){
		this.emId		= _themeId + "_focusImg";
		var conList		= opts;
		var local		= conList.length-1;
		var obj			= {
			showImg		: jQuery("#"+this.emId+" img"),
			showNav		: jQuery("#"+this.emId+" h2 i"),
			showLink	: jQuery("#"+this.emId+" h2 a")
		};
		var timer 		= null;	
		
		function funPlay(){
			clearInterval(timer);
			timer = setInterval(funGo,5000);
		};
		
		function funPause(){
			clearInterval(timer);
		};
		
		function funGo(){
			funShow(local);
			
			var img = new Image();
			img.src = conList[funNextLocal(local)].imgUrl;
			
			if (img.complete) {
				local = funNextLocal(local);
				return;
			}
			img.onload = function () {
				local = funNextLocal(local);		
			};
			
		};
		
		this.inits	   = function(){
			funShow(local);
			local = funNextLocal(local);
			funPlay();
			
			obj.showNav.each(function(i){
				jQuery(this).bind("mouseover",function(){
					funPause();
					funShow(i);
					funPlay();
				})						  
			})
			
		}
		function funNextLocal(_local){
			var index = _local;
			index  -= 1;
			if( index < 0 ) index = conList.length-1;
			return	index;
		}
		
		function funShow(_local){
			with(obj){
				showImg.attr("src",conList[_local].imgUrl);
				showLink.html(conList[_local].title);
				showLink.attr("href",conList[_local].linkUrl);
				showImg.parent().attr("href",conList[_local].linkUrl);
				showNav.removeClass("cur");
				jQuery(obj.showNav[_local]).addClass("cur");
			}
		};
	}

	//初始化
	function initsHtml(){
		if (confirm("恢复初始？")){
			(new modulCustom('c1')).initsWeb();
		}
	}
	
	//页面加载完成后执行的效果
	jQuery(function(){
		(new modulSreachCCTV('CCTVSearch')).inits();	
	});
