
<!--
//var jsBeforeSubmit="";

function submitForm()
{
 // setTimeout("Non()",10000);
  if (jsBeforeSubmit!="") return  eval(jsBeforeSubmit);
  else return true;
}

function promptSave()
{
	 var answer=confirm('You have made change(s), leave without save?');
     if (answer) return true;
     else return false;
}

function ConfirmDelete()
{
	var answer=confirm('You will lose the saved information, continue?');
    if (answer) return true;
    else return false;
}

function ConfirmDeleteDemand()
{
	var answer=confirm('Resource Template data will be deleted. Click OK to continue.');
    if (answer) return true;
    else return false;
}

 function MarkChange()
 {
	jsBeforeSubmit='promptSave()';
 }

 String.prototype.trim = function()    //// trims white space off both ends of this string
 {
 return( (ar=/^\s*([\s\S]*\S+)\s*$/.exec(this)) ? ar[1] : "" ); 
 }

 // Check whether string s is empty.
 function checkEmpty(s)
 {   return ((s == null) || (s.length == 0)) }

// generic positive number decimal formatting function
function format (expr, decplaces) 
{
	// raise incoming value by power of 10 times the
	// number of decimal places; round to an integer; convert to string
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces))
	// pad small value strings with zeros to the left of rounded number
	while (str.length <= decplaces) {
		str = "0" + str
	}
	// establish location of decimal point
	var decpoint = str.length - decplaces
	// assemble final result from: (a) the string up to the position of
	// the decimal point; (b) the decimal point; and (c) the balance
	// of the string. Return finished product.
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}

function MySpaceBar(width)
{
	 var ImageSpace = new Image(width,1);
	 ImageSpace.src= "projectimage/misc/space.gif";
	 return ImageSpace;
}

function formatName(NameStr)
 {
  var nameChr =" ";
  var newNameStr = "";
   
  for (var i=0; i < NameStr.length; i++)
  if (nameChr == "/" || nameChr == "-" || nameChr == "_" || nameChr == " ")
  {	nameChr = NameStr.substr(i, 1)	
	newNameStr = newNameStr + nameChr.toUpperCase();	
  }
  else
  { nameChr = NameStr.substr(i, 1)	
	newNameStr = newNameStr + NameStr.substr(i, 1).toLowerCase();
  }   	
	return newNameStr;
 }
 
 
// this is a very powerful tools for pick up object by Name 
// Benjamin Xu   09/26/2003
 
/*
function getObj(name)
{
  if (document.getElementById)  return document.getElementById(name);
  else if (document.all)        return document.all[name];
  else if (document.layers)     return getObjNN4(document,name);
}


function getObjNN4(obj,name)
{
	var x = obj.layers;
	var thereturn;
	for (var i=0;i<x.length;i++)
	{
		if (x[i].id == name)
		 	thereturn = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) thereturn = tmp;
	}
	return thereturn;
}

*/

// ***************************************************************
// ***************Time, Number Validation ************************
// ***************************************************************

function checkInteger (s)

{   var i;
    if (checkEmpty(s)) 
       if (checkInteger.arguments.length == 1) return defaultEmptyOK;
       else return (checkInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (!checkDigit(c))
         {
          alert("Invalid integer!");
          return false;
		 }	
    }
    // All characters are numbers.
    return true;
}

function validateTime(textBox, emptyOK, showAlert) 
{
  //if disabled field, no need to validate
  if (textBox.disabled==true) return true;

  var x=textBox.value.toUpperCase().trim();
  if (checkEmpty(x))
  {  
      if (!emptyOK) { textBox.focus(); textBox.select(); if (showAlert) alert("Field can not be left empty."); }
	  return emptyOK;
  }
  var sHours ='';
  var sMins = '';
  var isAmpm =(nrpttmdsp=='2'? false : true);
  var ampm = '';

  if (x.indexOf("AM")!=-1) 
  {  
     x=x.replace("AM", "").trim();
     if (isAmpm) ampm=camsuffix; 
  }
  else if (x.indexOf("A")!=-1) 
  {
	x=x.replace("A","").trim();
    if (isAmpm) ampm=camsuffix; 
  }
  else if (x.indexOf("PM")!=-1)
  {  
    x=x.replace("PM", "").trim();
    if (isAmpm) ampm=cpmsuffix; 
  } 
  else if (x.indexOf("P")!=-1)
  {
    x=x.replace("P","").trim();
    if (isAmpm) ampm=cpmsuffix; 
  }
  
  x = x.replace(':',''); 
  // more than two dots is invalid
  if (x.lastIndexOf('.')!=x.indexOf('.'))  return false;
  
  var hours, mins;
  if (x.indexOf(".")==-1) 
  {
  var y = x + (x.length==1?'00':x.length==2? (parseFloat(x)<24? '00':'0'):'');
  hours = parseFloat(y.substring(0,y.length-2));
  mins =  parseFloat(y.substring(y.length-2,y.length));
  }
  else
  {
   var parts=x.split(".");
   hours = parseFloat(parts[0]);
   mins = parseFloat(parts[1]);
  } 
  
  if (isNaN(hours) || isNaN(mins) ) 
  { 
     textBox.style.display="";
	 textBox.focus();
	 textBox.select();
	 if (showAlert) alert(" Invalid Time!");
     return false;
  }
  else 
  {
    if (x.length==2 && mins-60>=0)  mins=parseInt(mins/10);  //convert 5.9 to 5 hour 9 mins
    hours=(hours+Math.floor(mins/60)) % 24;
    mins=mins%60
    var sHours=(hours.toString().length==1 && lleadzero? '0':'') + hours.toString();
    var sMins=(mins.toString().length==1? '0':'') + mins.toString();

    if (hours==12) 
      textBox.value = sHours +':'+ sMins + (isAmpm? (ampm==''? cpmsuffix: ampm) : '');
    else if (hours==24) 
	  textBox.value = '0:'+ sMins +(isAmpm? camsuffix :'');
    else if (hours > 12 && hours < 24 && isAmpm)
      {
      sHours=(nrpttmdsp=='2'? hours.toString() : (hours-12).toString()); 	
	  textBox.value= sHours + (sHours == '' && sMins == ''?'':':') + sMins+ (isAmpm? (ampm==''? cpmsuffix: ampm) :'');
     }
    else 
      textBox.value= sHours +(sHours == '' && sMins == ''?'':':') + sMins+ (isAmpm?  (ampm==''? camsuffix: ampm) : '');
    
     return true; 
  }
}


