function unipro_clearCookie(name1) 
{
	document.cookie = name1+"=; " + "domain=sina.com.cn; path=/; ";     
//bites = document.cookie.split("; ");
} 


function unipro_UniProLogout() {
	unipro_clearCookie("SINAPRO");
	unipro_clearCookie("SINA-AVATAR");
	unipro_clearCookie("SINAPROC");
	unipro_clearCookie("nick");
	unipro_clearCookie("SINA_NU");      
	unipro_clearCookie("SINA_OU");
	unipro_clearCookie("appmask");
	unipro_clearCookie("gender");
	unipro_clearCookie("UNIPROTM");
	unipro_clearCookie("UNIPROU");
	unipro_clearCookie("SINA_USER");
	unipro_clearCookie("SMS_COOKIE");
	unipro_clearCookie("SID");
	unipro_clearCookie("PAYSID");
	unipro_clearCookie("UNIPROM");
	unipro_clearCookie("AUTOFANS");
	unipro_clearCookie("NOTAUTOFANS");
	return true;
}

	function checkLogin()
	{
	   if (document.logIn.uid.value=="")
	   {
		alert("登录名不能为空，请输入用户名！");
		document.logIn.uid.focus();
		return false;
	   }
	   if (document.logIn.passwd.value=="")
	   {
		alert("密码不能为空，请输入密码！");
		document.logIn.passwd.focus();
		return false;
	   }
	   if (document.logIn.checkcode.value=="")
	   {
	   	alert("请输入验证码！");
	   	document.logIn.checkcode.focus();
	   	return false;
	   }
	   return true;
	}
	
	function logon()
	{
	   if (checkLogin())
	   {
	   	
		window.open('http://fans.auto.sina.com.cn/userlogon.html','', 'menubar=no,status=no,toolbar=no,width=400,height=350,scrollbars=no');
	   }	   
	}
	
	function addrandcode()
	{
		var pp= Math.round((Math.random()) * 100000);
		return pp;
	}
	
function header_login()
{
	
	document.write("<table width=750 border=0 cellspacing=0 cellpadding=0>");
	document.write("<tr>");
	document.write("<td><img src=http://image2.sina.com.cn/qc/chm0104img/enrol_left.gif width=5 height=33 border=0></td>");
	document.write("<td width=740 align=center background=http://image2.sina.com.cn/qc/chm0104img/enrol_bg.gif>");
	document.write("<table width=80% border=0 cellspacing=0 cellpadding=0>");
//	document.write("<form name=logIn method=post action='' onsubmit='javascript:logon();'>");
	document.write("<form name=logIn method=post action=''>");
	document.write("<tr>");
	document.write("<td><b>用户登录：</b></td>");
	document.write("<td>用户名</td><td><input type=text name='uid' size=8></td>");
	document.write("<td>密码</td><td><input type=password name='passwd' size=8></td>");
	document.write("<td>验证码</td><td><input type=text name='checkcode' size=6></td>");
	document.write("<td align=center>");
	document.write("		<script>function addrandcode(){var pp= Math.round((Math.random()) * 1000);return pp;}g_img=new Image(55,18);g_img.src=\"http://fans.auto.sina.com.cn/imgserial.php?\"+ addrandcode();	var img = \"<img src='\";img += g_img.src;img += \"' width=52 height=18>\";	document.write(img);</script></td>");
//	document.write("<td align=center><input type=image src=http://image2.sina.com.cn/qc/chm0104img/button_login.gif width=33 height=20 border=0 style=border:none;></td>");
	document.write("<td align=center><a href='javascript:logon();'><img src=http://image2.sina.com.cn/qc/chm0104img/button_login.gif width=33 height=20 border=0 style=border:none;></a></td>");
	document.write("<td align=center><a href=http://unipro.sina.com.cn/getpass.html ><img src=http://image2.sina.com.cn/qc/chm0104img/button_password.gif width=58 height=20 border=0 style=border:none;></a></td>");
	document.write("<td align=center><a href='http://unipro.sina.com.cn/cgi-bin/new_regist0.cgi?url1=&url2=&id1=1&id2=0&entry=unipro&mcheck=41a54cfe5718c9a1f927a2af3728d9c6' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_enrol.gif  width=33 height=20 border=0 style=border:none;></a></td>");
	document.write("<td align=center><a href='http://auto.sina.com.cn/2006-10-12/157/1205.html'><img src=http://image2.sina.com.cn/qc/buy/U263P33T133D5403F2027DT20061012093452.GIF width=58 height=20 border=0 style=border:none;></a></td>");
	document.write("</tr>");
	document.write("</form>");
	document.write("</table>");
	document.write("</td>");
	document.write("<td><img src=http://image2.sina.com.cn/qc/chm0104img/enrol_right.gif width=5 height=33 border=0></td>");
	document.write("</tr>");
	document.write("</table>");	
	
	
}


