///-----------------------
// 新对联
// 2008.02.25 ----- slamz
///-----------------------
/// 实现对对联的左右分别控制,可替换掉scrolllogo.js和scrolllogo2007.js
///

	var isCloseAll = 0;//如果设置成1，则单击任何关闭按钮都会关闭所有对联，否则只关闭对应的部分


	//左边设置
	var isShowLeft = 0; //是否显示左边
	var src1 = "http://www.cabling-system.com/images/2009/11/sunsea.swf"; //图片位置
	var url1 = ""; //连接
	var width1 = 100; //宽度
	var height1 = 250; //高度
	var border1 = 1; //图片边框
	var isFlash1 = 1; //如果是flash请设置成1,否则设置成0
	var showClose1 =1; //如果设置为1则显示关闭按钮
	var x1 = null; //指定x坐标,设置成null则帖左边
	var y1 = null; //指定y坐标,设置成null则默认取中间值,指定坐标后不会滚动
	//var lock1 = 0; //0则会滚动,1则不滚动
	
	
	//右边设置
	var isShowRight = 1; //是否显示右边
	var src2 = "http://www.cabling-system.com/images/2009/10/091026.swf"; //图片位置
	var url2 = ""; //连接
	var width2 = 100; //宽度
	var height2 = 250; //高度
	var border2 = 1; //图片边框
	var isFlash2 = 1; //如果是flash请设置成1,否则设置成0
	var showClose2 = 1; //如果设置为1则显示关闭按钮
	var x2 = null; //指定x坐标,设置成null则帖右边
	var y2 = null; //指定y坐标,设置成null则默认取中间值,指定坐标后不会滚动
	//var lock2 = 0; //0则会滚动,1则不滚动

