//检查浏览器的版本
function getIEVersion(){
	var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
	if (navigator.userAgent.indexOf('Mac')        >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
	if (navigator.userAgent.indexOf('Opera')      >= 0) { win_ie_ver = 0; }
	return win_ie_ver;
}
function showTab(tabIndex,tabCount){
	var obj;
	for(var i=1;i<=tabCount;i++){
		if(i==tabIndex){
			eval("tab" + i + ".className=\"active\";");
			eval("panel" + i + ".style.display=\"\";");
		}else{
			eval("tab" + i + ".className=\"\";");
			eval("panel" + i + ".style.display=\"none\";");
		}
	}
}
//Check number or not and alarm user.
function CheckNumber(Obj,DescriptionStr)
{
	if (Obj.value!='' && (isNaN(Obj.value) || Obj.value<=0))
	{
		alert(DescriptionStr+"应填有效数字！");
		Obj.value="";
		Obj.focus();
	}
}
//Check English Str
function CheckEnglishStr(Obj,DescriptionStr)
{
	var TempStr=Obj.value,i=0,ErrorStr='',CharAscii;
	if (TempStr!='')
	{
		for (i=0;i<TempStr.length;i++)
		{
			CharAscii=TempStr.charCodeAt(i);
			if (CharAscii>=255||CharAscii<=31)
			{
				ErrorStr=ErrorStr+TempStr.charAt(i);
			}
			else
			{
				if (!CheckClassErrorStr(CharAscii))
				{
					ErrorStr=ErrorStr+TempStr.charAt(i);
				}
			}
		}
		if (ErrorStr!='')
		{
			alert(DescriptionStr+'发现非法字符:'+ErrorStr);
			Obj.focus();
			return false;
		}
		if (!(((TempStr.charCodeAt(0)>=48)&&(TempStr.charCodeAt(0)<=57))||((TempStr.charCodeAt(0)>=65)&&(TempStr.charCodeAt(0)<=90))||((TempStr.charCodeAt(0)>=97)&&(TempStr.charCodeAt(0)<=122))))
		{
			alert(DescriptionStr+'首字符只能够为数字或者字母');
			Obj.focus();
			return false;
		}
	}
	return true;
}
function CheckClassErrorStr(CharAsciiCode)
{
	var TempArray=new Array(34,47,92,42,58,60,62,63,124);
	for (var i=0;i<TempArray.length;i++)
	{
		if (CharAsciiCode==TempArray[i]) return false;
	}
	return true;
}
//Check int or not and alerm user.
function CheckInt(Obj,DescriptionStr)
{
	var Flag=false;
	if (!(Obj.value!='' && (isNaN(Obj.value) || Obj.value<=0)))
	{
		if (Obj.value%1==0) Flag=true;
	}
	if (Flag==false)
	{
		alert(DescriptionStr+"应填写整数！");
		Obj.value="";
		Obj.focus();
	}
}
//Check int or not and return true or false.
function CheckIntTF(Value)
{
	var Flag=false;
	if (!(Value!='' && (isNaN(Value) || Value<=0)))
	{
		if (Value%1==0) Flag=true;
	}
	return Flag;
}
//Check uncommon char and alerm user.
function CheckUnCommonChar(Obj)
{
	var TempStr=Obj.value,UnCommonStr='';
	var re=/[\,\'\"]/g;
	var Matchs=TempStr.match(re);
	if (Matchs!=null)
	{
		for (var i=0;i<Matchs.length;i++) UnCommonStr=UnCommonStr+Matchs[i]+' ';
		if (confirm('发现非法字符'+UnCommonStr+'，如果不删除可能超成系统运行错误！\n确定要删除非法字符吗？')==true) Obj.value=TempStr.replace(re,'');
	}
}

function CheckPercentTF(Value)
{
	var Flag=false;
	if (!(Value!='' && (isNaN(Value) || Value<=0)))
	{
		if (Value%1==0) Flag=true;
	}
	return Flag;
}

function MouseOverMenu() 
{   
	var el=event.srcElement;
	if (el.className.toLowerCase()=="menuitem")	el.className="highlightItem";
	else if (el.className.toLowerCase()=="highlightitem") el.className="menuItem";
	if (el.className.toLowerCase()=="menuitemdisable") 
	{
		if (el.style.backgroundColor=="highlight") el.style.backgroundColor="";
		else el.style.backgroundColor="highlight";
	}
}

function DisableMenu(MenuItemArray)
{
	for (var i=0;i<MenuItemArray.length;i++)
	if (MenuItemArray[i]!=null) MenuItemArray[i].className='MenuItemDisable';
}

function ActiveMenu(MenuItemArray)
{
	for (var i=0;i<MenuItemArray.length;i++)
	if (MenuItemArray[i]!=null)	MenuItemArray[i].className='MouseRightItem';
}

function ClickMenu(MenuObj)
{
	var el=event.srcElement;
	if (el.className.toLowerCase()!='menuitemdisable')
	{
		if (el.HaveChild==null)
		{
			//el.className='MouseRightItem';
			MenuObj.releaseCapture();
			MenuObj.className = "menu";
			for (var i=0;i<MenuObj.children.length;i++)
			{
				var CurrObj=MenuObj.children(i);
				if (CurrObj.className=='MouseRightHighlightItem') CurrObj.className='MouseRightItem';
				for (var j=0;j<CurrObj.children.length;j++)
				{
					if (CurrObj.children(j).className=='MenuShow') {CurrObj.children(j).className='Menu';}	
				}
			}
			if (el.ExeFunction != null) eval(el.ExeFunction);
		}
	}
}

function YCancelEvent() 
{
	event.returnValue=false;
	event.cancelBubble=true;
	return false;
}
//显示右健菜单
function showMenu(elMenu) 
{
	for (var i=0;i<elMenu.children.length-1;i++)
	{
		if (elMenu.children(i).tagName.toLowerCase()!='hr')
		{
			//elMenu.children(i).className='MouseRightItem';
			elMenu.children(i).style.backgroundColor=""
		}
	}
	var rightedge=document.body.clientWidth-event.clientX;
	var bottomedge=document.body.clientHeight-event.clientY;
	//右边距小于菜单宽度
	if (rightedge<elMenu.offsetWidth) 
		elMenu.style.posLeft = document.body.scrollLeft + event.clientX - elMenu.offsetWidth;
	else 
		elMenu.style.posLeft = document.body.scrollLeft + event.clientX;
	//底边距小于菜单高度
	if (bottomedge<elMenu.offsetHeight)
		elMenu.style.posTop = event.clientY+document.body.scrollTop-elMenu.offsetHeight;
	else 
		elMenu.style.posTop = event.clientY+document.body.scrollTop;
	elMenu.className = "menushow";
	elMenu.setCapture();
}

function MouseOverRightMenu() 
{   
	var el=event.srcElement;
	if (el.className.toLowerCase()=="menuitemdisable") 
	{
		for (var i=0;i<MouseRightMenu.children.length;i++)
		{
			if (MouseRightMenu.children(i).className=='MouseRightHighlightItem') MouseRightMenu.children(i).className='mouserightitem';
		}
		if (el.style.backgroundColor=="highlight") el.style.backgroundColor="";
		else el.style.backgroundColor="highlight";
		//alert(el.style.backgroundColor);
		//if (event.type=='mouseout') el.style.backgroundColor="";
	}
	else ShowMouseRightChildMenu(el);
}

function ShowMouseRightChildMenu(Obj)
{
	if (Obj.HaveChild!=null)
	{
		if (event.type=='mouseover')
		{
			for (var i=0;i<MouseRightMenu.children.length;i++)
			{
				if (MouseRightMenu.children(i).className=='MouseRightHighlightItem') MouseRightMenu.children(i).className='mouserightitem';
			}
			Obj.className="MouseRightHighlightItem";
			//alert(Obj.children(0).style.offsetWidth);
			//Obj.children(0).style.offsetTop=0;//+Obj.offsetTop;//MainMenu.style.posTop;//el.offsetHeight;
			//Obj.children(0).style.offsetLeft=0;//el.offsetWidth;
			Obj.children(0).className='MenuShow';
			//alert(el.parentElement.parentElement.offsetTop);
		}
		else
		{
			if (event.toElement.id.substr(0,5)=='Child')
			{
				Obj.className='MouseRightHighlightItem';
				Obj.children(0).className='MenuShow';
			}
			else
			{
				Obj.className='mouserightitem';
				Obj.children(0).className='Menu';
			}
		}
	}
	else
	{
		if (Obj.id.substr(0,5)!='Child')
		{
			for (var i=0;i<MouseRightMenu.children.length;i++)
			{
				var CurrObj=MouseRightMenu.children(i);
				for (var j=0;j<CurrObj.children.length;j++)
				{
					//alert(CurrObj.children(j).className.toLowerCase()=='childmenushow');
					//alert(Obj.id);
					if (CurrObj.children(j).className.toLowerCase()=='menushow') {CurrObj.children(j).className='Menu';}	
					//alert(MouseRightMenu.children.length);
				}
				if (CurrObj.className.toLowerCase()=='mouserighthighlightitem') CurrObj.className='mouserightitem';
				//if (document.body.all(i).className=='mouserighthighlightitem') 
				//if (document.body.all(i).style.backgroundColor=='highlight') document.body.all(i).style.backgroundColor='menu';
			}
		}
		if (Obj.className.toLowerCase()=="mouserightitem")
		{
			Obj.className="MouseRightHighlightItem";
		}
		else if (Obj.className.toLowerCase()=="mouserighthighlightitem") Obj.className="mouserightitem";
	}
}

function ChangeOperateWindow(Url)
{
    frames['OpreateWindow'].location=Url;
}

function OpenWindow(Url,Width,Height,WindowObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:no;');
	return ReturnStr;
}

function showDialog(url,width,height,sTitle) {
	try{
	 	var argu = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no;center:yes;";
		window.showModalDialog("../common/dlg_iframe.aspx?loadfile=" + url,sTitle,argu);
		window.location.reload();		
	}catch(exception){}
}
function showDialogO(url,width,height,sTitle) {//by snowalk 2005.1.19
	try{
	 	var argu = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no;center:yes;";
		window.showModalDialog("/common/dlg_iframe.aspx?loadfile=" + url,sTitle,argu);
	}catch(exception){}
	//showModalDialog创建一个显示指定 HTML 文档的模式对话框。
}
//用于在模式对话框中可以post数据。
function showDialogR(url,width,height,sTitle) {//by snowalk 2005.1.19
	try{
	 	var argu = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no;center:yes;";
		return window.showModalDialog("../common/dlg_iframe.aspx?loadfile=" +  url,sTitle,argu);
		//window.location.reload();
	}catch(exception){}
	//showModalDialog创建一个显示指定 HTML 文档的模式对话框。
}
function showDialogL(url,width,height,sTitle) {//调试用
	try{
	 	var argu = "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no;center:yes;";
		window.showModelessDialog("../common/dlg_iframe.aspx?loadfile=" + url,sTitle,argu);
		//window.location.reload();
	}catch(exception){}
	//showModalDialog创建一个显示指定 HTML 文档的模式对话框。
}
function showDialogD(url,width,height,sTitle) {//调试用
	try{
	 	var argu = "width=" + width + ",height=" + height + ",status=yes,toolbar=no,menubar=no,location=no";
		window.open("../common/dlg_iframe.aspx?loadfile=" + url,sTitle,argu);
		//window.location.reload();
	}catch(exception){}
	//showModalDialog创建一个显示指定 HTML 文档的模式对话框。
}
function showDialogE(url,width,height,sTitle) {//调试用
	var iL,iT;
	iL = (screen.width - width)/2;
	iT = (screen.height - height)/2;
	try{
	 	var argu = "width="+ width + ",height=" + height + ", left=" + iL +", top=" + iT + ", resizable=0, status=no,scrollbars=no,toolbar=no,menubar=no,location=no";
		window.open(url,sTitle,argu);
		//window.location.reload();
	}catch(exception){}
}
//打开对话框并返回值
function openDialog(url,width,height,sTitle)
{
	/*height += 20;*/
	var retVal=showModalDialog(url,sTitle,'dialogWidth:' + width + 'pt;dialogHeight:' + height + 'pt;status:no;help:no;scroll:no;');
	return retVal;
}

/**************************************************
//功能：打开对话框并返回值,同时可对eDes元素设置值
//用途：主要是用于通过文件选择器对文本框赋值
//作者：snowalk 2005.2 
**************************************************/
function openDialogAndSetValue(url,width,height,sTitle,eDes)
{
	//return;
	
	var retVal=showModalDialog(url,sTitle,'dialogWidth:' + width + 'pt;dialogHeight:' + height + 'pt;status:no;help:no;scroll:no;');
	if (retVal!='') eDes.value=retVal;
	return retVal;
}
/*************************************************
//功能：标签处理
//作者：snowalk 2005.2  
*************************************************/
function showTab(tabIndex,tabCount){
	var obj;
	for(var i=1;i<=tabCount;i++){
		if(i==tabIndex){
			eval("tab" + i + ".className=\"active\";");
			eval("panel" + i + ".style.display=\"\";");
		}else{
			eval("tab" + i + ".className=\"\";");
			eval("panel" + i + ".style.display=\"none\";");
		}
	}
}

//用在文件管理器中的树状菜单
function SendDataToServer(Url)
{
	//alert(Url);
	//return
	var HTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var ReturnValue=HTTP.open("POST", Url, false);
	HTTP.send("");
	return HTTP.responseText;
}
function Ajax(Url)
{
	//alert(Url);
	//return
	var HTTP = new ActiveXObject("Microsoft.XMLHTTP");
	var ReturnValue=HTTP.open("POST", Url, false);
	HTTP.send("");
	return HTTP.responseText;
}
