function getCookieVal2Car(n){var c=document.cookie.match(new RegExp("(^| )"+n+"=([^;]*)(;|$)")); if(c==null){return ""; }else{return unescape(c[2]);}} 
function getCookieVal(n){var c=document.cookie.match(new RegExp("(^| )"+n+"=([^;]*)(;|$)")); if(c==null){return ""; }else{return decodeURIComponent(c[2]);}} 
var userName = getCookieVal("51autoUserName");
var isPlay=0;
function refreshCaptchaTop(){isPlay=1;document.getElementById('captchaImg2').src='http://www.51auto.com/ValidateCode?'+ Math.round(Math.random() * 100000);}
if(userName==""){
	document.write('<form name="form" method="post" action="http://www.51auto.com/control/VerifyUser"><input name="forward" value="http://www.51auto.com/control/MyAuto" type="hidden"><ul><li>用户名 <input type="text" name="username" class="topinput1"/></li><li>密码 <input type="password" name="password" class="topinput1"/></li><li>校验码 <input type="text" name="ValidateCode" class="topinput1" style="width:45px" onFocus="if(isPlay==0){refreshCaptchaTop();}"/></li><li style="padding-top:3px "><img src="http://img.51auto.com/home2010/yanzheng.gif" alt="看不清，点击换一张" width="80" height="22" id="captchaImg2" onclick="javascript:refreshCaptchaTop()"/></li><li style="padding-top:3px"><input src="http://img.51auto.com/home2010/dl.gif" type="image" width="42px" height="21px"  ></li><li><a href="http://www.51auto.com/myauto.html" target="_blank" class="font12b_un" style="line-height:28px">新用户注册</a></li></ul></form>');
}else{
	document.write('<ul><li style="line-height:28px ">欢迎您 <span>'+userName+'</span>&nbsp;&nbsp;</li>');
	document.write('<li style="padding-top:3px"><a href="http://www.51auto.com/control/Logout" target="_parent"><img src="http://img.51auto.com/dc.gif" width="50px" height="19px"></a></li></ul>');
}


/*
 * 图片按比例缩放 
 * ImgD 图片对象
 * iWidth 定义允许图片宽度 
 * iHeight 定义允许图片高度 
 * 一般使用方法：onLoad = "DrawImage(this);"
 */
function DrawImage(ImgD,iWidth,iHeight){ 
	 if(ImgD.src==""){
		 ImgD.src = "http://img.51auto.com/wutu_small.gif";
	 }
	 var image=new Image(); 
	 image.src=ImgD.src; 
	 
	 var imgW = image.width;
	 var imgH = image.height;

	 if(imgW>0 && imgH>0){ 
		if(imgW/imgH>= iWidth/iHeight){ 
			if(imgW>iWidth){
				ImgD.width=iWidth; 
				ImgD.height=(imgH*iWidth)/imgW; 
			}else{
				ImgD.width=imgW;
				ImgD.height=imgH; 
			}
		}else{
			if(imgH>iHeight){ 
				ImgD.height=iHeight; 
				ImgD.width=(imgW*iHeight)/imgH;   
			}else{
				ImgD.width=imgW;
				ImgD.height=imgH; 
			}
		}
	} 
}  