﻿function IEHover() //IE下拉专用
 {
    var sfEls = document.getElementById("MainMenu").getElementsByTagName("li");
    for (var i=0; i<sfEls.length; i++) 
        {
          sfEls[i].onmouseover=function() {
            this.className+=" hover";
        }
        sfEls[i].onmouseout=function() {
           this.className=this.className.replace(new RegExp("( ?|^)hover\\b"),"");
        }
      }
 }

function FontZoom(Size,LineHeight,Id)
 {
   var Obj=document.getElementById(Id);
   Obj.style.fontSize=Size; 
   Obj.style.lineHeight=LineHeight; 
 }

//图片放大
function previewImgShow(obj,src,MaxWidth,MaxHeight)
{
if(!obj)return;
var floatObj=document.getElementById("floatPreviewImg",MaxWidth,MaxHeight);
floatObj.innerHTML="<img src='"+src+"' id='PreviewImg' style='cursor:pointer' />";
floatObj.style.left=getOffsetLeft(obj)+"px";
floatObj.style.top=getOffsetTop(obj)+"px";
floatObj.style.display="";
setPicRange(document.getElementById("PreviewImg"),MaxWidth,MaxHeight);
}

function getOffsetTop(obj) {

var n = obj.offsetTop;
while (obj = obj.offsetParent) n+= obj.offsetTop;
return n;

}

function getOffsetLeft(obj) {

var n = obj.offsetLeft;
while (obj = obj.offsetParent) n+= obj.offsetLeft;
return n;
}

function setPicRange(obj,maxW,maxH)
{
 if(obj.width>maxW || obj.height>maxH )
 {
  if(obj.width/obj.height>maxW/maxH  )
   obj.width=maxW;
  else 
   obj.height=maxH;
 }
}




//滚动插件
function PARoll(a)
{
	this.TheA = a;
	this.TheA.IsPlay = 1;
	this.$(a.box).style.overflow = "hidden";
                if(a.width!="")
                 {this.$(a.box).style.width = a.width;}
                if(a.height!="")
                 {this.$(a.box).style.height = a.height; }
	this.$(a.box2).innerHTML=this.$(a.box1).innerHTML;
	this.$(a.box).scrollTop=this.$(a.box).scrollHeight;
        this.$(this.TheA.box).scrollTop=0;
	this.Marquee();
	this.$(a.box).onmouseover=function() {eval(a.objname+".clearIntervalRoll();");}
	this.$(a.box).onmouseout=function() {eval(a.objname+".setTimeoutRoll();")}
}
PARoll.prototype.$ = function(Id)
{
	return document.getElementById(Id);
}
PARoll.prototype.getV = function(){ 
alert(this.$(this.TheA.box2).offsetWidth-this.$(this.TheA.box).scrollLeft);
alert(this.$(this.TheA.box2).offsetWidth);
alert(this.$(this.TheA.box).scrollLeft);}
PARoll.prototype.Marquee = function()
{
	this.MyMar=setTimeout(this.TheA.objname+".Marquee();",this.TheA.speed);
	if(this.TheA.IsPlay == 1)
	{
		if(this.TheA.direction == "top")
		{
			if(this.$(this.TheA.box).scrollTop>=this.$(this.TheA.box2).offsetHeight)
				this.$(this.TheA.box).scrollTop-=this.$(this.TheA.box2).offsetHeight;
			else{
				this.$(this.TheA.box).scrollTop++;
			}
		}
		
		if(this.TheA.direction == "down")
		{
			if(this.$(this.TheA.box1).offsetTop-this.$(this.TheA.box).scrollTop>=0)
				this.$(this.TheA.box).scrollTop+=this.$(this.TheA.box2).offsetHeight;
			else{
				this.$(this.TheA.box).scrollTop--;
			}
		}
		if(this.TheA.direction == "left")
		{
			if(this.$(this.TheA.box2).offsetWidth-this.$(this.TheA.box).scrollLeft<=0)
				this.$(this.TheA.box).scrollLeft-=this.$(this.TheA.box1).offsetWidth;
			else{
				this.$(this.TheA.box).scrollLeft++;
			}
		}
		
		if(this.TheA.direction == "right")
		{
			if(this.$(this.TheA.box).scrollLeft<=0)
				this.$(this.TheA.box).scrollLeft+=this.$(this.TheA.box2).offsetWidth;
			else{
				this.$(this.TheA.box).scrollLeft--;
			}
		}

	}
}
PARoll.prototype.clearIntervalRoll = function()
{
  this.TheA.IsPlay = 0;
}
PARoll.prototype.setTimeoutRoll = function()
{
   this.TheA.IsPlay = 1;
}





