<!--//version 0.9.1.1 modified on 10/07/03 by niveditha -->

netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP|Event.KEYPRESS);

var dateCompareResult

function validatekeys(DnEvents,KeyCategory,SpecialChar)
 {
 var alphabet="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
 var numeric="0123456789"
 var special="'"
 var searchstr=""
 SpecialChar=SpecialChar.replace("sq","'")
 
 switch (KeyCategory){
   case "alphabet":
     searchstr=alphabet+SpecialChar;
     break;
   case "numeric":
     searchstr=numeric+SpecialChar
     break;
   case "alphanumeric":
     searchstr=alphabet+numeric+SpecialChar
     break;
   case "special":
	 searchstr=alphabet+special+SpecialChar
     break; 
 }
 
 k = (netscape) ? DnEvents.which : window.event.keyCode;
 if ((k!=8)&&(k!=13)&&(searchstr.indexOf(String.fromCharCode(k))==-1)){
   if (netscape) {
    DnEvents.cancelBubble=true;
    DnEvents.returnValue=false; }
   else {
    window.event.cancelBubble=true;
    window.event.returnValue=false; }  }

 }
function validateFirstSlash(textvalue)
 {
  if (textvalue.substr(0,1)=="/")
  { return false; }
  else
  { return true; }
 }

function validateFirstAnd(textvalue)
 {
  if (textvalue.substr(0,1)=="&")
  { return false; }
  else
  { return true; }
 }
 function validateFirstSemi(textvalue)
 {
  if (textvalue.substr(0,1)==";")
  { return false; }
  else
  { return true; }
 } 
function validateFirstBlank(textvalue)
 {
  if (textvalue.substr(0,1)==" ")
  { return false; }
  else
  { return true; }
 }
 function validateFirstHyphen(textvalue)
{
	 if (textvalue.substr(0,1)=="-")
  { return false; }
  else
  { return true; }
} 

 function validateFirstQuestionMark(textvalue)
 {
  if (textvalue.substr(0,1)=="?")
  { return false; }
  else
  { return true; }
 }
 function validateFirstUnderscore(textvalue)
 {
  if (textvalue.substr(0,1)=="_")
  { return false; }
  else
  { return true; }
 }
  function validateFirstComma(textvalue)
 {
  if (textvalue.substr(0,1)==",")
  { return false; }
  else
  { return true; }
 }

function validateFirstAt(textvalue)
 {
  if (textvalue.substr(0,1)=="@")
  { return false; }
  else
  { return true; }
 }

 function validateFirstApostrophe(textvalue)
 {
  if (textvalue.substr(0,1)=="'")
  { return false; }
  else
  { return true; }
 }
 function validateFirstDot(textvalue)
 {
  if (textvalue.substr(0,1)==".")
  { return false; }
  else
  { return true; }
 }
 
 function validateFirstNumeric(textvalue)
 {
  if (isNaN(textvalue.substr(0,1)))
  { return true; }
  else
  { return false; }
 }
 
function alertmessage(alertTitle,iconPath,helpTopic)
{
 var alertArr=new Array(alertTitle,iconPath,helpTopic)
 window.showModelessDialog("alertX.htm",alertArr,"dialogHeight:150px;dialogWidth:400px;status:no;edge:raised;scroll:no;help:no;dialogLeft:300;dialogTop:250")
}

function loadTitle(filename)
 {
  var title=escape(document.title.substr(0,document.title.indexOf("SKCH ")))
  if (top.location.href.indexOf("main.htm")==-1)
   { top.location.href= "main.htm?doctitle=" + title + "&nav="+filename }
  top.document.title=document.title 
 }

function loadcombo(comboName,comboValue,comboText)
{
 var comboValue=false;

 for (i=0;i<comboName.length;i++)
 { if ((comboName.options[i].value==comboValue)&&(comboName.options[i].text==comboText))
    { comboName.selectedIndex = i
      comboValueExists=true
      break; } }

 if (comboValue==false){
  if (!(netscape)==true){
	var insertItem = new Option (comboText,comboValue)
	var insertIndex = comboName.length
	comboName.options[insertIndex] = insertItem 
	comboName.selectedIndex = insertIndex }
  }
}


//a function to clear the text field passed as an argument
function clearField(fld)
{
  if (confirm("Do you wish to clear off this field?")==true)
   {  fld.value = ""  }
}//end of function clearFld



//this function returns the comparative relation of the first date with the second date
//dates must be passed in dd/mm/yyyy format
//if the date format is unrecognized, the function returns "NR" when the dateCompareResult variable is accessed
function dateCompare(date1,date2)
{
  var dateArr1
  var dateArr2
  var day1, month1, year1
  var day2, month2, year2
  
  if ((date1.indexOf("/")==-1)||(date2.indexOf("/")==-1))
  {
    dateCompareResult = "NR"
  }
  else
  {
     dateArr1 = date1.split("/")
     dateArr2 = date2.split("/")
     if ((dateArr1.length!=3)||(dateArr2.length!=3))
     {
       dateCompareResult = "NR"
     }
     else
     {
       day1 = dateArr1[0]
       month1 = dateArr1[1]
       year1 = dateArr1[2]
       
       day2 = dateArr2[0]
       month2 = dateArr2[1]
       year2 = dateArr2[2]
     
       if ((isNaN(parseFloat(day1)))||(isNaN(parseFloat(month1)))||(isNaN(parseFloat(year1)))||(isNaN(parseFloat(day2)))||(isNaN(parseFloat(month2)))||(isNaN(parseFloat(year2))))
       {  
		 dateCompareResult = "NR" 
	   }
	   else
	   {
			if (parseFloat(year1)>parseFloat(year2))
			  {  dateCompareResult = ">"  }
			else if (parseFloat(year1)<parseFloat(year2))
			  {  dateCompareResult = "<"  }
			else
			  {
			    if (parseFloat(month1)>parseFloat(month2))
			      {  dateCompareResult = ">"  }
			    else if (parseFloat(month1)<parseFloat(month2))
			      {  dateCompareResult = "<"  }
			    else
			      {
			        if (parseFloat(day1)>parseFloat(day2))
			          {  dateCompareResult = ">" }
			        else if (parseFloat(day1)<parseFloat(day2))
			          {  dateCompareResult = "<" }
			        else
			          {  dateCompareResult = "=" }
			      }
			  }
	   }
     }
  }
}//end of dateCompare function