////常用函数////
function $G(id){
	return document.getElementById(id);
}

//检测浏览器类型
function is_IE(){return navigator.userAgent.indexOf("MSIE")>0;}
function is_FF(){return navigator.userAgent.indexOf("Firefox")>0;}

//---------------------------------------------------
//	打开新窗口
//---------------------------------------------------
function PopWindow(pageUrl,WinWidth,WinHeight) {
	var popwin=window.open(pageUrl,"_blank","scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,width="+WinWidth+",height="+WinHeight);
	return false;
}

//+---------------------------------------------------
//|	打开模式窗口，返回新窗口的操作值
//+---------------------------------------------------
function PopModalWindow(url,width,height){
	var result=window.showModalDialog(url,"win","dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:auto;dialogHide:no;resizable:no;help:no;edge:sunken;");
	return result;
}

//获取文档层次中指定的父对象
function GetParentNode(obj, tag){
	while(obj.parentNode && obj.tagName.toLowerCase() != tag){
		obj	= obj.parentNode;
	}
	return obj;
}

//全选
function CheckAll(strSection){
	var	colInputs = document.getElementById(strSection).getElementsByTagName("input");
	for	(var i=1; i < colInputs.length; i++){
		colInputs[i].checked=colInputs[0].checked;
	}
}
//反向选中指定的选择框对象
function reverseCheck(strSection){
	var	colInputs = document.getElementById(strSection).getElementsByTagName("input");
	for	(var i=1; i < colInputs.length; i++){
		colInputs[i].checked = !colInputs[i].checked;
	}
}
//获取选中的选择框对象值组成字符串
function getSelectCheckboxValues(){
	var obj = document.getElementsByName('ids');
	var result ='';
	for (var i=0; i<obj.length; i++){
		if (obj[i].checked==true){
			result += "," + obj[i].value;
		}
	}
	return result.substring(1);
}

//获取文件扩展名
function getFileExt(filename){
	var dot	= filename.lastIndexOf(".");
	if (dot >= 0){
		return filename.substr(dot + 1).toLowerCase();
	}else{
		return "";
	}
}

//检查数组中是否存在指定的值
function in_array(value, array){
	if (typeof(value) != "string" && typeof(value) != "number"){
		return false;
	}
	if (array.constructor != Array){
		return false;
	}
	for(var i in array){
		if (array[i] == value){
			return true;
		}
	}
	return false;
}

//滑动门
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, 1));
	for (i=0; i<n; i++){
		$G(tabName + "_div_" + i).style.display = "none";
		$G(tabName + "_btn_" + i).className = '';
	};
	$G(tabName+"_div_"+id).style.display = "block";
	btn.className = "cur";
}

//滚动
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(is_IE()){
		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("此操作被浏览器拒绝！");
			}
		}
   	}
}

//加入收藏
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 copyToClipboard(txt) {
	if(window.clipboardData) {
		window.clipboardData.clearData();
		window.clipboardData.setData("Text", txt);
	} else if(navigator.userAgent.indexOf("Opera") != -1) {
		window.location = txt;
	} else if (window.netscape) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		} catch (e) {
			alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
		}
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip)
			return;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans)
			return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext = txt;
		str.data = copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid = Components.interfaces.nsIClipboard;
		if (!clip)
			return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	//alert("复制成功！");
}

//导航菜单
var navCurrentId = "";

function showMenu(id)
{
	var objMenu = document.getElementById("menu" + id);
	objMenu.style.visibility = "visible";
	/*
	var objMenuA = document.getElementById("menuA" + id);
	if (objMenuA.className == "navCurrent")
	{
		navCurrentId = objMenuA.uniqueID;
		if (!navCurrentId)
		{
			navCurrentId = objMenuA.clientID;
		}
	}
	else
	{
		objMenuA.className = "navCurrent";
	}*/
}

function hiddMenu(id)
{
	var objMenu = document.getElementById("menu" + id);
	objMenu.style.visibility = "hidden";
	/*
	var objMenuA = document.getElementById("menuA" + id);
	if (objMenuA.uniqueID != navCurrentId)
	{
		objMenuA.className = "nav";
	}*/
}


//预定义动画有关
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		= 680;   //图片宽度 注:图片宽度取决Flash宽度，适量调整。990 -> 540
		var imageHeight		= 345;  //图片高度 注:图片高度取决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/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/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>');
}

//document.title = "网站建设 - 合肥点金软件科技有限公司";