function getCookie(name) {

  var search;

  search = name + "="
  offset = document.cookie.indexOf(search) 
  if (offset != -1) 
  {
    offset += search.length ;
    end = document.cookie.indexOf(";", offset) ;
    if (end == -1)
      end = document.cookie.length;
    return document.cookie.substring(offset, end);
  }
  else
    return "";
}

	var reged;
	var pos;
	var pos1;
	pos1 = "";
	pos = "";
	reged = "";
		
	g_img=new Image(55,18)
	g_img.src="http://fans.auto.sina.com.cn/imgserial.php?"+ addrandcode();
	reged = getCookie("AUTOFANS");
	var unipro_login_displayname = getCookie( "nick" );
	var unipro_login_pos3 = unipro_login_displayname.indexOf( "(" );
	if ( unipro_login_pos3 != -1 )
	{
		unipro_login_displayname = unipro_login_displayname.substr( 0, unipro_login_pos3 );
	}
	if (getCookie("SINAPRO") == "")
	{
		header_login();
	}
	else
	{
		document.write("<table width=750 border=0 cellspacing=0 cellpadding=0>");
		document.write("<tr>");
		document.write("<td><img src=http://image2.sina.com.cn/qc/chm0104img/enrol_left.gif width=5 height=33 border=0></td>");
		document.write("<td  align=center background=http://image2.sina.com.cn/qc/chm0104img/enrol_bg.gif>");
		
		
						
		pos = reged.indexOf("NO");
		pos1 = reged.indexOf("YES");
		if (pos>=0)
		{
			document.write("<table width=650 border=0 cellspacing=0 cellpadding=0>");
			document.write("<tr>");
			document.write("<td nowrap><b>");	
			document.write(unipro_login_displayname+"您好，欢迎来到我为车魔。");
			document.write("<font color=red>您还不是“我为车魔”会员！</font>");
			document.write("<td>");
			document.write("	<table border=0 cellpadding=0 cellspacing=0>");
			document.write("	<tr>");
			document.write("	<td align=center><a href='http://fans.auto.sina.com.cn/apply/userreg.php'>立即注册</a></td>");
			document.write("	</tr>");
			document.write("	</table>");
			document.write("</td>");
		}		
		else
		{
			if (pos1>=0)
			{
				document.write("<table width=85% border=0 cellspacing=0 cellpadding=0>");
				document.write("<tr>");
				document.write("<td nowrap><b>");	
				document.write(unipro_login_displayname+"您好，欢迎来到我为车魔。");
				document.write("<td width=200></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/addpic.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_01.gif  width=67 height=23 border=0></a></td>");
//				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/addpic.php?type=1' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_02.gif width=67 height=23 border=0></a></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/mypicture.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_dj_01.GIF width=67 height=23 border=0></a></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/classify.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_dj_011.gif width=67 height=23 border=0></a></td>");
			}
			else
			{
				document.write("<table width=650 border=0 cellspacing=0 cellpadding=0>");
				document.write("<tr>");
				document.write("<td nowrap><b>");
				document.write(unipro_login_displayname+"您好，欢迎来到我为车魔。");
				document.write("<td width=200></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/addpic.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_01.gif  width=67 height=23 border=0></a></td>");
	//			document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/addpic.php?type=1' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_02.gif width=67 height=23 border=0></a></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/mypicture.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_dj_01.GIF width=67 height=23 border=0></a></td>");
				document.write("<td align=center><a href='http://fans.auto.sina.com.cn/user/classify.php' target=_blank><img src=http://image2.sina.com.cn/qc/chm0104img/button_dj_011.gif width=67 height=23 border=0></a></td>");
			}
		}
		document.write("</b>");
		document.write("</td>");
		document.write("<td align=center><a href=\"javascript:unipro_UniProLogout();window.location='http://auto.sina.com.cn/fans/index.shtml';\"><img src=http://image2.sina.com.cn/qc/chm0104img/button_04.gif width=67 height=23 border=0></a></td>");
		document.write("</tr>");
		document.write("</table>");
		document.write("</td>");
		document.write("<td><img src=http://image2.sina.com.cn/qc/chm0104img/enrol_right.gif width=5 height=33 border=0></td>");
		document.write("</tr>");
		document.write("</table>");	
		
	}
	
