function PreloadImages(){
var ImgArr=new Array();
for (i=0;i>PreloadImages.arguments.length;i++){
ImgArr[i]=new Image()
ImgArr[i].src=PreloadImages.arguments[i]
}


}

function onload_reloadme () {
  if (document.reloadme_form.reloadme_field.value == "reloadme" ) {
    self.location.reload(true)
  } else {
    document.reloadme_form.reloadme_field.value = "reloadme";
  }

}

function DisplayHelp(ID,ImagePath,Lang){
if (Lang){
	if (Lang=='')
		Lang='EN';
	window.open(ImagePath+"webhelp/"+Lang+"/Help_Desk.htm?ID="+ID,"DNAHelp","toolbar=0,location=0,status=0,menubar=0,width=800,height=600,scrollbars=0,resizable=1");
}
else
	{
	window.open(ImagePath+"webhelp/EN/Help_Desk.htm?ID="+ID,"DNAHelp","toolbar=0,location=0,status=0,menubar=0,width=800,height=600,scrollbars=0,resizable=1");
	}

}


function displaysave(){
if (document.getElementById){
if (document.getElementById("MainPage") && document.getElementById("SaveImg"))
{
document.getElementById("MainPage").style.display="none"
document.getElementById("SaveImg").style.display="inline"


}
}


}


function NumbericTime(evnt) {
if (document.all){
keyCode=evnt.keyCode
}
else
{
keyCode=evnt.which
}
if (keyCode>31){
	if(keyCode<48 || keyCode>58)
	{

	return false;
	}
}
return true;
}

function Numberic(evnt) {
if (document.all){
keyCode=evnt.keyCode
}
else
{
keyCode=evnt.which
}
if (keyCode>31){
	if(keyCode<48 ||keyCode>57)
	{

	return false;
	}
}
return true;
}

function NumbericIP(evnt) {
if (document.all){
	keyCode=evnt.keyCode
	}
else
	{
	keyCode=evnt.which
	}
	
if (keyCode>31){
	if(keyCode<48 ||keyCode>58)
	{
	if(keyCode==46)
		return true;
	return false;
	}
}
return true;
}

function ValidateEmail(EmailAddress) {
	if (EmailAddress.toLowerCase()=="admin")
		return true
		
	EmailParts=EmailAddress.split("@")
	if (EmailParts.length!=2)
		return false;
		
	//check the MailboxName

var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,4})(\]?)$/; // valid
  if (!reg1.test(EmailAddress) && reg2.test(EmailAddress)) { // if syntax is valid

    if(EmailAddress.length == (EmailAddress.indexOf("@")+1) ) {
       return false;
       }

    if(EmailAddress.length == 0) { 
      return false; 
      }     
     }
     else
     {
		return false;
     }
     return true;
  }



function SelFill(SelObj,aValues,aText){
var x
SelObj.disabled=false
for (i=0;i<aValues.length;i++){
	x=new Option(aText[i],aValues[i]);
	SelObj.options[SelObj.options.length]=x;
	}
}

function ClearSel(SelObj){
var x=SelObj.options.length;
for (i=0;i<x;i++){
	SelObj.options[0]=null;
	}
}

function DisplayMenu(){
var imagepath="";
if (arguments[0] != null){
		imagepath=arguments[0];

		}
if (document.getElementById){
if (document.getElementById("MenuDiv").style.display=="none"){
document.getElementById("MenuDiv").style.display="block"
document.getElementById("MenuDivImg").src=imagepath+'images/menuup.gif'
document.getElementById("menutd").bgcolor="#8cbdef"
if (window.parent.frames){
window.parent.frames[0].menuVisiable=true;
}
}
else
{
document.getElementById("MenuDiv").style.display="none"
document.getElementById("MenuDivImg").src=imagepath+'images/menudown.gif'
document.getElementById("menutd").bgcolor="#c0c0c0"
if (window.parent.frames){
window.parent.frames[0].menuVisiable=false;
}
}
}

}
function ChangePassword(){
window.open("/Helpdesk/Changepass.asp","ChangePass","toolbar=0, ststus=0, location=0, menubar=0,resizable=0, width=450,height=200,scrollbars=0",false)
}


function buttonOver(btnObj){
btnObj.className=btnObj.className+"Hover"
}
function buttonOut(btnObj){

btnObj.className=btnObj.className.substr(0,btnObj.className.indexOf("Hover"))
}

function navBack()
{
if (arguments[0] != null){
		window.history.back(arguments[0]);
		return;
		}
window.history.back();
}


function setStatus(msg){
window.status=msg
}
function Logout(path){
if (window!=top){
 window.parent.location.href=path+"logout.asp"
}
else
{
 window.location.href=path+"logout.asp"
}

}

function PopPage(Url,pName,pWidth,pHeight,modal){
	var pTop=(screen.availHeight -pHeight)/2
	var pLeft=(screen.availWidth  -pWidth)/2
	if (modal){
		if (window.showModalDialog){
		window.showModalDialog(Url,"","dialogWidth:"+pWidth/16+" ; dialogHeight:"+pHeight/13)
		}
		else {
		window.open(Url,pName,"top="+pTop+",left="+pLeft+",toolbar=0,location=0,status=0,menubar=0,width="+pWidth+",height="+pHeight+",scrollbars=0,resizable=0")
		}
	}
	else
	{
	window.open(Url,pName,"top="+pTop+",left="+pLeft+",toolbar=0,location=0,status=0,menubar=0,width="+pWidth+",height="+pHeight+",scrollbars=0,resizable=1")
	}
}

function OpenProblem(ID,newwindow){
if (newwindow)
	window.open("Problem.asp?TicketId="+ID,"_blank")
else
	window.location.href="Problem.asp?TicketId="+ID

}

function setMenuItem(ItemNo){
if (window.parent.frames){
	if (window.parent.frames[0]){
		if (window.parent.frames[0].SelectedStatusItem || window.parent.frames[0].SelectedStatusItem==0){
			window.parent.frames[0].SelectedMenuItem=ItemNo;
		}
	}
}

}

function SetStatusItem(StatusId){

if (window.parent.frames){
//if (window.parent.frames[0].SelectedStatusItem)
window.parent.frames[0].SelectedStatusItem=StatusId;
}
}



function FormatString(Msg){
	var ii=1
	
	for (ii=1;ii<FormatString.arguments.length;ii++){
		Msg=doReplace(Msg,FormatString.arguments[ii])
	}
	return Msg
}

function doReplace(strVal,RepVal){
  var r, re;
  re = /%j/i;
  r = strVal.replace(re, RepVal);
  return(r);
}