// *************************************************************************
// Developed by HCS Enterprises Pty Ltd. 
// -------------------------------------------------------------------------
// All source code & content (c) Copyright 2006, HCS Enterprises unless
// specifically noted otherwise.
//
// The contents of this file are protect under law as the intellectual 
// property of HCS Enterprises. Any use, reproduction, disclosure or copying 
// of any kind without the express and written permission of HCS Enterprises 
// is forbidden.
// -------------------------------------------------------------------------
// Author: HCS Enterprises |  support@hcshelp.com  |  http://www.hcshelp.com
// *************************************************************************

function IsNumeric(strString)
{
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
   {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
      {
         blnResult = false;
      }
   }
   return blnResult;
}
function validEmail(str) {
 	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1)
	{
	   return true;
	}
	else if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{
	    return true;
	}
	else if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{
	    return true;
	}
	else if (str.indexOf(at,(lat+1))!=-1)
	{
	    return true;
	}
	else if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{
	    return true;
	}
	else if (str.indexOf(dot,(lat+2))==-1)
	{
	    return true;
	}
	else if (str.indexOf(" ")!=-1)
	{
	    return true;
	}
	return false
}
function trim(inputString) 
{
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue;
}
function checkMatch_pass(pass1,pass2)
{
	if(trim(pass1).length<=0)
	{
		return true;
	}
	else if(trim(pass1)==trim(pass2))
	{
		return false;
	}
	return true;
}
function helpRequest(url) {

	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = helpContents;
	http_request.open('GET', url, true);
	http_request.send(null);

}

function helpContents() {

	if (http_request.readyState == 4) {
		if (http_request.status == 200) 
		{
			var ns6=(document.getElementById&&!document.all);
			var theElm,a,j,theHTML;
			if(ns6)
				theElm = document.getElementById('Div1');
			else
				theElm = document.all.Div1;
			theHTML=http_request.responseText;
			theElm.innerHTML=theHTML;
			createWindow('Help', 500, '#D6E1F5', 1, 1, 220, 140);
		} 
		else {
			alert('There was a problem with the request.');
		}
	}

}
function fill_help(th)
{
	var ns6=(document.getElementById&&!document.all);
	var theElm,a,j,theHTML;
	if(ns6)
		theElm = document.getElementById('Div1');
	else
		theElm = document.all.Div1;
	if(trim(theElm.innerHTML).length<=0)
	{
		theElm.innerHTML="Loading Please Wait..";
		helpRequest("fill_help.php?st="+th);
	}
	else
	{
		createWindow('Help', 500, '#D6E1F5', 1, 1, 220, 140);
	}
}
function createWindow(cUrl,cName,cFeatures)
{
	var xWin = window.open(cUrl,cName,cFeatures)
}
function menuoperation()
{
	if(document.getElementById("mainMenu").style.display=="none")
	{
		document.getElementById("mainMenu").style.display="";
		document.getElementById("imgMenu").src="../images/close-arrow.gif";
		setcookie('pmsmenustatus',"S",100);
	}
	else
	{
		document.getElementById("mainMenu").style.display="none";
		document.getElementById("imgMenu").src="../images/open-arrow.gif";
		setcookie('pmsmenustatus',"H",100);
	}
}
function menuoperation()
{
	if(document.getElementById("mainMenu").style.display=="none")
	{
		document.getElementById("mainMenu").style.display="";
		document.getElementById("imgMenu").src="../images/close-arrow.gif";
		setcookie('pmsmenustatus',"S",100);
	}
	else
	{
		document.getElementById("mainMenu").style.display="none";
		document.getElementById("imgMenu").src="../images/open-arrow.gif";
		setcookie('pmsmenustatus',"H",100);
	}
}
function ubhumenu(strcomd)
{
	if(strcomd=="Ubhumyacc")
	{
		if(document.getElementById("Ubhumyacc").style.display=="none")
		{
			document.getElementById("Ubhumyacc").style.display="";
			setcookie('Ubhumyacc',"S",100);
		}
		else
		{
			document.getElementById("Ubhumyacc").style.display="none";
			setcookie('Ubhumyacc',"H",100);
		}
	}
	else if(strcomd=="Ubhuproj")
	{
		if(document.getElementById("Ubhuproj").style.display=="none")
		{
			document.getElementById("Ubhuproj").style.display="";
			setcookie('Ubhuproj',"S",100);
		}
		else
		{
			document.getElementById("Ubhuproj").style.display="none";
			setcookie('Ubhuproj',"H",100);
		}
	}
	else if(strcomd=="Ubhurepo")
	{
		if(document.getElementById("Ubhurepo").style.display=="none")
		{
			document.getElementById("Ubhurepo").style.display="";
			setcookie('Ubhurepo',"S",100);
		}
		else
		{
			document.getElementById("Ubhurepo").style.display="none";
			setcookie('Ubhurepo',"H",100);
		}
	}
	else if(strcomd=="Ubhuseti")
	{
		if(document.getElementById("Ubhuseti").style.display=="none")
		{
			document.getElementById("Ubhuseti").style.display="";
			setcookie('Ubhuseti',"S",100);
		}
		else
		{
			document.getElementById("Ubhuseti").style.display="none";
			setcookie('Ubhuseti',"H",100);
		}
	}
}
function getexpirydate( nodays){
	var UTCstring;
	Today = new Date();
	nomilli=Date.parse(Today);
	Today.setTime(nomilli+nodays*24*60*60*1000);
	UTCstring = Today.toUTCString();
	return UTCstring;
}
function setcookie(name,value,duration)
{
	cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration)+";path=/";
	document.cookie=cookiestring;
}
function getcookie(cookiename)
{
	var cookiestring=""+document.cookie;
	var index1=cookiestring.indexOf(cookiename);
	if (index1==-1 || cookiename=="") return ""; 
	var index2=cookiestring.indexOf(';',index1);
	if (index2==-1) index2=cookiestring.length; 
	return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}