function validateNumber(textBox,emptyOK, showAlert)
{

  if (textBox.disabled==true) return true;
  //Empty is OK
  if (checkEmpty(textBox.value.toUpperCase().trim())) 
  {
     if(!emptyOK) { textBox.focus(); textBox.select(); if (showAlert) alert("Field can not be left empty.");}
     else textBox.value=format(0, 2);         //PC
     return emptyOK;
  }	
  if(isNaN(textBox.value)) { textBox.focus(); textBox.select(); if (showAlert) alert("Invalid number."); 
							 return false; }
  else 
  { 
    textBox.value=format(textBox.value, 2);
    return true; 
  }
}


function focusState(element) {element.style.backgroundColor="#FFFFDE";
				                     element.style.borderColor="#000000";
						             element.style.color="#000000";
						     //CTD-081204-DS8A - PC - 12/09/2008        
						     if ((element.id =='txtUserName'))
						     {
								element.setAttribute("focus", "yes");
								if (document.forms[0].txtPassword) 
								document.forms[0].txtPassword.setAttribute("focus", "no");
							 }
							 if ((element.id =='txtPassword'))
						     {
								element.setAttribute("focus", "yes");
								if (document.forms[0].txtUserName) 
								document.forms[0].txtUserName.setAttribute("focus", "no");
							 }
							 //EOC
						     }
function blurState(element) {element.style.backgroundColor="#FFFFFF";
                                     element.style.borderColor="#777777";
                                     element.style.color="#777777";}


//***************PC - 02/25/2005 - Validate Rate Textbox**********************
function validateRate(txtID,length,dec,symbol)
{
  var cell=getObj(txtID);
  var cellValue = cell.value.replace(symbol.trim(),"")
  if (!isNumber(cellValue)) 
  {	cell.value ='';
	return; 
  }
  cell.value=(cellValue.trim() !=''? parseFloat(cellValue).toFixed(length) : '') 
  addSymbol(getObj(txtID),cell,dec,symbol)  
}


function isEmpty(inputStr) {
	if (inputStr == null || inputStr == "") 
	{
	return true;
	}			
	return false;
}

// Validate if the input value is a number. Pop up an error message if it is not;
function isNumber(inputVal) {
	
	oneDecimal = false;
	inputStr = inputVal.toString()
	if (isEmpty(inputStr.trim()))
    {
     return true;
    }	
	for (var i = 0; i < inputStr.length; i++) 
	    {
		var oneChar = inputStr.charAt(i)
		if (i == 0 && oneChar == "-") 
		{
		 continue;
		 }
	
 	    if (oneChar == "." && !oneDecimal) 
 	     {
			oneDecimal = true;
			continue;
	      }
	
	    if (oneChar < "0" || oneChar > "9") 
	     {
			//alert("Rate is invalid !");
			alert("Value is invalid !");    //PC - 05/23/2007
			return false;
		 }
	}

	return true;
}

function addSymbol(textBox,cell,dec,symbol)
{
    //Empty is OK
    if (checkEmpty(textBox.value.toUpperCase().trim())) {textBox.value="";  return false; }	
	textBox.value = textBox.value.replace(symbol, "")
    var amount=parseFloat(textBox.value,dec);
    textBox.setAttribute("unmaskedValue", format(amount, dec));
    if (document.all) cell.innerText= symbol.trim() + format(amount, dec);
    else textBox.value= symbol.trim() +format(amount, dec);
    return false;
}
//***************PC - 02/25/2005 - Validate Rate Textbox**********************

//PC - 04/24/2007
function reFormatDateString(dateStr)
	{// JS needs four digits years, so this function reformat the date string (e.g. mm/dd/yyyy)
		
		var formatDStr=dateStr.split("/");
		var yearFM1;
			
		switch(parent.ndatefmt)
		{	
			case "1":
				return formatDStr[0] + '/' + formatDStr[1]+ '/' + formatDStr[2]; 
				break;
			case "2":
				return formatDStr[1] + '/' + formatDStr[0]+ '/' + formatDStr[2];  
				break;
			case "3":
				return  formatDStr[1] + '/' + formatDStr[2]+ '/' + formatDStr[0];  
				break;
		}
	}



// ******************************************************************************************
// *************Do Not Allow Web User to user mouse right click to view page source *********
// ******************************************************************************************

if (window.Event)
document.captureEvents(Event.MOUSEUP);
function nocontextmenu() {
  event.cancelBubble = true, event.returnValue = false;
  return false;
} 

function norightclick(e) {
  if (window.Event) {
    if (e.which == 2 || e.which == 3) return false;
  }
  else if (event.button == 2 || event.button == 3) {
    event.cancelBubble = true, event.returnValue = false;
    return false;
  }
}

if (document.layers)
document.captureEvents(Event.MOUSEDOWN);
document.oncontextmenu = nocontextmenu;
document.onmousedown = norightclick;
document.onmouseup = norightclick;

// *************Do Not Allow Web User to user mouse right click to view page source *********




//-->



 