﻿// 名称:Common.js
// 功能描述:弹出层
// 作者:朱国庆
// 修改时间:2008-07-24



//******************************
//基础函数
//******************************

var Eval={
    GetTop:function()   //屏幕可视范围离页面顶距离,放在这里是为了好管理
    {
        if(typeof(window.pageYOffset)!='undefined')
        {
	        return window.pageYOffset;
        }
        else if(typeof(document.compatMode)!='undefined'&&document.compatMode!='BackCompat')
        {
	        return document.documentElement.scrollTop;
        }
        else if(typeof(document.body)!='undefined')
        {
	        return document.body.scrollTop;
        }
    },
    
    GetLeft:function()  //屏幕可视范围离左边距离
    {
        if(typeof(window.pageXOffset)!='undefined')
        {
	        return window.pageXOffset;
        }
        else if(typeof(document.compatMode)!='undefined'&&document.compatMode!='BackCompat')
        {
	        return document.documentElement.scrollLeft;
        }
        else if(typeof(document.body)!='undefined')
        {
	        return document.body.scrollLeft;
        }
    },
    
    GetWidth:function() //屏幕可视范围宽
    {
        if(typeof(document.compatMode)!='undefined'&&document.compatMode!='BackCompat')
        {
	        return document.documentElement.clientWidth;
        }
        else if(typeof(document.body)!='undefined')
        {
	        return document.body.clientWidth;
        }
    },
    
    GetHeight:function()    //屏幕可视范围高
    {
        if(typeof(document.compatMode)!='undefined'&&document.compatMode!='BackCompat')
        {
	        return document.documentElement.clientHeight;
        }
        else if(typeof(document.body)!='undefined')
        {
	        return document.body.clientHeight;
        }
    }
}