function FloatEngine(M_VN,M_MC,M_MC2)
{
	
	
	//var side = "left"; //居左,要居右则填写right
	
	
	var thisName=M_VN;
	var M_MC=M_MC;
	var M_MC2=M_MC2;
	this.menu_width=0;
	this.menu_height=0;
	this.menu=null;
	this.button=null;
	this.button2=null;
	var mTable;
	var mDiv;
	var mTable2;
	var mDiv2;
	
	

	
	this.M_PE=function M_PE(){ //建立显示用的图层
		var btClose="";
		if(showClose1==1)btClose = "<b>关闭</b>";
		var pageW=0;
		if(x1!=null)pageW=x1;
		var htm="<div style=\"POSITION:absolute;z-index:4; left:"+pageW+"; top:0;  height:"+height1+"px; width:"+width1+"px; visibility:"+(isShowLeft==1?"visible":"hidden")+"\" id=\"sl1_divid\"> ";
		htm+="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  id=\"sl1_tableid\" > ";
		htm+="<tr>";
		htm+="<td width=\"100%\"  align=\"right\" valign=\"bottom\" ><span id=\"sl1_menu\" >"+M_MC+"</span></td>";
		htm+="</tr>";
		htm+="<tr>";
		htm+="<td align=\"right\" valign=\"top\" height=20><span id=\"sl1_button\" style=\"font-size:12px; color:red;cursor:hand;\" >"+btClose+"</span></td>";
		htm+="</tr>";
		htm+="</table>";
		htm+="</div>";
		document.write(htm);
	};
	
	this.M_PE2=function M_PE2(){ //建立显示用的图层
		var btClose="";
		if(showClose2==1)btClose = "<b>关闭</b>";
		var pageW=window.document.body.offsetWidth-width2-22-border2;
		if(x2!=null)pageW=x2;
		var htm="<div style=\"POSITION:absolute;z-index:4; left:"+pageW+"; top:0;  height:"+height2+"px; width:"+width2+"px; visibility:"+(isShowRight==1?"visible":"hidden")+"\" id=\"sl2_divid\"> ";
		htm+="<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"  id=\"sl2_tableid\" > ";
		htm+="<tr>";
		htm+="<td width=\"100%\"  align=\"right\" valign=\"bottom\" ><span id=\"sl2_menu\">"+M_MC2+"</span></td>";
		htm+="</tr>";
		htm+="<tr>";
		htm+="<td align=\"right\" valign=\"top\" height=20><span id=\"sl2_button\" style=\"font-size:12px; color:red;cursor:hand;\" >"+btClose+"</span></td>";
		htm+="</tr>";
		htm+="</table>";
		htm+="</div>";
		document.write(htm);
	};
	
	this.M_IV=function M_IV(){ //获取宽高和将变量指向对象
		mTable=document.all("sl1_tableid"); //将变量指向括号内的对象
		mDiv=document.all("sl1_divid"); //将变量指向括号内的对象
		mTable2=document.all("sl2_tableid"); //将变量指向括号内的对象
		mDiv2=document.all("sl2_divid"); //将变量指向括号内的对象
		this.menu=(isShowLeft==1)?document.all("sl1_menu"):document.all("sl2_menu"); //将变量指向括号内的对象
		this.button=document.all("sl1_button"); //将变量指向括号内的对象
		this.button2=document.all("sl2_button"); //将变量指向括号内的对象
		this.menu_width=this.menu.scrollWidth; //获取宽度
		this.menu_height=this.menu.scrollHeight+this.button.scrollHeight; //获取高度(菜单高度+按钮高度)
	};
	

	this.Close1=function Close1(){ //关闭显示
		mDiv.style.display = "none";
		if(isCloseAll==1&&isShowRight==1)mDiv2.style.display = "none";;
	};
	
	this.Close2=function Close2(){ //关闭显示
		mDiv2.style.display = "none";
		if(isCloseAll==1&&isShowLeft==1)mDiv.style.display = "none";;
	};
	
	this.M_MT=function M_MT(left,top){ //调整位置 Movie : Move To
		//mTable.width=left+this.menu_width-mDiv.style.pixelLeft;
		//mTable.height=top+this.menu_height-mDiv.style.pixelTop;
		
		if(isShowLeft==1)
		{
			mDiv.style.pixelTop=top;
			mDiv.style.pixelLeft=(x1==null)?0:x1;
		}
		
		if(isShowRight==1)
		{
			mDiv2.style.pixelTop=top;
			mDiv2.style.pixelLeft=(x2==null)?window.document.body.offsetWidth-width2-22-border2:x2;	
		}
	};
	
	this.M_GL=function M_GL(){ //Get_Left
		return (isShowLeft==1?(mDiv.style.pixelLeft+parseInt(mTable.width)-this.menu_width):(mDiv2.style.pixelLeft+parseInt(mTable2.width)-this.menu_width));
	};
	
	this.M_GT=function M_GT(){ //Get_Top
		return (isShowLeft==1?mDiv.style.pixelTop:mDiv2.style.pixelTop);//+this.menu_height;
	};
}


//建立图层菜单内容
var htm = "";

if(isFlash1==0){
	htm+="<table id=\"sl1_Table_01\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" ><tr>";
	htm+="<td><a href=\""+url1+"\">";
	htm+="<img src=\""+src1+"\" width=\""+width1+"\" height=\""+height1+"\" style='border:"+border1+"px'></a>";
	htm+="</td></tr></table>";	
}


if(isFlash1==1){
	htm+='<object id="nowads_img" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width1+'" height="'+height1+'">';
	htm+='<param name="movie" value="'+src1+'">';
	htm+='<param name="quality" value="high">';
	htm+='<embed src="'+src1+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width1+'" height="'+height1+'"></embed>';
	htm+='</object>';
}



var htm2 = "";
if(isFlash2==0){
	htm2+="<table id=\"sl2_Table_02\" width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" ><tr>";
	htm2+="<td><a href=\""+url2+"\">";
	htm2+="<img src=\""+src2+"\" width=\""+width2+"\" height=\""+height2+"\" border=\""+border2+"\"></a>";
	htm2+="</td></tr></table>";	
}
	
if(isFlash2==1){
	htm2+='<object id="nowads_img" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+width2+'" height="'+height2+'">';
	htm2+='<param name="movie" value="'+src2+'">';
	htm2+='<param name="quality" value="high">';
	htm2+='<embed src="'+src2+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width2+'" height="'+height2+'"></embed>';
	htm2+='</object>';
}


