﻿//滚动
function marquee(i, direction)
{
	var obj = document.getElementById("marquee" + i);
	var obj1 = document.getElementById("marquee" + i + "_1");
	var obj2 = document.getElementById("marquee" + i + "_2");

	if (direction == "up")
	{
		if (obj2.offsetTop - obj.scrollTop <= 0)
		{
			obj.scrollTop -= (obj1.offsetHeight + 20);
		}
		else
		{
			var tmp = obj.scrollTop;
			obj.scrollTop++;
			if (obj.scrollTop == tmp)
			{
				obj.scrollTop = 1;
			}
		}
	}
	else
	{
		if (obj2.offsetWidth - obj.scrollLeft <= 0)
		{
			obj.scrollLeft -= obj1.offsetWidth;
		}
		else
		{
			obj.scrollLeft++;
		}
	}
}

function marqueeStart(i, direction)
{
	var obj = document.getElementById("marquee" + i);
	var obj1 = document.getElementById("marquee" + i + "_1");
	var obj2 = document.getElementById("marquee" + i + "_2");

	obj2.innerHTML = obj1.innerHTML;
	var marqueeVar = window.setInterval("marquee("+ i +", '"+ direction +"')", 20);
	obj.onmouseover = function(){window.clearInterval(marqueeVar);}
	obj.onmouseout = function(){marqueeVar = window.setInterval("marquee("+ i +", '"+ direction +"')", 20);}
}

//搜索相关
function searchCheck(form)
{
	if (form.search.value == "")
	{
		form.search.focus();
		return false;
	}

	return true;
}

function searchFocus(obj)
{
	if (obj.value == "请输入搜索关键字")
	{
		obj.value = "";
	}
	obj.style.color = "#000";
}


//登陆相关
function loginCheck(form)
{
	if (form.account.value == "")
	{
		form.account.focus();
		return false;
	}

	if (form.pass.value == "")
	{
		form.pass.focus();
		return false;
	}

	return true;
}


//留言相关
function messageCheck(form)
{
	if (form.name.value == "")
	{
		alert("请输入您的姓名。");
		form.name.focus();
		return false;
	}

	if (form.content.value == "")
	{
		alert("请输入留言内容。");
		form.content.focus();
		return false;
	}

	return true;
}


//设为首页
function setHomePage()
{
	if(document.all)
	{
		var obj = document.links(0);
		if (obj)
		{
			obj.style.behavior = 'url(#default#homepage)';
			obj.setHomePage(window.location.href);
		}
  	}
	else
	{
		if(window.netscape)
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e)
			{
				window.alert("此操作被浏览器拒绝，请通过浏览器菜单完成此操作！");
			}
		}
   	}
}

//加入收藏
function addFavorite()
{
	var url		= document.location.href;
	var title	= document.title;
	if (document.all)
	{
		window.external.addFavorite(url,title);
	}
	else if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	}
}