function JopLayer(){
    this.layer=null;
     this.llayer=null;    
    var _me=this;   
    var imgw=124;
    var imgh=300;
    var laUrl="http://www.91555.com/mm/active/nj";
    var laTitle="";    
    var limgUrl="images/ad.png";
    var aUrl="http://www.91555.com/mm/active/nj";
    var aTitle="";
    var imgUrl="images/ad.png";

    this.Show=function()
    {
	
	try{
	var mIEw=Eval.GetWidth();
	if(mIEw>1004){
		mIEw=(mIEw-800)/2+800+imgw;
	}
	if(mIEw<800){
		mIEw=800+imgw;
	}
        var _layer=document.createElement("div");
        _layer.style.cssText="position:absolute;visibility:visible; width:"+imgw+"px; height:"+imgh+"px; z-index:100; left: "+(mIEw-imgw+50)+"px; top: "+(Eval.GetTop()+120)+"px;";
        _layer.innerHTML="<a href='"+aUrl+"' target='_blank' title='"+aTitle+"'><img src='"+imgUrl+"' width='"+imgw+"px' height='"+imgh+"px' border='0' /></a>";
        document.body.appendChild(_layer);
        _me.layer=_layer;
        if(document.body.onscroll){
            document.body.onscroll=function(){
             if(_me.layer!=null)
             {
                _me.layer.style.top=(Eval.GetTop()+120)+"px";
             }
             if(_me.llayer!=null)
             {
                _me.llayer.style.top=(Eval.GetTop()+120)+"px";
             }
            };
        }else
        {
            window.onscroll=function(){
             if(_me.layer!=null)
             {
                _me.layer.style.top=(Eval.GetTop()+120)+"px";
             }
             if(_me.llayer!=null)
             {
                _me.llayer.style.top=(Eval.GetTop()+120)+"px";
             }
            };
        }
        
        if(document.body.onresize){
            document.body.onresize=function(){
		var mIEw1=Eval.GetWidth();
		if(mIEw1>1004){
			mIEw1=(mIEw-800)/2+800+imgw;
		}
		if(mIEw1<800){
			mIEw1=800+imgw;
		}
                _me.layer.style.left=(mIEw1-imgw)+"px";
            };
        }else
        {
            window.onresize=function(){
		var mIEw2=Eval.GetWidth();
		if(mIEw2>1004){
			mIEw2=(mIEw-800)/2+800+imgw;
		}
		if(mIEw2<800){
			mIEw2=800+imgw;
		}
                _me.layer.style.left=(mIEw2-imgw)+"px";
            };
        }
	}catch(e){
		
	}
    }
    
    ///////////////////
    this.Showl=function()
    {
	
	try{
	var mIEw=Eval.GetWidth();
	var le=5;
	if(mIEw>1004){
		le=(mIEw-800)/2-100;
	}
	if(mIEw<800){
		le=5;
	}
        var _layer=document.createElement("div");
        _layer.style.cssText="position:absolute;visibility:visible; width:"+imgw+"px; height:"+imgh+"px; z-index:100; left: "+(le-50)+"px; top: "+(Eval.GetTop()+120)+"px;";
        _layer.innerHTML="<a href='"+laUrl+"' target='_blank' title='"+laTitle+"'><img src='"+limgUrl+"' width='"+imgw+"px' height='"+imgh+"px' border='0' /></a>";
        document.body.appendChild(_layer);
        _me.llayer=_layer;
        if(document.body.onscroll){
            document.body.onscroll=function(){
             if(_me.layer!=null)
             {
                _me.layer.style.top=(Eval.GetTop()+120)+"px";
             }
             if(_me.llayer!=null)
             {
                _me.llayer.style.top=(Eval.GetTop()+120)+"px";
             }
            };
        }else
        {
            window.onscroll=function(){
             if(_me.layer!=null)
             {
                _me.layer.style.top=(Eval.GetTop()+120)+"px";
             }
             if(_me.llayer!=null)
             {
                _me.llayer.style.top=(Eval.GetTop()+120)+"px";
             }
              
            };
        }
        
        if(document.body.onresize){
            document.body.onresize=function(){
		var mIEw1=Eval.GetWidth();
		if(mIEw1>1004){
			mIEw1=(mIEw-800)/2+800+imgw;
		}
		if(mIEw1<800){
			mIEw1=800+imgw;
		}
                _me.layer.style.left=(mIEw1-imgw)+"px";
            };
        }else
        {
            window.onresize=function(){
		var mIEw2=Eval.GetWidth();
		if(mIEw2>1004){
			mIEw2=(mIEw-800)/2+800+imgw;
		}
		if(mIEw2<800){
			mIEw2=800+imgw;
		}
                _me.layer.style.left=(mIEw2-imgw)+"px";
            };
        }
	}catch(e){
		
	}
    }
    
}




function DisplayAd()
{
    var la=new JopLayer();
    la.Show();
    la.Showl();
    //ShowFloatAD();
}

setTimeout("DisplayAd()", 2000);


//var x = 50,y = 60
//var xin = true, yin = true
//var step = 1
//var delay = 30
//var itl;
//var obj;
//var piaofu="/common/ad/piaofu.jpg"

//function floatAD() {
//    var L=T=0
//    var R= Eval.GetWidth()-obj.offsetWidth
//    var B = Eval.GetHeight()-obj.offsetHeight
//    obj.style.left = x + Eval.GetLeft();
//    obj.style.top = y + Eval.GetTop()
//    x = x + step*(xin?1:-1)
//    if (x < L) { xin = true; x = L}
//    if (x > R){ xin = false; x = R}
//    y = y + step*(yin?1:-1)
//    if (y < T) { yin = true; y = T }
//    if (y > B) { yin = false; y = B }
//}

//function ShowFloatAD(){
//    obj=document.createElement("div");
//    obj.id="piaoad";
//    obj.style.cssText="position:absolute;z-index:101;";
//    obj.innerHTML="<img src=\""+piaofu+"\" border=\"0\">";
//    document.body.appendChild(obj);
//    itl= setInterval("floatAD()", delay)
//    obj.onmouseover=function(){clearInterval(itl)}
//    obj.onmouseout=function(){itl=setInterval("floatAD()", delay)}
//}


                