var isIe=(document.all)?true:false; 

//设置select的可见状态 
function setSelectState(state) 
{ 
 var objl=document.getElementsByTagName('select'); 
 for(var i=0;i<objl.length;i++) 
 { 
 objl[i].style.visibility=state; 
 } 
} 

function mousePosition(ev) 
 { 
	 if(ev.pageX || ev.pageY) 
	 { 
	 return {x:ev.pageX, y:ev.pageY}; 
	 } 
	 return { 
	 x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop 
	 }; 
 } 

//弹出方法 
function showMessageBox(wTitle,content,pos,wWidth) 
{ 
	 closeWindow(); 
	 window.scrollTo(0,0);
	 if(isIe){ 
	 setSelectState('hidden');} 
	 var bWidth=parseInt(document.documentElement.scrollWidth); 
	 var bHeight=parseInt(document.documentElement.scrollHeight); 
	 var back=document.createElement("div"); 
	 back.id="back"; 
	 var styleStr="top:0px;left:0px;position:absolute;background:#F4F4F4;width:"+bWidth+"px;height:"+bHeight+"px;"; 
	 styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;"; 
	 back.style.cssText=styleStr; 
	 document.body.appendChild(back); 
	 var mesW=document.createElement("div"); 
	 mesW.id="mesWindow"; 
	 mesW.className="mesWindow"; 
	 mesW.innerHTML=""+content+""; 
	 
	 styleStr="left:32%;top:36%;position:absolute;width:"+wWidth+"px;height:150px;"; 
	 mesW.style.cssText=styleStr; 
	 document.body.appendChild(mesW); 
	 showBackground(back,40); 
} 

//让背景渐渐变暗 
 function showBackground(obj,endInt) 
{ 
	 if(isIe) 
	 { 
		obj.filters.alpha.opacity+=10; 
		if(obj.filters.alpha.opacity<endInt) 
		{ 
			setTimeout(function(){showBackground(obj,endInt)},5); 
		} 
	}else{ 
		var al=parseFloat(obj.style.opacity);al+=0.1; 
		obj.style.opacity=al; 
		if(al<(endInt/100)) 
		{
			setTimeout(function(){showBackground(obj,endInt)},5);
		} 
	} 
} 


// 背景的渐显. 
function checkIMBAlpha(){ 
	smObject.style.filter = "alpha(opacity="+smAlpha+");"; 
	smAlpha += 10; 
	if (smAlpha>80){ 
	clearInterval(smInterval); 
	}
} 


//关闭窗口 
function closeWindow() 
{ 
	 if(document.getElementById('back')!=null) 
	 { 
		 document.getElementById('back').parentNode.removeChild(document.getElementById('back')); 
	 } 
	 if(document.getElementById('mesWindow')!=null) 
	 { 
		 document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow')); 
	 } 
	 if(isIe){ 
	 setSelectState('');} 
} 


//弹出 
function LoginBox(ev,target,referer) 
{ 
 var objPos = mousePosition(ev); 
 messContent="<form name=login action='/inc/logging_common_post.php' method=post accept-charset=GBK target='"+target+"'><style>body,tr,td,font {font-size: 12px;}</style><table border=1 borderColor=#99BBE8 cellPadding=0 cellSpacing=0 style=BORDER-COLLAPSE: collapse align=center height=150 width=300 bgcolor=#FFFFFF><tr><td height=24 background=/images/common/topbg1.gif align=center>千千音乐在线用户登录</td></tr><tr><td height=100px><table border=0 cellPadding=0 cellSpacing=0><tr><td colspan=5 height=10></td></tr><tr><td width=100 align=right>用户名：</td><td height=22 background=/images/common/inputbg.gif style=background-repeat:no-repeat><input name=username type=text maxlength=100 style=width:157;height:22;border:0;background:Transparent onKeyDown=ctlSubmit(event);></td></tr><tr><td colspan=5 height=5></td></tr><tr><td width=100 align=right>密&nbsp;&nbsp;码：</td><td height=22 background=/images/common/inputbg.gif style=background-repeat:no-repeat><input name=password type=password maxlength=100 style=width:157;height:22;border:0;background:Transparent onKeyDown=ctlSubmit(event);></td></tr><tr><td colspan=5 height=5></td></tr><tr><td width=100 height=25></td><td><img src=/images/common/login.gif  onClick=CheckAndSubmit(); style=cursor:hand>&nbsp;<img src=/images/common/close.gif onClick=closeWindow(); style=cursor:hand></td></tr></table></td></tr><tr><td height=25 background=/images/common/topbg2.gif id=alerts style='color:red'></td></tr></table><input type=hidden name=Suc_referer value="+referer+"></form>";
 showMessageBox('',messContent,objPos,500);
}



function ctlSubmit(event) { 
	if ( event.keyCode == 13) { CheckAndSubmit(); } 
}

function CheckAndSubmit()
{
     if (document.login.username.value == "")
     {
		 alerts.innerHTML="&nbsp;错误,请输入用户名！";
         document.login.username.focus();
         return (false);
     }

     if (document.login.password.value == "")
     {
		 alerts.innerHTML="&nbsp;错误,请输入密码！";
         document.login.password.focus();
         return (false);
     }
	//document.login.Suc_referer.value=document.location.href;
	document.login.submit();
	closeWindow();
}
