﻿// JavaScript Document
/***/

var popCover=function()
{
    this.CoverDiv='Cover_div';
    this.LoginDiv='LoginParentDiv';
    this.bgColor='#CCCCCC';
    this.bodySize= getBodySize();
    this.ScrolPostion=getScrolPostion();
    this.Timer=null;
	this.RemoveCoverDiv=function()
	{
	   var obj=$(this.LoginDiv)
	   if (obj)
	   {
		//document.body.removeChild(obj);
		obj.style.display='none';
	   }
	   obj=$(this.CoverDiv);
	   if (obj)
	   {
		//document.body.removeChild(obj);
		obj.style.display='none';
	   }
	}
	
	/***/
	this.popCoverDiv=function(Layer)
	{
	   var obj=$(this.CoverDiv);
	   if (obj)
	   {
		obj.style.display = 'block';
	   }
	   else 
	   {
		obj = $C('div');
		document.body.appendChild(obj);
		obj.id = this.CoverDiv;
		obj.className='Coverage';
		}
		with(obj.style)
		{
		 position = 'absolute';
		 //background = this.bgColor;
		 left = '0px';
		 top = '0px';
		 //this.bodySize= getBodySize();
		 width = this.bodySize.x + 'px'
		 height = this.bodySize.y + 'px';
		 //zIndex = Layer;
		 textAlign='center';
		 lineHeight=height;
		  filter = "Alpha(Opacity=15)";
		  opacity = 0.15;
		}
	   obj.innerHTML="";
	}
	/*载入模板*/
	this.SetContent=function(temlate)
	{
	   var obj=$(this.CoverDiv);
	   if (!obj)
	   {
		alert('未能载入登录模板');
		return false;
	   }

        var loginDivWidth = 700;
        var signDiv = $C('div');
        document.body.appendChild(signDiv);
        signDiv.id = this.LoginDiv;
        //signDiv.align = "center";
        with (signDiv.style)
        {    
             position = 'absolute';
             left = (this.bodySize.x - loginDivWidth)/2 + 'px';
             top = this.ScrolPostion.y+250+'px';//(this.bodySize.y - 500)/2 + 'px';
             width = loginDivWidth + 'px';
             //zIndex = 8889;
             background = '#FFFFFF';
             //border = '#66CCFF solid 1px';
         }

	   signDiv.innerHTML=temlate;
	   $('CodeImg').src=CodeImgPath+'?rnd='+Math.random();
	   $('regCodeImg').src=CodeImgPath+'?rnd='+Math.random();
	    return true;
	}
	
	/*显示登录层*/
	this.ShowSignPanel=function()
	{
	   var obj=$(this.CoverDiv);
	   if (!obj)
	   {
	    this.RemoveCoverDiv();
		alert('未能载入登录模板');
		return false;
	   }

        var loginDivWidth = 510;
        var signDiv = $(this.LoginDiv);
        
        if(!signDiv)
        {
            alert(signDiv);
            this.RemoveCoverDiv();
            alert('未能载入登录模板3');
            return false;
        }
        with (signDiv.style)
        {    
             position = 'absolute';
             left = (this.bodySize.x - loginDivWidth)/2 + 'px';
             top = this.ScrolPostion.y+200+'px';
             //width = loginDivWidth + 'px';
             //zIndex = 8889;
             background = '#FFFFFF';
             display='block';
             //border = '#66CCFF solid 1px';
         }
	    return true;
	}	
	
	this.ContentMove=function()
	{
	    var defaultTop=0;
	    var obj=$(this.LoginDiv)
	    if(!obj)
	        return;
	    
	    defaultTop+=this.ScrolPostion.y;
	    if(this.ScrolPostion.y<=0)    
	        defaultTop=200;
	    var pt=GetPoint(obj);

	    if(defaultTop>pt.y)
	    {
	        for(var i=pt.y;i<defaultTop;i++)
	            obj.style.top=i+'px';
	    }
	    if(defaultTop<pt.y)
	    {
	        for(var i=pt.y;i>=defaultTop;i--)
	            obj.style.top=i+'px';
	    }
	    if(defaultTop<=200)
	        defaultTop=200;
	    obj.style.top=defaultTop+'px';  
	}

}