//预定义动画有关
function bannerShow(mode, flashWidth, flashHeight, title, url, image)
{
	var flashVars;

	if (title != '')
		title = title.substr(0, title.length - 1);
	if (url != '')
		url = url.substr(0, url.length - 1);
	if (image != '')
		image = image.substr(0, image.length - 1);

	bgcolor = "#FFFFFF";

	if (mode == 11)
	{
		var imageWidth		= flashWidth * 0.545;   //图片宽度 注:图片宽度取决Flash宽度，适量调整。990 -> 540
		var imageHeight		= flashHeight * 0.89;  //图片高度 注:图片高度取决Flash高度，适量调整。360 -> 320
		var imagebgcolor	= "0xBBBBBB";	//图片边框
		var timeOut			= 3000;  //图片播放速度
		var playMode		= 1;  //播放模式，"0"停止自动播放,"1"向左播放,"2"向右播放
		var titleVisible	= 1;  //标题是否显示，"0"不显示，"1"显示

		flashVars = "&flashWidth=" + flashWidth + "&flashHeight=" + flashHeight + "&image=" + image + "&title=" + title + "&url=" + url + "&imageWidth=" + imageWidth + "&imageHeight=" + imageHeight + "&imagebgcolor=" + imagebgcolor + "&timeOut=" + timeOut + "&playMode=" + playMode + "&titleVisible=" + titleVisible;
	}
	else if (mode == 12)
	{
		var timeOut		= 4000;  //图片播放速度
		var playMode	= 1;  //播放模式，"0"停止播放，"1"向左播放，"2"向右播放

		flashVars = "&flashWidth=" + flashWidth + "&flashHeight=" + flashHeight + "&image=" + image + "&title=" + title + "&url=" + url + "&timeOut=" + timeOut + "&playMode=" + playMode;
	}
	else if (mode == 13 || mode == 14)
	{
		var timeOut		= 5000;  //图片播放速度
		var playMode	= 1;	//播放模式,"0"手动，"1"自动
		var txtColor	= "0xFFFFFF";	//标题颜色
		var txtColor2	= "0xFF0000";	//鼠标触碰标题颜色
		var titleY		= -50;	//标题Y轴
		var btnVisible	= 1;	//按钮可见，"0"不可见，"1"可见
		var btnColor	= "0xFF6600";	//按钮触碰或点击颜色
		var btnWidth	= 15;	//按钮宽
		var btnHeight	= 15;	//按钮高
		var btnInterval	= 2;	//按钮间隔
		var btnX		= 1;	//按钮X轴
		var btnY		= 5;	//按钮Y轴

		flashVars = "&flashWidth=" + flashWidth + "&flashHeight=" + flashHeight + "&image=" + image + "&title=" + title + "&url=" + url + "&timeOut=" + timeOut + "&playMode=" + playMode + "&txtColor=" + txtColor + "&txtColor2=" + txtColor2 + "&titleY=" + titleY + "&btnVisible=" + btnVisible + "&btnColor=" + btnColor + "&btnWidth=" + btnWidth + "&btnHeight=" + btnHeight + "&btnInterval=" + btnInterval + "&btnX=" + btnX + "&btnY=" + btnY;
	}
	else
	{
		return;
	}

	document.write('<div style="width:' + flashWidth + 'px; margin:0 auto;">');
	document.write('<object id="banner" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' + flashWidth + '" height="' + flashHeight + '" align="left" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="FlashVars" value="flashVars=' + flashVars + '" /> <param name="movie" value="banner/banner' + mode + '.swf" /> <param name="quality" value="high" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="scale" value="noscale" /> <param name="wmode" value="Opaque" /> <param name="devicefont" value="false" /> <param name="bgcolor" value="' + bgcolor + '" /> <param name="menu" value="true" /> <param name="allowFullScreen" value="false" /> <param name="allowScriptAccess" value="sameDomain" /> <param name="salign" value="lt" /> <embed name="banner" FlashVars="flashVars=' + flashVars + '" width="' + flashWidth + '" height="' + flashHeight + '" src="banner/banner' + mode + '.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" align="left" play="true" loop="true" scale="noscale" wmode="Opaque" devicefont="false" bgcolor="' + bgcolor + '" menu="true" allowFullScreen="false" allowScriptAccess="sameDomain" salign="lt" type="application/x-shockwave-flash" > </embed> </object>');
	document.write('</div>');
}

