//document.domain ="mydrivers.com";

function GetObj(id)
{
	var obj;
	obj=document.getElementById(id);
	if(obj==null)
	{	
		return null;
		
	}else
	{
		return obj;
	}
}

function AjaxObject(){
	var request = null;
	try
	{
		request = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		try
		{
			request = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (oc)
		{
			request = null;
		}
	}
if (!request && typeof XMLHttpRequest != "undefined")
{
	try
	{
	  request =  new XMLHttpRequest();
	}
	catch (fa)
	{
		alert("抱歉，您的浏览器不支持这个功能，请选择IE 6.0或FireFox浏览器。")
		request = null;
	}
}
return request;
}


//驱动下载A页面 设置用户投票 cookie
function setCookieDig(cookieName,value){
	var time = new Date();
	time.setTime(time.getTime() + 30*60*1000);//30分钟
	document.cookie=cookieName+"="+escape(value)+";expires="+time.toGMTString(); 
	//+ ";
	//domain=drivers1.mydrivers.com";
}

//驱动下载A页面 获取用户投票 cookie
function getCookieDig(cookieName){
   var cookieString = document.cookie;
   var start = cookieString.indexOf(cookieName+"=");
	if (start ==-1) return null;
	start+=cookieName.length+1;
	var end = cookieString.indexOf(';', start);
	if (end == -1) return unescape(cookieString.substring(start));
	else return unescape(cookieString.substring(start, end));
}

//驱动下载A页面  返回用户投票信息
function make_show(url,type){
	
	var contentObj_z = document.getElementById('votecontent_z');//支持
	var contentObj_f = document.getElementById('votecontent_f');//反对
	
	var xmlHttp = AjaxObject();
	url+="&rand="+Math.random();
	xmlHttp.onreadystatechange=function(){
		if (xmlHttp.readyState==4 && xmlHttp.status==200){
		    if (xmlHttp.responseText == ""){
		    	make_show(url,type);
		    }else{
				var response = xmlHttp.responseText;
				response = response.split('|');
				var s = response[0];
				var o = response[1];
				
				contentObj_f.innerHTML= o + '票';
				contentObj_z.innerHTML= s + '票';

				s = parseInt(s);
				o = parseInt(o);
 				if((s==0)&&(o==0))
				{return;}
				document.getElementById("imgGood").style.height=Math.ceil(s/(s+o)*50)+'px';
				document.getElementById("imgBad").style.height=50-Math.ceil(s/(s+o)*50)+'px';
		    }
		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

//驱动下载A页面 用户投票
 function change_vote(Tid,type)
 {
	var cookieName = "doc_"+Tid;
	var tag;
	if (!getCookieDig(cookieName))
	{
		if(type!=3)
		{
			setCookieDig(cookieName,Tid);//添加该驱动cookie
			tag=1;
		}
	}
	else
	{
		if(type!=3)
		{
			alert('您已经投过票了！');
			return;
		}
		tag=0;
		
	}
	
	var url ="/AjaxVote.aspx";
 	url+="?Tid="+Tid+"&tag=" + tag + "&type="+type;
 	make_show(url,type);
 }
 
 //驱动下载A页面 用户投票
 function init_content(Tid)
 {
	change_vote(Tid,3);
 }

//驱动下载A页面 左侧tab切换 	
function ChangeTabColor(tabid,classid)
{
	if(classid == 1)
	{
		for(var i=1;i<4;i++)
		{
			GetObj('tab_nav'+i).style.display = 'none';
			GetObj('taxis_nav'+i).className = 'newstiao4-0';
		}
		
		GetObj('tab_nav' + tabid).style.display = 'block';	
		GetObj('taxis_nav' + tabid).className = 'gengduo5';	
		GetObj('bg' + classid).className='bg' + tabid;	
		
	}else if(classid == 2) 
	{
		for(var i=4;i<6;i++)
		{
			GetObj('tab_nav'+i).style.display = 'none';
			GetObj('taxis_nav'+i).className = 'newstiao4-0';
			if(i==5)
			{
				var value=getCookie('DriversIDs');;
				if(value!=null)
				 {
				 GetHistoryList(value);

				 }
			}
		}
		
		GetObj('tab_nav' + tabid).style.display = 'block';	
		GetObj('taxis_nav' + tabid).className = 'gengduo5';
		tabid = tabid -3;
		GetObj('bg' + classid).className='bg' + tabid;	
				
	}else if(classid == 3)
	{
		for(var i=6;i<8;i++)
		{
			GetObj('tab_nav'+i).style.display = 'none';
			GetObj('taxis_nav'+i).className = 'newstiao4-0';
		}
		GetObj('tab_nav' + tabid).style.display = 'block';	
		GetObj('taxis_nav' + tabid).className = 'gengduo5';
		tabid = tabid - 5;
		GetObj('bg' + classid).className='bg' + tabid;			
	}
}

//驱动下载A页面 获取用户浏览驱动的列表
function GetHistoryList(value)
{
	url="/AjaxHistory.aspx?driversid="+value+""
	var xmlHttp = AjaxObject();
	url+="&rand="+Math.random();
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 && xmlHttp.status==200)
		{
		    if (xmlHttp.responseText == "")
		    {
		    	GetHistoryList(value);
		    }else
		    {
				var response = xmlHttp.responseText;
				document.getElementById('divhistory').innerHTML = response;
			}
		}
	};
	
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

//驱动下载A页面 获取用户 浏览驱动的cookie

function setCookie(name,value)
{
  var Days = 30; //此 cookie 将被保存 30 天
  var exp  = new Date();    //new Date("December 31, 9998");
  exp.setTime(exp.getTime() + Days*24*60*60*1000);
  document.cookie = name + "="+ escape(value) +";expires="+ exp.toGMTString()+ ";domain=.mydrivers.com;Path=/";
}

function getCookie(name)
{
   
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null)
		return unescape(arr[2]);
	return null;
}

//驱动下载A页面 设置用户浏览驱动的cookie
function SetHistoryCookie(driversid)
{
  // debugger;
	if(driversid!='')
	{
		var mycookie=getCookie('DriversIDs');
		if(mycookie==null)//不存在cookie
		{
			setCookie("DriversIDs",driversid);
	
		}else
		{
			arr_mycookie=mycookie.split(',');
			if(arr_mycookie.length > 10)
			{
				mycookie = '';
				for(var i = 0;i < 10;i++)
				{
				 	if(mycookie=='')
				  {
				  
					mycookie = arr_mycookie[i];
					
				   }else
				   {
				   
					 mycookie += "," + arr_mycookie[i];
					   
					}
				 }
			 }
			if(mycookie.indexOf(driversid)==-1)
			{	
				setCookie("DriversIDs",driversid + "," + mycookie)
			}
			
		}
		
	}
}
	
//驱动下载A页面 返回用户浏览历史
function show_historydrivers(driversid) 
   {   
		SetHistoryCookie(driversid);//设置cookie
		
		
	}

//驱动下载A页面 添加到收藏夹
function addBookmark(title,url) 
{ 
	if (window.sidebar) {   
	window.sidebar.addPanel(title, url,"");   
	} else if( document.all ) {  
	window.external.AddFavorite( url, title);  
	} else if( window.opera && window.print ) {  
	return true;  
	}  
} 

//驱动下载A页面 返回收藏标签	
function ReturnShouCang(objdiv)
{

document.getElementById(objdiv).innerHTML=(" <a href=\"javascript:u=location.href;t=document.title;c = %22%22 + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);var url=%22http:\/\/cang.baidu.com\/do\/add?it=%22+encodeURIComponent(t)+%22&iu=%22+encodeURIComponent(u)+%22&dc=%22+encodeURIComponent(c)+%22&fr=ien#nw=1%22;window.open(url,%22_blank%22,%22scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes%22); void 0\" title=\"Baidu搜藏\"><img height=\"16\" src=\"\/images\/baidu.gif\" alt=\"Baidu搜藏\" border=\"0\"><\/a> <a href=\"javascript:window.open(\'http:\/\/www.google.com\/bookmarks\/mark?op=add&bkmk=\'+encodeURIComponent(document.href)+\'&title=\'+encodeURIComponent(document.title),\'favit\',\'width=960,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes\');void(0)\"><img height=\"16\" src=\"\/images\/google.gif\" alt=\"Google书签\" border=\"0\"><\/a> <a style=\"font-size:14px;\" href=\"javascript:window.open(\'http:\/\/shuqian.qq.com\/post?title=\'+encodeURIComponent(document.title)+\'&uri=\'+encodeURIComponent(document.location.href)+\'&jumpback=2&noui=1\',\'favit\',\'width=960,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes\');void(0)\"><img height=\"16\" src=\"\/images\/qq.gif\" alt=\"QQ书签\" align=\"absmiddle\" border=\"0\" style=\"margin-right:2px;\" title=\"QQ书签\"><\/a> <a href=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(vivi=window.open(\'http:\/\/vivi.sina.com.cn\/collect\/icollect.php?pid=28&title=\'+escape(d.title)+\'&url=\'+escape(d.location.href)+\'&desc=\'+escape(t),\'vivi\',\'scrollbars=no,width=480,height=480,left=75,top=20,status=no,resizable=yes\'));vivi.focus();\" title=\"新浪ViVi\"><img height=\"16\" src=\"\/images\/vivi.gif\" alt=\"新浪ViVi\" border=\"0\"><\/a> <a title=\"推荐到diglog\" href=\"javascript:\/\/\" onclick=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(keyit=window.open(\'http:\/\/www.diglog.com\/submit.aspx?title=\'+escape(d.title)+\'&url=\'+escape(d.location.href)+\'&description=\'+escape(t),\'keyit\',\'resizable,location,menubar,toolbar,scrollbars,status\'));keyit.focus();\"><img height=\"16\" src=\"http:\/\/img.diglog.com\/images\/diglog_thrumb_1.gif\" border=\"0\"><\/a> <a href=\" javascript:window.open(\'http:\/\/del.icio.us\/post?&url=\'+encodeURIComponent(location.href)+\'&title=\'+encodeURIComponent(document.title),\'favit\',\'width=960,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes\');void(0)\"><img height=\"16\" src=\"\/images\/delicious.gif\" alt=\"Del.icio.us\" border=\"0\" title=\"Del.icio.us\"><\/a> <a href=\"javascript:window.open(\'http:\/\/myweb2.search.yahoo.com\/myresults\/bookmarklet?u=\'+encodeURIComponent(location.href)+\'&t=\'+encodeURIComponent(document.title),\'favit\',\'width=960,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes\');void(0)\"><img height=\"16\" src=\"\/images\/yahoo.gif\" alt=\"Yahoo书签\" border=\"0\"><\/a> <a href=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(keyit=window.open(\'http:\/\/www.365key.com\/storeit.aspx?t=\'+escape(d.title)+\'&u=\'+escape(d.location.href)+\'&c=\'+escape(t),\'keyit\',\'scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes\'));keyit.focus();\" title=\"365Key网摘\"><img height=\"16\" src=\"\/images\/365key.gif\" alt=\"365Key网摘\" border=\"0\"><\/a> <a href=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(yesky=window.open(\'http:\/\/hot.yesky.com\/dp.aspx?t=\'+escape(d.title)+\'&u=\'+escape(d.location.href)+\'&c=\'+escape(t)+\'&st=2\',\'yesky\',\'scrollbars=no,width=400,height=480,left=75,top=20,status=no,resizable=yes\'));yesky.focus();\" title=\"天极网摘\"><img height=\"16\" src=\"\/images\/yesky.gif\" alt=\"天极网摘\" border=\"0\"><\/a> <a href=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(keyit=window.open(\'http:\/\/my.poco.cn\/fav\/storeIt.php?t=\'+escape(d.title)+\'&u=\'+escape(d.location.href)+\'&c=\'+escape(t)+\'&img=http:\/\/www.h-strong.com\/blog\/logo.gif\',\'keyit\',\'scrollbars=no,width=475,height=575,status=no,resizable=yes\'));keyit.focus();\" title=\"POCO网摘\"><img height=\"16\" src=\"\/images\/poco.gif\" alt=\"POCO网摘\" border=\"0\"><\/a> <a href=\"javascript:d=document;t=d.selection?(d.selection.type!=\'None\'?d.selection.createRange().text:\'\'):(d.getSelection?d.getSelection():\'\');void(keyit=window.open(\'http:\/\/blogmark.bokee.com\/jsp\/key\/quickaddkey.jsp?k=\'+encodeURI(d.title)+\'&u=\'+encodeURI(d.location.href)+\'&c=\'+encodeURI(t),\'keyit\',\'scrollbars=no,width=500,height=430,status=no,resizable=yes\'));keyit.focus();\" title=\"博采网摘\"><img height=\"16\" src=\"\/images\/bokee.gif\" alt=\"博采网摘\" border=\"0\"><\/a> <a href=\"javascript:u=location.href;t=document.title;void(open(\'http:\/\/www.YouNote.com\/NoteIt.aspx? u=\'+escape(u)+\'&t=\'+escape(t)+\'&c=\'+escape(document.selection.createRange ().text),\'网络书签\', \'toolbar=no,width=475,height=575,left=75,top=20,status=no,resizable=yes\'));\" title=\"YouNote网摘\"><img height=\"16\" src=\"\/images\/younote.gif\" alt=\"YouNote网摘\" border=\"0\"><\/a> <A href=\"javascript:t=document.title;u=location.href;e=document.selection?(document.selection.type!=\'None\'?document.selection.createRange().text:\'\'):(document.getSelection?document.getSelection():\'\');void(open(\'http:\/\/bookmark.hexun.com\/post.aspx?title=\'+escape(t)+\'&url=\'+escape(u)+\'&excerpt=\'+escape(e),\'HexunBookmark\',\'scrollbars=no,width=600,height=450,left=80,top=80,status=no,resizable=yes\'));\" title=\"和讯网摘\"><img height=\"16\" src=\"\/images\/hexun.gif\" alt=\"和讯网摘\" border=\"0\"><\/A> <A href=\"javascript:addBookmark(document.title,location.href)\"><img height=\"16\" src=\"\/images\/tianjiashoucang.gif\" alt=\"添加到收藏夹\" border=\"0\"><\/A> ")

} 

//订阅向导第二步 厂商 中英文切换
function TabChange(divid,id)
{
	if(id==1) //显示按英文排序
	{
	
		GetObj(divid+'Tab1').className="onsubscribetab";
		GetObj(divid+'Tab2').className="outsubscribetab";
		GetObj(divid+'div1').style.display = 'block';
		GetObj(divid+'div2').style.display = 'none';
	
	}else//显示按中文排序
	{
		
		GetObj(divid+'Tab1').className="outsubscribetab";
		GetObj(divid+'Tab2').className="onsubscribetab";
		GetObj(divid+'div1').style.display = 'none';
		GetObj(divid+'div2').style.display = 'block';
	
	}	
}

//订阅向导第一步 用户点击 选中事件
function DoCheckCount(obj)
{
    var icheckcount=0;
	for(i=0;i<document.getElementsByName('classID').length;i++)
		{
			if(document.getElementsByName('classID')[i].checked)
				{
					icheckcount++;
				}
		}
	
	if(icheckcount>5)
	{
	    document.getElementById(obj).checked=false;
	    icheckcount = icheckcount-1;
		alert('你要订阅的种类不可以超过五个!');
	}

}

//订阅向导第一步 用户点击 提交事件
function checkform()
{
	for(i=0;i<document.getElementsByName('classID').length;i++)
		{
			if(document.getElementsByName('classID')[i].checked)
				{
							return true;
				}
		}
	alert( '请选择你要定阅的种类！');
	return false;
}


