if (!window.ZHISHI){ ZHISHI = {} }
ZHISHI.createTopMaskDIV = function(alphaNum)
{
	if (window!=window.top)
	{
		 top.ZHISHI.createTopMaskDIV(alphaNum);
		 return;
	}
	var topMask = document.createElement("DIV");

	ZHISHI.resizeMaskFull(topMask);

    topMask.setAttribute("id","M_DOMmaskDIV");
    topMask.style.position = "absolute";
    topMask.style.left = topMask.style.top = "0px";
    topMask.style.zIndex = 100;
    topMask.style.backgroundColor = "#F2F2F2"; 
    topMask.onselectstart = function(){return false}
    
    document.body.appendChild(topMask);
	topMask.style.filter="Alpha(opacity="+alphaNum+")";
    topMask.style.MozOpacity = alphaNum/100;

	if(window.attachEvent)window.attachEvent('onresize',ZHISHI.resizeMaskFull);
    else window.addEventListener("click", ZHISHI.resizeMaskFull, false);
}

ZHISHI.createTopFrame = function(PO)
{
	if (window!=window.top){
		 top.ZHISHI.createTopFrame(PO);
		 return;
	}
	PO.w = PO.w || 770;
	PO.h = PO.h || 540
	PO.name = PO.name || 'M_ZHISHIopFrame';

	var d = document.createElement("IFRAME");
    d.src = PO.src;
    d.setAttribute("id" ,PO.name);
    d.setAttribute("name" ,PO.name);
    d.setAttribute("scrolling" ,"no");
	d.setAttribute('frameborder','0',0);
	var ds = d.style;
    ds.position = "absolute";
    ds.zIndex = 101;
    ds.top = "50%";
    ds.left = "50%";
    ds.width  = PO.w +"px";
    ds.height = PO.h +"px";
    ds.overflow="hidden";
    ds.marginTop  = -parseInt(PO.h/2) + document.body.scrollTop+"px";//"-180px";
    ds.marginLeft = -parseInt(PO.w/2) +"px";
	ds.backgroundColor = "white";
	//ds.border = PO.border||"3px solid #38A8E4";
	//d.frameBorder = d.frameSpacing = 2;
    document.body.appendChild(d);
}

ZHISHI.createLogin = function()
{
	ZHISHI.createTopMaskDIV(60);
    var ua=navigator.userAgent.toLowerCase();
    var isOpera=(ua.indexOf('opera')>-1);
    var isSafari=(ua.indexOf('safari')>-1);
    var isFirefox=(ua.indexOf('firefox')>-1);    
    var isIE=(window.ActiveXObject);
    var ph;
    if(isIE)ph=288;
    if(isFirefox)ph=278;
    if(isSafari)ph=286;
    if(isOpera)ph=302;
    
	var PO = {
        w: 375,h:ph, src:'http://ui.ptlogin2.soso.com/cgi-bin/login?link_target=blank&appid=6000201&f_url=loginerroralert&hide_uin_tip=1&target=parent&hide_close_icon=1&s_url='+encodeURIComponent(document.location),
		border:'1px solid #38A8E4'
	}

	ZHISHI.createTopFrame(PO);

	var sttime;
	window.onscroll = function()
	{
		window.clearTimeout(sttime);
		sttime = window.setTimeout(st,100);
	}
	function st()
	{
		document.getElementById('M_ZHISHIopFrame').style.marginTop = -180 + document.body.scrollTop+"px";
	}   
}

ZHISHI.resizeMaskFull = function(dom)
{
	var d=document.getElementById('M_DOMmaskDIV')||dom;
	if (d)
	{
		try{
			d.style.width = document.body.clientWidth;
			d.style.height = document.body.scrollHeight;
		}catch(e){}
	}
}

ZHISHI.cancelTopFrame = function(noClear)
{
	if(window.detachEvent)window.detachEvent('onresize',ZHISHI.resizeMaskFull);
    else if(window.removeEventListener)window.removeEventListener('onresize',ZHISHI.resizeMaskFull,false);
	window.onscroll = function(){}
    var _$domdiv = document.getElementById("M_DOMmaskDIV");
    if (_$domdiv) { _$domdiv.parentNode.removeChild(_$domdiv); }
    var _$loginFrame = document.getElementById("M_ZHISHIopFrame");
    if (_$loginFrame) { _$loginFrame.parentNode.removeChild(_$loginFrame); }
}