var timePopup=160;
var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var adCount=0;
var hdCount=0;
var iTime;
var msDiv;
var scrollPos; 



//function showHtml(intX)
//{
//   document.write("<div  style='text-align: left; left: 0px; visibility: hidden; width: 1px;position: absolute; top: 50px; height: 1px' bgcolor='#9CC2D8'>");
//   document.write("<table onmouseover='clearpop();' onmouseout='showPopup();' height='40' cellspacing='0' cellpadding='0' style='width:187px;background-color:#9cc2d8;' background='/page/images/message/showmsg2.jpg'>");
//   document.write("<tr>");
//   document.write("<td align=right style='vertical-align:top' height='33' background='/page/images/message/showmsg1.jpg'>");
//   document.write("<img onclick='closePopup();' title=关闭 style='padding-top:5px;padding-right:5px;' src='/page/images/message/close.gif'  /></td>");
//   document.write("</tr><tr>");
//   document.write("<td background='/page/images/message/showmsg4.jpg' style='text-align:center;height:29px;'>");
//   document.write("<a href='/page/individual/myhouseIndex.aspx?method=GetLw' style='font-size:12px' >您有新的消息(<font color='red'>"+ intX +"</font>)</a>");
//   document.write("</td></tr><tr><td valign='bottom'><img src='/page/images/message/showmsg3.jpg' border='0'></td></tr></table></div> ");
// }

function initPopup2()
{
    setTimeout("initPopup()",1000);
    
   //document.getElementById('msgTitle').innerHTML =window.;
  
}

function initPopup(){
	if(!ns && !ie && !w3){
		return;
	}
	//showHtml(5);
    //showHtml(5);
//	if(GetCookie("showmm")==2){
//	    return;
//	}
     
	if(ie){
	 if(document.all.windlocation1)
	 {
        msDiv=eval('document.all.windlocation1.style');	 
	 }
     }else if(ns){
		msDiv=eval('document.layers["windlocation1"]');
	}else if(w3){
		msDiv=eval('document.getElementById("windlocation1").style');
	}
	if(msDiv)
	{
	if (ie||w3){
		msDiv.visibility="visible";
	}else{
		msDiv.visibility ="show";
	}}
	
	  if (typeof window.pageYOffset != 'undefined') { 
           scrollPos = window.pageYOffset; 
        } 
        else if (typeof document.compatMode != 'undefined' && 
             document.compatMode != 'BackCompat') { 
           scrollPos = document.documentElement.scrollTop; 
        } 
        else if (typeof document.body != 'undefined') { 
           scrollPos = document.body.scrollTop; 
        } 
      
	
	if(msDiv)
	{
	    showPopup();
	}
	 
}

function showPopup(){

	if (ie){
		documentWidth  =document.documentElement.offsetWidth;
		documentHeight =document.documentElement.offsetHeight+scrollPos-160;
	} else if (ns){
		documentWidth  =window.innerWidth;
		documentHeight =window.innerHeight+scrollPos-160;
	} else if (w3){
		documentWidth  =self.innerWidth;
		documentHeight =self.innerHeight+scrollPos-160;
	}
	msDiv.right=documentWidth;

	if(adCount < 10){
		adCount++;
		msDiv.top = documentHeight+160-adCount*8;
		iTime = setTimeout("showPopup()",100);
	}else if(adCount < timePopup-10){
		adCount++;
		msDiv.top = documentHeight;
		iTime = setTimeout("showPopup()",100);
		}

}

function closePopup(){
	if (ie||w3){
		msDiv.display="none";
	}else{
		msDiv.visibility ="hide";
	}

}

function closePopOn()
{
    if (ie||w3){
		msDiv.display="none";
	}else{
		msDiv.visibility ="hide";
	}
    SetCookie("showmm",2,6);
}

function clearpop(){
	clearTimeout(iTime);
}

function hide(){
	closePopup();
	//document.cookie="msghide=1; path=/";
}

var changePos1=function(){
    var obj=document.getElementById("windlocation1");
	if(obj==null) return;
//	obj.style.top=(document.body.clientHeight+document.body.scrollTop -obj.offsetHeight ) +"px";
//	obj.style.left=(document.body.clientWidth+ -obj.offsetWidth ) +"px";
  if (typeof window.pageYOffset != 'undefined') { 
           scrollPos = window.pageYOffset; 
        } 
        else if (typeof document.compatMode != 'undefined' && 
             document.compatMode != 'BackCompat') { 
           scrollPos = document.documentElement.scrollTop; 
        } 
        else if (typeof document.body != 'undefined') { 
           scrollPos = document.body.scrollTop; 
        } 
 
    
obj.style.top=(document.documentElement.offsetHeight+scrollPos-160) +"px";
//    //alert(document.documentElement.clientWidth);
//    obj.style.left="0px";
obj.style.right="0px";


var obj=document.getElementById("msgboxDiv");
if(obj==null) return;
obj.style.top=(document.body.clientHeight+document.body.scrollTop -obj.offsetHeight ) +"px";
obj.style.left=(document.body.clientWidth+ -obj.offsetWidth ) +"px";

}
window.attachEvent("onscroll",   changePos1);
window.attachEvent("onresize",   changePos1);


/*
    设置cookie
*/
function SetCookie(name,value,expireHours) 
{ 
    var cookieString=name+"="+escape(value);
      //判断是否设置过期时间
      if(expireHours>0){
             var date=new Date();
             date.setTime(date.getTime()+expireHours*3600*1000);
             cookieString=cookieString+"; expires="+date.toGMTString() +"; domain=.pepo.cn; path=/;"
      }
      document.cookie=cookieString;

} 

function GetCookie(sName) 
{ 
    var aCookie = document.cookie.split("; "); 
    for (var i=0; i < aCookie.length; i++) 
    { 
        var aCrumb = aCookie[i].split("="); 
        if (sName == aCrumb[0])  
            return unescape(aCrumb[1]); 
    } 
}

function DelCookie(sName) 
{ 
	document.cookie = sName + "=; expires=" + new Date().toLocaleString() + ";"; 
}

function chanImg(obj,strType)
{
    if(strType=="over") { obj.src='/page/images/message/close_over.gif';}
    if(strType=="over") { obj.src='/page/images/message/close.gif';}
}

//initPopup2();

window.attachEvent("onload",   initPopup);   