// *************************************************************************
// 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
// *************************************************************************
var viewpag=0;
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
   }
	 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);
   }
   retValue=removeHTMLTags(retValue);
   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));
}

function tabview_aux(TabViewId, id)
{
  var TabView = document.getElementById(TabViewId);

  // ----- Tabs -----

  var Tabs = TabView.firstChild;
  while (Tabs.className != "Tabs" ) Tabs = Tabs.nextSibling;

  var Tab = Tabs.firstChild;
  var i   = 0;

  do
  {
    if (Tab.tagName == "A")
    {
      i++;
      Tab.href      = "javascript:tabview_switch('"+TabViewId+"', "+i+");";
      Tab.className = (i == id) ? "Active" : "";
      Tab.blur();
    }
  }
  while (Tab = Tab.nextSibling);

  // ----- Pages -----

  var Pages = TabView.firstChild;
  while (Pages.className != 'Pages') Pages = Pages.nextSibling;

  var Page = Pages.firstChild;
  var i    = 0;

  do
  {
    if (Page.className == 'Page')
    {
      i++;
      if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
      Page.style.overflow = "auto";
      Page.style.display  = (i == id) ? 'block' : 'none';
    }
  }
  while (Page = Page.nextSibling);
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}
function roundNumber(num,dec)
{
	num=parseFloat(num);
	if(isNaN(num))
	num=0.00;
	var val=Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	if (val>0)
		return val;
	else
		return "0.00";
}
// ----- Functions -------------------------------------------------------------

function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); }

function tabview_initialize(TabViewId) { tabview_aux(TabViewId,  1); }

function cookieSave(name, text) {
		document.cookie = name + "=" + escape(text);
	}

	function cookieLoad(name) {
		var search = name + "=";
		if (document.cookie.length > 0) {
			offset = document.cookie.indexOf(search);
			if (offset != -1) {
				offset += search.length;
				end = document.cookie.indexOf(";", offset);
				if (end == -1) {
					end = document.cookie.length;
				}
				return unescape(document.cookie.substring(offset, end));
			}
		}
	}
function winRedirect(id)
{
	window.open("view.php?id="+id);
}
function trim1( value ) {
	str = value.toString();
	while (str.indexOf("&nbsp;")!=-1)
	{
		str = str.replace('&nbsp;',"");
	}
	 while (str.indexOf(" ")!=-1)
	{
		str = str.replace(' ',"");
	}
	str = str.replace(/^\s*|\s*$/g,"");
	return str;    	
}//function for trim end
function IsInteger(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 removeHTMLTags(text)
{
 		var strInputCode = text;
 		/* 
  			This line is optional, it replaces escaped brackets with real ones, 
  			i.e. < is replaced with < and > is replaced with >
 		*/	
 	 	strInputCode = strInputCode.replace(/&(<|>);/g, function (strMatch, p1){
 		 	return (p1 == "<")? "<" : ">";
 		});
 		var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
 		//alert("Output text:\n" + strTagStrippedText);	
		while (strTagStrippedText.indexOf("&nbsp;")!=-1)
		{
			strTagStrippedText = strTagStrippedText.replace('&nbsp;',"");
		}
		strTagStrippedText = strTagStrippedText.replace(/^\s*|\s*$/g,"");
		
		if(strTagStrippedText=="")
			return "";
		else
 			return strTagStrippedText;	
			
		
			
   // Use the alert below if you want to show the input and the output text
   //		alert("Input code:\n" + strInputCode + "\n\nOutput text:\n" + strTagStrippedText);	
 		
}

<!--
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
    v=o.value;t=a[i+2];
    if (o.type=='text'||o.type=='password'||o.type=='hidden'){
      if (r&&v.length==0){err=true}
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      }
    } else
    if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
    } else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
    }else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
    if (err){s+='* '+a[i+3]+'\n'; err=false}
  }
  if (s!=''){alert(s)}
  document.MM_returnValue = (s=='');
}
function saveIssueStatus(tktit,uid)
{
	var stat=document.getElementById("issuetracker").style.display;
	var st=1;
	if(stat=="none")
		st=0;
	var url="updissuestatus.php?tktid="+tktit+"&uid="+uid+"&stat="+st;
	var xmlHttpDel;
	xmlHttpDel=GetXmlHttpObject();
	if (xmlHttpDel==null)
	{
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlHttpDel.onreadystatechange=function()
	{
		if(xmlHttpDel.readyState == 4 && xmlHttpDel.status == 200)
		{
			//getIssue(tid,1);
		}
	}
	xmlHttpDel.open("GET",url,true);
	xmlHttpDel.send(null);

}
//-->