//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 showMenu(MenuObj) 
//{
	//if (event.srcElement.tagName.toLowerCase()!='select')
	//{
	//	var rightedge=document.body.clientWidth-event.clientX;
	//	var bottomedge=document.body.clientHeight-event.clientY;
	//	if (rightedge<MenuObj.offsetWidth) MenuObj.style.posLeft = document.body.scrollLeft + event.clientX - MenuObj.offsetWidth;
	//	else MenuObj.style.posLeft = document.body.scrollLeft + event.clientX;
	//	if (bottomedge<MenuObj.offsetHeight) MenuObj.style.posTop = event.clientY+document.body.scrollTop-MenuObj.offsetHeight;
	//	else MenuObj.style.posTop = event.clientY+document.body.scrollTop;
	//	MenuObj.className = "menushow";
	//	MenuObj.setCapture();
//	}
//}


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(MenuObj) 
{
	for (var i=0;i<MenuObj.children.length-1;i++)
	{
		if (MenuObj.children(i).tagName.toLowerCase()!='hr')
		{
			//MenuObj.children(i).className='MouseRightItem';
			MenuObj.children(i).style.backgroundColor=""
		}
	}
	var rightedge=document.body.clientWidth-event.clientX;
	var bottomedge=document.body.clientHeight-event.clientY;
	if (rightedge<MenuObj.offsetWidth) MenuObj.style.posLeft = document.body.scrollLeft + event.clientX - MenuObj.offsetWidth;
	else MenuObj.style.posLeft = document.body.scrollLeft + event.clientX;
	if (bottomedge<MenuObj.offsetHeight) MenuObj.style.posTop = event.clientY+document.body.scrollTop-MenuObj.offsetHeight;
	else MenuObj.style.posTop = event.clientY+document.body.scrollTop;
	MenuObj.className = "menushow";
	MenuObj.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 OpenEditerWindow(Url,WindowName,Width,Height)
{
	window.open(Url,WindowName,'toolbar=0,location=0,maximize=1,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,top=50,left=50,width='+Width+',height='+Height);
}
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 OpenWindowAndSetValue(Url,Width,Height,WindowObj,SetObj)
{
	var ReturnStr=showModalDialog(Url,WindowObj,'dialogWidth:'+Width+'pt;dialogHeight:'+Height+'pt;status:no;help:no;scroll:no;');
	if (ReturnStr!='') SetObj.value=ReturnStr;
	return ReturnStr;
}

function Editsite(Editer1)
{
var TempArray,TempStr;
TempArray=Editer1.split("***");
if (TempArray[0] != '')
{
	if (document.NewsForm.EditerText.value.indexOf(TempArray[0])<0)
	{
		if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
		else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
		if (document.NewsForm.EditerText.value=='') 	document.NewsForm.EditerText.value=TempArray[0];
		else document.NewsForm.EditerText.value = document.NewsForm.EditerText.value + ',' + TempArray[0];
		if (document.NewsForm.Editer.value=='') 	document.NewsForm.Editer.value=TempArray[0];
		else document.NewsForm.Editer.value = document.NewsForm.Editer.value + ',' + TempArray[0];
	}
}
if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
{
	document.NewsForm.Editer.value = '';
	document.NewsForm.EditerText.value = '';
}
return;
}

function Doauthsite(Author)
{
var TempArray,TempStr;
TempArray=Author.split("***");
if (TempArray[0] != '')
{
	if (document.NewsForm.AuthorText.value.indexOf(TempArray[0])<0)
	{
		if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
		else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
		if (document.NewsForm.AuthorText.value=='') 	document.NewsForm.AuthorText.value=TempArray[0];
		else document.NewsForm.AuthorText.value = document.NewsForm.AuthorText.value + ',' + TempArray[0];
		if (document.NewsForm.Author.value=='') 	document.NewsForm.Author.value=TempArray[0];
		else document.NewsForm.Author.value = document.NewsForm.Author.value + ',' + TempArray[0];
	}
}
if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
{
	document.NewsForm.Author.value = '';
	document.NewsForm.AuthorText.value = '';
}
return;
}

function Dokesite(KeyWords)
{
if (KeyWords!='')
{
	if (document.NewsForm.KeywordText.value.search(KeyWords)==-1)
	{
		if (document.NewsForm.KeyWords.value=='') document.NewsForm.KeyWords.value=KeyWords;
		else document.NewsForm.KeyWords.value=document.NewsForm.KeyWords.value+','+KeyWords;
		if (document.NewsForm.KeywordText.value=='') document.NewsForm.KeywordText.value=KeyWords;
		else document.NewsForm.KeywordText.value=document.NewsForm.KeywordText.value+','+KeyWords;
	}
}
if (KeyWords == 'Clean')
{
	document.NewsForm.KeyWords.value = '';
	document.NewsForm.KeywordText.value = '';
}
return;
}

function Dosusite(Source)
{
var TempArray,TempStr;
TempArray=Source.split("***");
if (TempArray[0] != '')
{
	if (document.NewsForm.TxtSourceText.value.indexOf(TempArray[0])<0)
	{
		if (typeof(TempArray[1])=='undefined') TempStr=TempArray[0];
		else TempStr='<a href='+TempArray[1].replace(/[\"\']/,'')+'>'+TempArray[0]+'</a>';
		if (document.NewsForm.TxtSourceText.value=='') 	document.NewsForm.TxtSourceText.value=TempArray[0];
		else document.NewsForm.TxtSourceText.value = document.NewsForm.TxtSourceText.value + ',' + TempArray[0];
		if (document.NewsForm.TxtSource.value=='') 	document.NewsForm.TxtSource.value=TempArray[0];
		else document.NewsForm.TxtSource.value = document.NewsForm.TxtSource.value + ',' + TempArray[0];
	}
}
if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
{
	document.NewsForm.TxtSource.value = '';
	document.NewsForm.TxtSourceText.value = '';
}
return;
}

function ChooseSpecial(Special)
{
var TempArray,TempStr;
TempArray=Special.split("***");
if (TempArray[0] != '')
{
	if (document.NewsForm.SpecialID.value.search(TempArray[1])==-1)

       {		if (document.NewsForm.SpecialIDText.value=='') 	document.NewsForm.SpecialIDText.value=TempArray[0];
				else document.NewsForm.SpecialIDText.value = document.NewsForm.SpecialIDText.value + ',' + TempArray[0];
				if (document.NewsForm.SpecialID.value=='') 	document.NewsForm.SpecialID.value=TempArray[1];
				else document.NewsForm.SpecialID.value = document.NewsForm.SpecialID.value + ',' + TempArray[1];
		}
}
if ((TempArray[0] == '')&&(TempArray[1] == 'Clean'))
{
	document.NewsForm.SpecialID.value = '';
	document.NewsForm.SpecialIDText.value = '';
}
return;
}

function ChooseSystem(DownSystem)
{
if (DownSystem != '')
	{	
		if (document.DownForm.SystemType.value.search(DownSystem)==-1)
		{
			if (document.DownForm.SystemType.value=='') document.DownForm.SystemType.value=DownSystem;
			else document.DownForm.SystemType.value = document.DownForm.SystemType.value + '/' + DownSystem;
		}
	}
if (DownSystem == 'Clean') document.DownForm.SystemType.value = '';
return;
}
