document.domain="qq.com"
var g_myBodyInstance = null;
var g_init   = null;
var isMinNS4 = null;
var isMinNS5 = null;
var isMinIE4 = null;
var isMinIE5 = null;


function getWindowWidth()
{
	if (isMinIE4||isMinNS5)
		return (g_myBodyInstance.clientWidth);
	else if (isMinNS4)
		return (window.innerWidth);
	return (-1);
}

function getWindowHeight()
{
	if (isMinIE4||isMinNS5)
		return (g_myBodyInstance.clientHeight);
	else if (isMinNS4)
		return(window.innerHeight);
	
	return(-1);
}

function getWidth(layer)
{
	if (isMinIE4||isMinNS5)
	{
		if (layer.style.pixelWidth)
			return (layer.style.pixelWidth);
		else
			return (layer.clientWidth);
	}
	else if (isMinNS4)
	{
		if (layer.document.width)
			return (layer.document.width);
		else
			return (layer.clip.right - layer.clip.left);
	}
	
	return (-1);
}

function getHeight(layer)
{
	if (isMinIE4||isMinNS5)
	{
		if (false && layer.style.pixelHeight)
			return (layer.style.pixelHeight);
		else
			return (layer.clientHeight);
	}
	else if (isMinNS4)
	{
		if (layer.document.height)
			return (layer.document.height);
		else
			return (layer.clip.bottom - layer.clip.top);
	}
	
	return(-1);
}

function getPageScrollY()
{
	if (isMinIE4||isMinNS5)
		return (g_myBodyInstance.scrollTop);
	else if (isMinNS4)
		return (window.pageYOffset);
	
	return (-1);
}

function moveLayerTo(layer, x, y)
{
	if (isMinIE4)
	{
		layer.style.left = x;
		layer.style.top  = y;
	}
	else if (isMinNS5)
	{
		layer.style.left = x+'px';
		layer.style.top  = y+'px';
	}
	else if (isMinNS4)
    	layer.moveTo(x, y);
}


function ptlogin2_onResize(width, height)
{	
	login_wnd = document.getElementById("login_div");
	if (login_wnd)
	{
		login_wnd.style.width = width + "px";
		login_wnd.style.height = height + "px";

		//确定位置
		if ( getWindowWidth() != getWidth(login_wnd) )
		{
			moveLayerTo(login_wnd,(getWindowWidth()-getWidth(login_wnd))/2,getPageScrollY()+(getWindowHeight()-getHeight(login_wnd))/2);
		}
		
		login_wnd.style.visibility = "hidden"
		login_wnd.style.visibility = "visible"
	}
}

function ptlogin2_onClose()
{
	login_wnd = document.getElementById("login_div");	
	login_wnd.style.display="none"
}

function shadeWin(){
    var wnd = $(window), doc = $(document);
    if(wnd.height() > doc.height()){ //当高度少于一屏
        wHeight = wnd.height(); 
    }else{//当高度大于一屏
        wHeight = doc.height();   
    }
    //创建遮罩背景
    $("body").append("<div ID=MaskID></div>");
    $("body").find("#MaskID").width(wnd.width()).height(wHeight)
        .css({position:"absolute",top:"0px",left:"0px",background:"#464646",filter:"Alpha(opacity=90);",opacity:"0.3",zIndex:"2"});

}

function openLogin(aid)
{
	 ptlogin2_forme();
	login_wnd = document.getElementById("login_div");
	if (login_wnd != null){
		login_wnd.style.visible = "hidden"	//先隐藏，这样用户就看不到页面的尺寸变化的效果
		login_wnd.style.display = "block"	//设为block， 否则页面不会真正载入		

		var argv = openLogin.arguments
		if ( argv[1] )
		{
			surl = argv[1];
		}
		else
		{
			surl = window.location;
		}		
		
		var url = "http://ui.ptlogin2.qq.com/cgi-bin/login" + "?"
		url += "f_url=loginerroralert"
		url += "&style=1"
		url += "&appid="  + aid
	  url += "&s_url="  + escape(surl)	
		 if(navigator.userAgent.indexOf("Firefox")>0){
		     login_frame.location.href = url;
		 }
		 else {
		    document.all.login_frame.src = url;
		 }

	}
}


function ptlogin2_writeDiv()
{
	if ( !g_init )
	{
		g_myBodyInstance = document.body;
		isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
		isMinNS5 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
		isMinIE4 = (document.all) ? 1 : 0;
		isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
		isMacIE = (isMinIE4 && navigator.userAgent.indexOf("Mac") >= 0) ? 1 : 0;
		isOpera = (navigator.appName.indexOf("Opera") >= 0) ? 1 : 0;	
		if (document.compatMode != "BackCompat" && !isOpera )
		{	 
		    g_myBodyInstance = document.documentElement;
		}
		
		document.write('<div id=login_div style=" display:none; position:absolute; left: 37%; top: 28%; width:400px; height:330px; padding:0; margin:0px;z-index:100" align="center">');
		document.write('<iframe name="login_frame" frameborder="0" scrolling="auto" width="100%" height="100%" src="">');
		document.write('</iframe></div>');
		g_init = true;
	}	
}

function ptlogin2_forme()
{
	if ( !g_init )
	{
		g_myBodyInstance = document.body;
		isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
		isMinNS5 = (navigator.appName.indexOf("Netscape") >= 0 && parseFloat(navigator.appVersion) >= 5) ? 1 : 0;
		isMinIE4 = (document.all) ? 1 : 0;
		isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.") >= 0) ? 1 : 0;
		isMacIE = (isMinIE4 && navigator.userAgent.indexOf("Mac") >= 0) ? 1 : 0;
		isOpera = (navigator.appName.indexOf("Opera") >= 0) ? 1 : 0;	
		if (document.compatMode != "BackCompat" && !isOpera )
		{	 
		    g_myBodyInstance = document.documentElement;
		}
		var div_=document.getElementById('login_div');

		//alert(g_myBodyInstance.id);
		if(!div_)
		{
			var div=document.createElement('div'); 
			div.id="login_div";
			div.style.display="none";
			div.style.position="absolute";
			div.style.left="40%";
			div.style.top="50%";
			div.style.width="400px";
			div.style.height="330px";
			div.style.padding="0";
			div.style.margin="0";
			div.style.zIndex="99";
			
			div.innerHTML="<iframe name=\"login_frame\" id=\"login_frame\" frameborder=\"0\" scrolling=\"auto\" width=\"100%\" height=\"100%\" src=\"\"></iframe>";
			document.body.appendChild(div);

		}
		
		/*document.write('<div id=\'login_div\' style=" display:none; position:absolute; left: 40%; top: 50%; width:400px; height:330px; padding:0; margin:0px;" align="center">');
		document.write('<iframe name="login_frame" frameborder="0" scrolling="auto" width="100%" height="100%" src="">');
		document.write('</iframe></div>');*/
		g_init = true;
	}	
}

//ptlogin2_writeDiv();
//ptlogin2_forme();