function find_news()
{
	var yIndex = document.finddate.Year.selectedIndex;
	var yValue = document.finddate.Year.options[yIndex].value;
	
	var mIndex = document.finddate.Month.selectedIndex;
	var mValue = document.finddate.Month.options[mIndex].value;
	
	var dIndex = document.finddate.Day.selectedIndex;
	var dValue = document.finddate.Day.options[dIndex].value;
	var strScripts = "http://blog.mydrivers.com/"+yValue+mValue+dValue+".htm";
	
	window.open (strScripts,"basefrm","");
}

//镜像相关的东东
function SetTEL()
{
	var mydate = new Date();
	mydate.setTime(mydate.getTime() + 315360000000);
	document.cookie = "zz_area=TEL;expires=" + mydate.toGMTString() + ";domain=mydrivers.com";
	Get();
}

function SetCNC()
{
	var mydate = new Date();
	mydate.setTime(mydate.getTime() + 315360000000);
	document.cookie = "zz_area=CNC;expires="+ mydate.toGMTString() + ";domain=mydrivers.com";
	Get();
}
 function GetCookie(name)
 {
     var arg=name+ "=";
     var alen=arg.length;
     var clen=document.cookie.length;
     var i=0;
     while (i<clen) {
       var j=i+alen;
       if(document.cookie.substring(i,j)
       ==arg)
       return getCookieVal(j);
       i=document.cookie.indexOf("",i)+1;
       if(i==0)break;
     }
     return null;
   }
   
   
   function getCookieVal(offset) {
     var endstr=document.cookie.indexOf
       (";",offset);
     if(endstr==-1) //没有指定其他元素
       endstr=document.cookie.length;
     return unescape(document.cookie.substring
       (offset,endstr));
   }

//获得当前的COOKIE
function Get()
{		
	var cookieEnabled=(navigator.cookieEnabled)? true : false;
	//如果浏览器不是ie4+或ns6+
	if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
	{ 
		document.cookie="testcookie";
		cookieEnabled=(document.cookie=="testcookie")? true : false;
		document.cookie=""; //erase dummy value
	}
	
	if (cookieEnabled)
	{		
		var CookieArea = GetCookie('zz_area');
		//var CookieArea = "CNC";
		if (CookieArea == "CNC")
		{		
			this.location = "http://www.mydrivers.com/default.shtml";
		}
		else
		{
			//判断电信线路
			if (CookieArea == "TEL")
			{
				this.location = "http://www1.mydrivers.com/default.shtml";
			}
		}
	}
	else
	{		
		this.location = "http://www.mydrivers.com/default.shtml";
	}
}



////////////////////////

//news_search

function go_newssearch()
{
	var txtsearch = document.findnews.q.value;
	var strsearchurl = "http://so.mydrivers.com/news.aspx?q="+txtsearch;   //&classtype="+txtkeyclass;
	window.open (strsearchurl,"basefrm","");
}

function go_search()
{
	var txtsearch = document.findnews.q.value;
	var strsearchurl = "http://so.mydrivers.com/drivers.aspx?q="+txtsearch;   //&classtype="+txtkeyclass;
	window.open (strsearchurl,"basefrm","");
}

function go_search2()
{
	var txtsearch = document.findnews.q.value;
	var strsearchurl = "http://so.mydrivers.com/hardware.aspx?q="+txtsearch;//+"&classtype="+txtkeyclass;
	window.open (strsearchurl,"basefrm","");
}

//search
function go_search_key()
{
	var s_keywords	= document.myform.q.value;
	var s_class 	= document.myform.s_class.value;	
	if (errorFunc(s_keywords))
	{
		if (s_class == "tools")
		{
			var sAction = "http://tools.mydrivers.com/search.asp?k=" + s_keywords;			
		}
		else
		{
			var sAction = "http://so.mydrivers.com/" + s_class + ".aspx?q=" + s_keywords;
		}
		window.open (sAction,"basefrm","");
	}
}

//search
function go_search_keyV2()
{
	var s_keywords	= document.myform.q.value;
	if (errorFunc(s_keywords))
	{
		return true;
	}
	else
	{
		return false;
	}
}

function enter()
{
	if(event.keyCode==13)
	{
		event.keyCode = 9;		
		document.getElementById('myButton').click();
	}
}


function goUrl()
{
	var url = "http://passport.mydrivers.com/logout.aspx?ReturnUrl=" + my_return_url;
	parent.location=url;
}

function get_cookie(varname)
{
	var tmp_ary = new Array();
	if (varname)
	{
		var a = document.cookie.indexOf(varname+"=");
		if (a != -1)
		{
			var b = document.cookie.substring((a+varname.length+1),document.cookie.length);
			var c = b.split(";");
			var d = c[0];
			return d;
		}
	}
}

function check_login(jsf)
{ 
	if(document.mydrivers_Login.username.value=="")
	{
	    alert("请输入用户ID");
		document.mydrivers_Login.username.focus();
		return false;
	}
	else if ( document.mydrivers_Login.password.value.length<1 ) 
	{
		alert("密码不能为空");
		document.mydrivers_Login.password.focus();
		return false;
	}			
	mydrivers_Login.action="http://passport.mydrivers.com/check_login.aspx?ReturnUrl=" + my_return_url;	
	return true;
}

function errorFunc( keyword )
{
	if( ( keyword=="" || keyword=="请输入关键字" ))
	{
		alert("请输入查询关键字!");
		document.myform.q.focus();
		return false;
	}
	return true;
}

//加入首页面的日期
function showweek() 
{
	var now = new Date();if (now.getDay() == 0) return ("星期日");
　　if (now.getDay() == 1) return ("星期一"); 	
　　if (now.getDay() == 2) return ("星期二");	
　　if (now.getDay() == 3) return ("星期三"); 	
　　if (now.getDay() == 4) return ("星期四"); 	
　　if (now.getDay() == 5) return ("星期五"); 	
　　if (now.getDay() == 6) return ("星期六"); 
} 

function showdate() 
{ 
　var now = new Date() 
　var year = now.getYear() 
　var month = now.getMonth()+1 
　var day = now.getDate() 
　return year+"年"+month+"月"+day+"日" 
}

function showshortdate() 
{ 
　var now = new Date() 
　var month = now.getMonth()+1 
　var day = now.getDate() 
　return month+"月"+day+"日" 
}

function GetObj(objName)
{
	if(document.getElementById)
	{
		return eval('document.getElementById("' + objName + '")');
	}
	else if(document.layers)
	{
		return eval("document.layers['" + objName +"']");
	}
	else
	{
		return eval('document.all.' + objName);
	}
}
function SetLbl(objId, cClass, cCon, hCon)
{
	GetObj(objId).className = cClass;
	GetObj(cCon).style.display = "block";
	GetObj(hCon).style.display = "none";
}

//百度I吧
function share(type,link,title,content){
    var itieba_share = 'http://tieba.baidu.com/i/sys/share?link=' + encodeURIComponent(link)
    +'&type=' + encodeURIComponent(type)
    +'&title=' + encodeURIComponent(title)
    +'&content=' + encodeURIComponent(content);
    if (!window.open(itieba_share, 'itieba', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436')) 
    {
        location.href = itieba_share;
    }
}
