 
function getobj(id)
{
   return document.getElementById(id);
}

function writehtml(id,text)
{
   if(getobj(id)!=null)
   {g(id).innerHTML=text;}
}

function writeText(id,text)
{
   if(getobj(id)!=null)
   {g(id).innerText=text;}
}

function getPos(obj){
	this.Left=0;
	this.Top=0;
	this.Height=obj.offsetHeight;
	this.Width=obj.offsetWidth;
	var tempObj=obj;
	while (tempObj.tagName.toLowerCase()!="body" && tempObj.tagName.toLowerCase()!="html"){
		this.Left+=tempObj.offsetLeft;
		this.Top+=tempObj.offsetTop;
		tempObj=tempObj.offsetParent;
		
	}
}

function getMousePos(ev)
{  
	if(ev.pageX || ev.pageY)
	{
		return {Left:ev.pageX, Top:ev.pageY};
	}
	return {
		Left:ev.clientX + document.documentElement.scrollLeft,Top:ev.clientY + document.documentElement.scrollTop
		}; 
}

function showMessageBox(content,pos,wWidth)
{
	var arrayPageSize= getPageSize();//调用getPageSize()函数		
	var arrayPageScroll = getPageScroll();//调用getPageScroll()函数
	
   closeWindow();
   var bWidth=parseInt(document.documentElement.scrollWidth);
    var bHeight=parseInt(document.documentElement.scrollHeight);
	var mesW=document.createElement("div");
	mesW.id="messagebox";
	mesW.innerHTML= "<div style='border-bottom:3px #a10101 solid;border-right:3px #a10101 solid;border-top:0px #a10101 solid; background-color:#a10101; border-left:3px #a10101 solid; width:275px; padding-left:5px; padding-top:10px; height:10px; font-size:13px; ' align='left'  ><span style='margin-left:230px; font-size:12px; color:black;'><a href='javascript:closeWindow()' style='color:black; ' >[关闭]</a></span></div><div style='border-bottom:3px #a10101 solid;border-right:3px #a10101 solid;border-top:0px #a10101 solid; border-left:3px #a10101 solid; width:260px; padding:10px 10px 10px 10px; line-height:200% ;background-color:white; font-size:13px; '  align='center'  >"+content+"！！<a href='/users/ShowCollect.asp' target='_blank' style='font-size:13px; ' >查看收藏夹</a><br><FONT color='#FF0000'><span id=sec>5</span></FONT> 秒钟之后自动关闭！</div>"
 
 
 	var v_top=arrayPageScroll[1] + (arrayPageSize[3] - 50) / 2-50;
    var v_left=(arrayPageSize[0] - 260) / 2;

    
	if(bWidth-pos.Left<wWidth)
	{
	   styleStr="left:"+v_left+"px;";
	}
	else
	{
	   styleStr="left:"+v_left+"px;";
	}
	styleStr+="top:"+v_top+"px;position:absolute;width:"+wWidth+"px;background-color:white";
	mesW.style.cssText=styleStr;
	document.body.appendChild(mesW);
	 //setTimeout(function(){closeWindow();},4000);
	 countClose(5);
	
}



 

function closeWindow()
{
    if(getobj('messagebox')!=null)
    {  
       getobj('messagebox').parentNode.removeChild(getobj('messagebox'));
    }
}




function countClose(secs){
try{
 var tiao= document.getElementById("sec");
 tiao.innerHTML=secs;
 
 if(--secs>-1){
     setTimeout("countClose("+secs+")",1000);
     }
 else{
   closeWindow();
     }
   }
   catch(e){}   
 }
 
 function getPageSize()//获取页面实际大小
{
    var xScroll,yScroll;
    if (window.innerHeight  &&  window.scrollMaxY)
    {
        xScroll = document.body.scrollWidth;
        yScroll = window.innerHeight + window.scrollMaxY;   
    } 
    else if (document.body.scrollHeight > document.body.offsetHeight)
    {
        sScroll = document.body.scrollWidth;
        yScroll = document.body.scrollHeight;
    } 
    else 
    {
        xScroll = document.body.offsetWidth;
        yScroll = document.body.offsetHeight;
    }
    var windowWidth,windowHeight;
    //var pageHeight,pageWidth;
    if (self.innerHeight)
    {
        windowWidth = self.innerWidth;
        windowHeight = self.innerHeight;
    } 
    else if (document.documentElement  &&  document.documentElement.clientHeight) 
    {
        windowWidth = document.documentElement.clientWidth;
        windowHeight = document.documentElement.clientHeight;
    } 
    else if (document.body)
    {
        windowWidth = document.body.clientWidth;
        windowHeight = document.body.clientHeight;
    }
    var pageWidth,pageHeight
    if(yScroll < windowHeight)
        pageHeight = windowHeight;
    else 
        pageHeight = yScroll; 
           
    if(xScroll < windowWidth)     
        pageWidth = windowWidth;   
    else    
        pageWidth = xScroll;
    
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
    return arrayPageSize;
}

function getPageScroll()//获取滚动条的高度
{
    var yScroll;
    if (self.pageYOffset)
    {
        yScroll = self.pageYOffset;
    } 
    else if (document.documentElement  &&  document.documentElement.scrollTop)
    {
        yScroll = document.documentElement.scrollTop;
    } 
    else if (document.body) 
    {
        yScroll = document.body.scrollTop;
    }
    arrayPageScroll = new Array('',yScroll)
    return arrayPageScroll;
}
