var t = n = count = 0;  
jQuery(document).ready(
function(){
	jQuery("#searchPop1").click(function(){toggleDivById("#searchPop1ul");});
	jQuery("#searchPop2").click(function(){toggleDivById("#searchPop2ul");});
	jQuery("#key").focus(function(){focSearText("#key");});
	jQuery("#key").keyup(function(){searchPop_open('searchMeg',this);});
	
	
	//图片切换
	count = jQuery("#play_list a").size();    
    jQuery("#play_list a:not(:first-child)").hide();       
    jQuery("#play_text li:first-child").addClass("on");    
    jQuery("#play_text li").click(function() {    
        var i = jQuery(this).attr("title") - 1;    
        n = i;    
        if (i >= count) return;    
        jQuery("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);    
        jQuery(this).addClass("on").siblings().removeClass("on"); 
    });    
    t = setInterval("showAuto()", 2000);    
    jQuery("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 2000);});    
	
	
	
	
}
);


function showAuto()    
{    
   n = n >= (count - 1) ? 0 : n + 1;
    $("#play_text li").eq(n).trigger('click');    
}    




/**
  * tab页切换
  * @param {} tag
  * @param {} content
  */
 function switchTag(tag,content)
  {
	  for(i=1; i <3; i++)
	  {
		  if ("tag"+i==tag)
		  {
			  document.getElementById(tag).getElementsByTagName("a")[0].className="selectli"+i;
			  document.getElementById(tag).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="selectspan"+i;
		  }else{
			  document.getElementById("tag"+i).getElementsByTagName("a")[0].className="";
			  document.getElementById("tag"+i).getElementsByTagName("a")[0].getElementsByTagName("span")[0].className="";
		  }
		  if ("content"+i==content)
		  {
		  	 document.getElementById(content).className="";
		  }else{
		 	 document.getElementById("content"+i).className="hidecontent";
		  }
		  	 document.getElementById("content").className=content;
	  }
  }
  
  //用户登录验证
function loginValidate()
{
  var sName = jQuery("#name").val();
  var sPwd = jQuery("#pwd").val();
  var sCode = jQuery("#code").val();
  if(sName=="")
  {
  	alert("用户名不能为空!");
  	jQuery("#name").focus();
  	return false;
  }else if(sPwd==""){
    alert("密码不能为空!");
    jQuery("#pwd").focus();
    return false;
  }else{
 	 setCookie();
    return true;
  }
}
function setCookie()//设置cookie
{
  var sName = jQuery("#name").val();
  var sPwd = jQuery("#pwd").val();
   var checkbox  =document.getElementById("checkbox").checked;
   
   if(checkbox==true)
   {
	   if((sName!="")&&(sPwd!=""))
		{
		 document.cookie ="userName="+sName;
		 document.cookie ="password="+sPwd;
		 }
   }

}
String.prototype.trim   = function()      
{       
     return   this.replace(/(^s*)|(s*$)/g,   "");   
}
function getCookie(objName)//获取指定名称的cookie的值
{    
    var arrStr = document.cookie.split(";");
   
        for(var i = 0;i < arrStr.length;i++)
           {
                var temp = arrStr[i].split("=");
                
                	
                if(objName.trim()==temp[0].trim()) //此处如果没有去掉字符串空格就不行,偶在这里折腾了半死,主要是这种错误不好跟踪啊
               {    
                return temp[1];
                }                            
            }
}

	function rememberUser()
	{  
	//userName1=userName;Pwd=password   
	    if(document.cookie !="")
	 	 {          
	   // alert( getCookie('userName'));
	   //  alert( getCookie('password'));
	     //下面这两句就是用来记住用户名和密码了
	     if(getCookie('userName') !=null)
	 	 { 
	 	 	document.getElementById("name").value=getCookie('userName');
	 	 }
	   
	   //  jQuery("#pwd").val()=getCookie('password');    
	 	 
	var $ = function($){
	return document.getElementById($);
	};
	aLiTab = $("oUlTab").getElementsByTagName("li");
	aDivTab = [$("oDivTab1") , $("oDivTab2") , $("oDivTab3")];
	for(var i=0;i<aLiTab.length;i++){
		(function(i){
			var t = aLiTab[i];
			t.onclick = function(){
				if(nFocus != i){
					aLiTab[nFocus].className = "";
					aDivTab[nFocus].style.display = "none";
					nFocus = i;
					aLiTab[nFocus].className = "on";
					aDivTab[nFocus].style.display = "";
				}
				bFlag = true;
			};
			t.onmouseout = function(){
				bFlag = false;
			};
		})(i);
	}

	    }
}




