//////////////////////////////////////////////////////常用JS代码//////////////////////////////////////////////////////
function $(obj)
{
	return document.getElementById(obj);
}

//滚动
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 disabledRightButton()
{
	document.oncontextmenu = function(e){return false;}
	document.onselectstart = function(e){return false;}
	if (navigator.userAgent.indexOf("Firefox") > -1)
	{
		document.writeln("<style>body {-moz-user-select: none;}</style>");
	}
}

//设为首页
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)
			{
				alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'");
			}
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage', window.location.href);
   	}
}

//加入收藏
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);

	if (mode == 1)
	{
		var imageWidth		= 540;   //图片宽度 注:图片宽度取决Flash宽度，适量调整。990 -> 540
		var imageHeight		= 320;  //图片高度 注:图片高度取决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 == 2)
	{
		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 == 3)
	{
		var timeOut		= 5000;  //图片播放速度
		var playMode	= 1;	//播放模式,"0"手动，"1"自动
		var txtColor	= "0xFFFFFF";	//标题颜色
		var txtColor2	= "0xFF0000";	//鼠标触碰标题颜色
		var titleY		= 5;	//标题Y轴
		var btnVisible	= 1;	//按钮可见，"0"不可见，"1"可见
		var btnColor	= "0xFF6600";	//按钮触碰或点击颜色
		var btnWidth	= 20;	//按钮宽
		var btnHeight	= 20;	//按钮高
		var btnInterval	= 5;	//按钮间隔
		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('<object id="bannerShow" 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' + 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="transparent" /> <param name="devicefont" value="false" /> <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' + mode + '.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" align="left" play="true" loop="true" scale="noscale" wmode="transparent" devicefont="false" menu="true" allowFullScreen="false" allowScriptAccess="sameDomain" salign="lt" type="application/x-shockwave-flash" > </embed> </object>');
}

//////////////////////////////////////////////////////访问统计相关//////////////////////////////////////////////////////
function GetXMLRequester()
{
	var xmlHttpRequest = false;
	try
	{
		if(window.ActiveXObject)
		{
			for(var i = 5; i; i--)
			{
				try
				{
					if( i == 2 )
					{
						xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
					}
					else
					{
						xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP." + i + ".0" );
						xmlHttpRequest.setRequestHeader("Content-Type","text/xml");
						xmlHttpRequest.setRequestHeader("Content-Type","gb2312");
					}
					break;
				}
				catch(e)
				{
					xmlHttpRequest = false;
				}
			}
		}
		else if(window.XMLHttpRequest)
		{
			xmlHttpRequest = new XMLHttpRequest();
			if (xmlHttpRequest.overrideMimeType)
			{
				xmlHttpRequest.overrideMimeType('text/xml');
			}
		}
	}
	catch(e)
	{
		xmlHttpRequest = false;
	}

	return xmlHttpRequest;
}

function Counter(refer, ip)
{
	var	url = "counter.asp?refer=" + refer + "&ip=" + ip;
	var xmlHttpRequest = GetXMLRequester();
	xmlHttpRequest.open('GET', url, true);
	xmlHttpRequest.send(null);
}

//滑动门
function tabit(btn, n){
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_") + 1;
	var tabName = idname.substr(0, s);
	var id = parseInt(idname.substr(e));
	for (i=0; i<n; i++){
		document.getElementById(tabName + "_div_" + i).style.display = "none";
		document.getElementById(tabName + "_btn_" + i).className = '';
	};
	document.getElementById(tabName+"_div_"+id).style.display = "block";
	btn.className = "postion";
};