function srcMarquee(){
this.ID = document.getElementById(arguments[0]);
if(!this.ID){this.ID = -1;return;}
this.Direction = this.Width = this.Height = this.DelayTime = this.WaitTime = this.Correct = this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
this.Step = 1;
this.Timer = 30;
this.DirectionArray = {"top":0 , "bottom":1 , "left":2 , "right":3};
if(typeof arguments[1] == "number")this.Direction = arguments[1];
if(typeof arguments[2] == "number")this.Step = arguments[2];
if(typeof arguments[3] == "number")this.Width = arguments[3];
if(typeof arguments[4] == "number")this.Height = arguments[4];
if(typeof arguments[5] == "number")this.Timer = arguments[5];
if(typeof arguments[6] == "number")this.DelayTime = arguments[6];
if(typeof arguments[7] == "number")this.WaitTime = arguments[7];
if(typeof arguments[8] == "number")this.ScrollStep = arguments[8]
this.ID.style.overflow = this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
this.ID.noWrap = true;
this.IsNotOpera = (navigator.userAgent.toLowerCase().indexOf("opera") == -1);
if(arguments.length >= 7)this.Start();
}
srcMarquee.prototype.Start = function(){
if(this.ID == -1)return;
if(this.WaitTime < 1000)this.WaitTime = 1000;
if(this.Timer < 20)this.Timer = 20;
if(this.Width == 0)this.Width = parseInt(this.ID.style.width);
if(this.Height == 0)this.Height = parseInt(this.ID.style.height);
if(typeof this.Direction == "string")this.Direction = this.DirectionArray[this.Direction.toString().toLowerCase()];
this.HalfWidth = Math.round(this.Width / 2);
this.BakStep = this.Step;
this.ID.style.width = this.Width;
this.ID.style.height = this.Height;
if(typeof this.ScrollStep != "number")this.ScrollStep = this.Direction > 1 ? this.Width : this.Height;
var msobj = this;
var timer = this.Timer;
var delaytime = this.DelayTime;
var waittime = this.WaitTime;
msobj.StartID = function(){msobj.Scroll()}
msobj.Continue = function(){
if(msobj.MouseOver == 1){
setTimeout(msobj.Continue,delaytime);
     }
     else{ clearInterval(msobj.TimerID);
msobj.CTL = msobj.Stop = 0;
msobj.TimerID = setInterval(msobj.StartID,timer);
     }
    }
msobj.Pause = function(){
msobj.Stop = 1;
clearInterval(msobj.TimerID);
setTimeout(msobj.Continue,delaytime);
    }
msobj.Begin = function(){
   msobj.ClientScroll = msobj.Direction > 1 ? msobj.ID.scrollWidth : msobj.ID.scrollHeight;
   if((msobj.Direction <= 1 && msobj.ClientScroll <msobj.Height) || (msobj.Direction > 1 && msobj.ClientScroll <msobj.Width))return;
   msobj.ID.innerHTML += msobj.ID.innerHTML;
   msobj.TimerID = setInterval(msobj.StartID,timer);
   if(msobj.ScrollStep < 0)return;
   msobj.ID.onmousemove = function(event){
       if(msobj.ScrollStep == 0 && msobj.Direction > 1){
var event = event || window.event;
if(window.event){
if(msobj.IsNotOpera){msobj.EventLeft = event.srcElement.id == msobj.ID.id ? event.offsetX - msobj.ID.scrollLeft : event.srcElement.offsetLeft - msobj.ID.scrollLeft + event.offsetX;}
else{msobj.ScrollStep = null;return;}
}
else{msobj.EventLeft = event.layerX - msobj.ID.scrollLeft;}
msobj.Direction = msobj.EventLeft > msobj.HalfWidth ? 3 : 2;
msobj.AbsCenter = Math.abs(msobj.HalfWidth - msobj.EventLeft);
msobj.Step = Math.round(msobj.AbsCenter * (msobj.BakStep*2) / msobj.HalfWidth);
}
}
msobj.ID.onmouseover = function(){
if(msobj.ScrollStep == 0)return;
msobj.MouseOver = 1;
clearInterval(msobj.TimerID);
}
msobj.ID.onmouseout = function(){
if(msobj.ScrollStep == 0){
if(msobj.Step == 0)msobj.Step = 1;
return;
}
msobj.MouseOver = 0;
if(msobj.Stop == 0){
clearInterval(msobj.TimerID);
msobj.TimerID = setInterval(msobj.StartID,timer);
}}}
setTimeout(msobj.Begin,waittime);
}
srcMarquee.prototype.Scroll = function(){
switch(this.Direction){
case 0:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop >= this.ClientScroll){this.ID.scrollTop -= this.ClientScroll;}
this.ID.scrollTop += this.Step;
}
break;
case 1:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollTop <= 0){this.ID.scrollTop += this.ClientScroll;}
this.ID.scrollTop -= this.Step;
}
break;
case 2:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft >= this.ClientScroll){this.ID.scrollLeft -= this.ClientScroll;}
this.ID.scrollLeft += this.Step;
}
break;
case 3:
this.CTL += this.Step;
if(this.CTL >= this.ScrollStep && this.DelayTime > 0){
this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL;
this.Pause();
return;
}
else{
if(this.ID.scrollLeft <= 0){this.ID.scrollLeft += this.ClientScroll;}
this.ID.scrollLeft -= this.Step;
}
break;
}
} 
