

function popUp(URL) {
 popwin = window.open(URL, 'popup', 'toolbar=yes,scrollbars=1,location=0,statusbar=0,menubar=yes, dependent=yes, resizable=1,width=800,height=300,left = 630,top = 502');
 popwin.focus();
}
			
function setSaveTime(res) {
	if (res) {
		document.getElementById('messageArea').innerHTML = 'Autosaved at ' + nowFormated();
	}
}
function nowFormated(){
	var now = new Date();
	var ampm = "AM";
	var hour = new Number(now.getHours());
	if (hour > 12) {
		ampm = "PM";
		hour = hour - 12;
	} else if (hour == 0) {
		hour = 12;
	}
	var minutes = new Number(now.getMinutes());
	if (minutes <= 9) {
		minutes = "0" + minutes;
	}
	var seconds = new Number(now.getSeconds());
	if (seconds <= 9) {
		seconds = "0" + seconds;
	}
	return hour + ":" + minutes + ":" + seconds + " " + ampm;
}

function toggleDisplay( val, val1, val2 , val4){
   element1 = document.getElementById(val1).style; 
   element2 = document.getElementById(val2).style; 
   element3 = document.getElementById('result').style; 
   if( val ==  val4)	{ 
	element1.display='none'; 
	element2.display='block'; 
	element3.display='block'; 
   }
   else{
	
	element1.display='block'; 
	element2.display='none'; 
	element3.display='none'; 
   }
   return;
}

function toggleDisplayHelpD( ){
   element1 = document.getElementById('hdesk').style; 
   element1.display='block'; 
    return;
}
function foronload(val,val1){
	  if(val != ' ') { 
	   toggleDisplay( val, 'tr1' , 'tr2', '2');}
	 if(val1 != ' ') {
	 toggleDisplay( val1, 'tr1', 'tr3', '1');}
}


function check(frm) { 
valid = true; 
if ((frm.state.selectedIndex == -1) || 
(frm.state.options[frm.state.selectedIndex].value == "")) { 
valid = false; 
} 
  if (!valid)
   { 
      alert("Please select State."); 
  } 
  return valid; 
} 


function submitRegistrationForm(frm){
   
  dnameVal = frm.dname.value;
  cityVal = frm.city.value;
  
  
  if((dnameVal.substring(0,1)) == " "  || (isDigit(dnameVal.substring(0,1))) || (checkTHE(dnameVal.substring(0,3)))){
      alert("Name cannot begin with 'THE', 'The', blank, or a numeric character.");
      frm.dname.focus();
      return false; 
  }
  
  if((cityVal.substring(0,1)) == " "  || (isDigit(cityVal.substring(0,1))) || (checkTHE(cityVal.substring(0,3)))){
      alert("City name cannot begin with 'THE', 'The', blank, or a numeric character.");
      frm.city.focus();
      return false; 
 }
 
 if ((frm.state.selectedIndex == -1) || 
     (frm.state.options[frm.state.selectedIndex].value == "")) { 
      alert("Please select State."); 
      frm.state.focus();
      return false; 
  }
}


function checkTHE(val){
	
 if(val.toUpperCase() == "THE" ){	return true;}
  else{   return false;}
}   

function isBlank(val){
	if(val==null){return true;}
	for(var i=0;i<val.length;i++) {
		if ((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}
		}
	return true;
}

	
function isDigit(num) {
	if (num.length>1){return false;}
		var string="1234567890";
	if (string.indexOf(num)!=-1){return true;}
	return false;
}

function popUpWin(URL) {
  day = new Date();
  id = day.getTime();
  popwin = window.open(URL, id ,  'toolbar=yes,scrollbars=1,location=0,statusbar=0,menubar=yes, dependent=yes, resizable=1,width=800,height=300,left = 630,top = 502');
  popwin.focus();
}