var v_ft,v_fs,v_rb,v_lb,v_fp=53;
var v_temp = 0;
var aaa=new FloatEngine("aaa",htm,htm2);

if(F_CB()=="IE55up"){ //如果IE版本高于等于5.5
	aaa.M_PE(); //建立图层
	aaa.M_PE2(); //建立图层
	window.attachEvent("onload",F_OBL);
}

function F_OBL(){ //Function : On Body Load 
	aaa.M_IV(); //获取高和宽
	aaa.menu.onmouseover=F_PS; //Stop
	aaa.menu.onmouseout=F_DS; //Start
	

	aaa.button.onclick=F_OBC1; //On Button Click
	aaa.button2.onclick=F_OBC2; //On Button Click
	v_fs=aaa.menu_width/10;
	//v_fs=aaa.menu_width;
	v_rb=-3;
	v_lb=-1*aaa.menu_width+v_fp;
	aaa.M_MT(v_lb,100);
	F_MI();

}

function F_CB(){ //获取IE版本信息
	if(navigator.appName=="Microsoft Internet Explorer"){
		verStr=navigator.appVersion;msie=verStr.indexOf("MSIE");
		ver=verStr.substring(msie+5,msie+8);
		if(ver>=5.5){
			return "IE55up";
		}
		else{
			return "IE55down";
		}
	}
	else
	{
		return "other";
	}
}

function F_OBC1(e){  // On Button Click 
	aaa.Close1();
	return;
}

function F_OBC2(e){  // On Button Click 
	aaa.Close2();
	return;
}

function F_PS(e){ //Pullengine(计时器) Start
	clearTimeout(v_ft);
	v_ft=setTimeout("pullengine();",50);
}

function F_DS(e){ //Drawengine(计时器) Start
	if(event.clientX<3)return;
	clearTimeout(v_ft);
	v_ft=setTimeout("drawengine();",50);
}

function pullengine(){
	if(v_rb-aaa.M_GL()>v_fs){
		aaa.M_MT(aaa.M_GL()+v_fs,aaa.M_GT());
		v_ft=setTimeout("pullengine();",50); 
	}
	else
	{
		aaa.M_MT(v_rb,aaa.M_GT());
		clearTimeout(v_ft);
	}
}


function drawengine(){
	if(aaa.M_GL()-v_lb>v_fs){
		aaa.M_MT(aaa.M_GL()-v_fs,aaa.M_GT());
		v_ft=setTimeout("drawengine();",50);
	}
	else
	{
		aaa.M_MT(v_lb,aaa.M_GT());
		clearTimeout(v_ft);
	}
}

var v_tm,v_mt,v_pt;


function F_GD(value){
	return (value<0?Math.floor(value):Math.ceil(value));
	//floor: 取整而非4舍5入
	//ceil: 取整4舍5入
}


function menuDivMoving(){ //移动图层
	v_temp = (aaa.M_GT() - v_tm)/4;
	if((v_temp>1)||v_temp<-1){
			aaa.M_MT(aaa.M_GL(),aaa.M_GT()-v_temp);
	}
	else
	{
		clearInterval(v_mt);
		v_mt=-1;
	}
}

function F_ST(){
	v_tm=scrollTop();
	v_tm+=v_pt;
	if(aaa.M_GT()!=v_tm&&v_mt==-1)v_mt=setInterval("menuDivMoving()",10);
}


function F_MI(){ //Move In
	v_pt=(pageHeight()-aaa.menu_height)/2;
	v_tm=0;
	v_mt=-1;
	document.body.onscroll=F_ST; //绑定事件函数
	F_ST();
}

// JavaScript Document
// by Slamz 2007.8
function pageWidth()
{
    return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
}

function pageHeight()
{
    return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
}

function scrollLeft()
{
    return window.pageXOffset != null? window.pageXOffset: document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft:document.body != null? document.body.scrollLeft:null;
}

function scrollTop()
{
    return window.pageYOffset != null? window.pageYOffset: document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body != null? document.body.scrollTop:null;
}