function isValidDate(dateStr) {
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
	document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Date is not in a valid format.";
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Month must be between 1 and 12.";
return false;
}
if (day < 1 || day > 31) {
document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Day must be between 1 and 31.";
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Month "+month+" doesn't have 31 days!";
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;February " + year + " doesn't have " + day + " days!";
return false;
   }
}

}
//  End -->


//Ajax function for the Adding data for the Multiple calendar to the temporary table

function loadXMLDoc(date,check,admin)
{
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
			//document.getElementById("eventdate").value=xmlhttp.responseText;
			//alert(xmlhttp.responseText);
	  }
	}
		xmlhttp.open("GET","../siteadmin/scripts/add_temp.php?date="+date+"&admin="+admin+"&check="+check,true);
	xmlhttp.send();
}
function loadDateXML(date)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
			document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
			
	  }
	}
		xmlhttp.open("GET","../siteadmin/scripts/date_change.php?date="+date,true);
		xmlhttp.send();
}
function loadCoupon()
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
			
			document.getElementById("pcode").value=xmlhttp.responseText;
			
	  }
	}
		xmlhttp.open("GET","../siteadmin/scripts/coupon.php",true);
		xmlhttp.send();
}

function loadCDiscount(id,invoiceid)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	code=document.getElementById('pcode').value;
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
	  	document.getElementById("pdiscount").innerHTML=xmlhttp.responseText;
	  }
	}
		//xmlhttp.open("GET","http://staging.drivesafecolorado.com/coupon_discount.php?code="+code+"&id="+id+"&invoice="+invoiceid,true);
		xmlhttp.open("GET","/coupon_discount.php?code="+code+"&id="+id+"&invoice="+invoiceid,true);
		xmlhttp.send();
}

function loadCDiscountAdmin(id,invoiceid)
{
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	code=document.getElementById('pcode').value;
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
	  	document.getElementById("pdiscount").innerHTML=xmlhttp.responseText;
	  }
	}
		//xmlhttp.open("GET","http://staging.drivesafecolorado.com/coupon_discount.php?code="+code+"&id="+id+"&invoice="+invoiceid,true);
		xmlhttp.open("GET","/siteadmin/scripts/coupon_discount.php?code="+code+"&id="+id+"&invoice="+invoiceid,true);
		xmlhttp.send();
}

function loadXMLContact()
{
	
	var xmlhttp;
	email=document.getElementById('loginemail').value;
	if(email=="" )
	{
		document.getElementById('mess').innerHTML="<img src='/images/error.gif' border='0'>&nbsp;&nbsp;Please enter Email Address";
		return false;
	}
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
			if(xmlhttp.responseText!=" ") {
				document.getElementById("student_check").value=1;
				document.getElementById("contact_td").innerHTML="";
				document.getElementById("contact_td").innerHTML=xmlhttp.responseText;
				
			}else {
				document.getElementById("student_check").value=0;
				document.getElementById('mess').innerHTML="<img src='/images/error.gif' border='0'>&nbsp;&nbsp;Please enter Correct Email Address";
			}
	  }
	}
		var r = Math.floor(Math.random()*100);
		xmlhttp.open("GET","/show_student.php?emailid="+email+"&cb="+r,true);
	xmlhttp.send();
}

function loadXMLClass(contactid,classid,locationid,divid,selmonth)
{
	
	var xmlhttp;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function()
	{
	  if (xmlhttp.readyState==4)
	  {
			document.getElementById(divid).innerHTML=xmlhttp.responseText;
	  }
	}
		
	xmlhttp.open("GET","/siteadmin/scripts/ajax_ pre_registration.php?contactid="+contactid+"&classid="+classid+"&locationid="+locationid+"&monthselected="+selmonth,true);
	xmlhttp.send();
}

function PHPhasValue(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA") {
		if (obj.value.length == 0) {
			return false;
		} else { 
			return true;
		}
	}
}
function PHPchecknewInvoice(PHPthis) {
	if  (!PHPhasValue(PHPthis.invoicedate, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.invoicedate, PHPthis.invoicedate.value, "Please enter a date for this invoice")) {
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.amount, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.amount, PHPthis.amount.value, "Please enter an amount for this invoice")) {
			return false; 
		}
	} 
	if  (!PHPhasValue(PHPthis.description, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.description, PHPthis.description.value, "Please enter Description for this invoice")) {
			return false; 
		}
	}
	
	return true;
}


function PHPhasValueSelect(obj,invalid_val) {
    if (obj.value == invalid_val) 
    {
            return false;
    } 
    else { 
            return true;
    }
}
function PHPhasValueZero(obj, obj_type) {
	if (obj_type == "TEXT" || obj_type == "PASSWORD" || obj_type == "TEXTAREA") {
		if (obj.value == 0) {
			return false;
		} else { 
			return true;
		}
	}
}
function PHPcheckReportWriter(PHPthis)
{
	if  (!PHPhasValue(PHPthis.rtitle, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.rtitle, PHPthis.rtitle.value, "Please enter Report Title")) 
		{
			PHPthis.rtitle.focus();
			return false; 
		}
		
	}
}

function PHPcheckEvent(PHPthis)
{
	if(document.getElementById('ClassID').value==0) {
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please select Class Name";
		document.getElementById('mess').scrollIntoView();
		return false;
	}
	
	var x = 0;
	var Sel=0;
	for (x=0;x<PHPthis.LocationID.length;x++)
	 {
		if(PHPthis.LocationID[x].selected)
		{
			Sel=Sel+1;
			
		}
	 }
	if(document.getElementById('InstructorID').value!=0 && Sel>1) {
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;You can not add one Instructor to more than one Location";
		document.getElementById('mess').scrollIntoView();
		return false;
	
	}
	if(Sel==0) {
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Select atleast one Location Location";
		document.getElementById('mess').scrollIntoView();
		return false;
	
	}

	
}


function PHPcheckProducts(PHPthis)
{
	if  (!PHPhasValue(PHPthis.product_name, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.product_name, PHPthis.product_name.value, "Please enter Product Name")) 
		{
			PHPthis.product_name.focus();
			return false; 
		}
		
	}
	if((FCKeditorAPI.GetInstance('product_desc').GetHTML(true))=="")
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Product Description";
		return false;
	}
	
}

function PHPcheckform(PHPthis) 
{

	if  (!PHPhasValue(PHPthis.loginemail, "PASSWORD" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.loginemail, PHPthis.loginemail.value, "Please enter a Email")) {
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.loginpassword, "PASSWORD" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.loginpassword, PHPthis.loginpassword.value, "Please enter a password")) {
			return false; 
		}
	}
		
		
	//return true;
}
function PHPcheckSide(PHPthis) 
{

		if  (!PHPhasValue(PHPthis.package_group, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.package_group, PHPthis.package_group.value, "Please select Package Group")) {
			return false; 
			}
		}	
		if  (!PHPhasValue(PHPthis.side_content, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.side_content, PHPthis.side_content.value, "Please Side Content")) {
			return false; 
			}
		}

		
	//return true;
}

function PHPcheckweekly(PHPthis) 
{

		if  (!PHPhasValue(PHPthis.weekly, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.weekly, PHPthis.weekly.value, "Please select week")) {
			return false; 
			}
		}	
		if  (!PHPhasValueZero(PHPthis.LocationID, "TEXT" )) {
		if  (!PHPonError_new(PHPthis, PHPthis.LocationID, PHPthis.LocationID.value, "Please Select Location")) {
			return false; 
			}
		}	
		
	//return true;
}


function PHPcheckPage(PHPthis) 
{

	if  (!PHPhasValue(PHPthis.menu_id, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.menu_id, PHPthis.menu_id.value, "Please select Page Link To ")){
			PHPthis.menu_id.focus();
			return false; 

		}
	}
	if  (!PHPhasValue(PHPthis.headline, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.headline, PHPthis.headline.value, "Please enter Page Title")) 
		{
			PHPthis.headline.focus();
			return false; 

		}
	}
	if  (!PHPhasValue(PHPthis.summary, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.summary, PHPthis.summary.value, "Please enter Short Description")) 
		{
			PHPthis.summary.focus();
			return false; 

		}
	}	
	if  (!PHPhasValue(PHPthis.textbody, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.textbody, PHPthis.textbody.value, "Please enter Page Content")) 
		{
			PHPthis.textbody.focus();
			return false; 

		}
	}

		
	
}
  
function imposeMaxLength(Event, Object, MaxLen)
{
        if( (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40)))
		{
			return true;
		}
		else
		{
			alert('You added maximum number of characters');
			return false;
		}
}


function PHPcheckLocation(PHPthis)
{
	if (document.getElementById('satellite').checked==true) 
	{
		if  (!PHPhasValue(PHPthis.location_main, "TEXT" )) 
		{
		if  (!PHPonError_new(PHPthis, PHPthis.location_main, PHPthis.location_main.value, "Please Select Main Location")) 
		{
			PHPthis.location_main.focus();
			return false; 
		}
	}	
	}
	if  (!PHPhasValue(PHPthis.centername, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.centername, PHPthis.centername.value, "Please enter Center Name")) 
		{
			PHPthis.centername.focus();
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.locationabbr, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.locationabbr, PHPthis.locationabbr.value, "Please enter Center abbr ")) 
		{
			PHPthis.locationabbr.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.address, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.address, PHPthis.address.value, "Please enter Address")) 
		{
			PHPthis.address.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.city, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.city, PHPthis.city.value, "Please enter City")) 
		{
			PHPthis.city.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.state, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.state, PHPthis.state.value, "Please enter State")) 
		{
			PHPthis.state.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.zipcode, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.zipcode, PHPthis.zipcode.value, "Please enter Zip code")) 
		{
			return false; 
		}
	}
		var valid = "0123456789-";
		var hyphencount = 0;
		var field=PHPthis.zipcode.value;

		if (field.length!=5 && field.length!=10) {
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter correct Zip code.";
		document.getElementById('mess').scrollIntoView();
		return false;
		}
		for (var i=0; i < field.length; i++) 
		{
			temp = "" + field.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") 
			{
				document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Invalid characters in your zip code.  Please enter again.";
				document.getElementById('mess').scrollIntoView();
				return false;
			}
			if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) 
			{
				document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please enter again.";
				document.getElementById('mess').scrollIntoView();
				return false;
			   }
		}
	
	if  (!PHPhasValue(PHPthis.phone, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.phone, PHPthis.phone.value, "Please enter Phone")) 
		{
			PHPthis.phone.focus();
			return false; 
		}
		
	}
	var re10digit= /^\d{3}-\d{3}-\d{4}$/; 
	if (PHPthis.phone.value.search(re10digit)==-1)
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a valid Phone number \n Exp. 222-222-3334";
		document.getElementById('mess').scrollIntoView();
		PHPthis.phone.focus();
		return false
	} 
}

function PHPcheckLead(PHPthis)
{
	if  (!PHPhasValue(PHPthis.leadname, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.leadname, PHPthis.leadname.value, "Please enter Lead Source Name")) 
		{
			PHPthis.leadname.focus();
			return false; 
		}
	}
}

function PHPcheckActivity(PHPthis)
{
	if  (!PHPhasValue(PHPthis.location_id, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.location_id, PHPthis.location_id.value, "Select Location Name")) 
		{
			PHPthis.location_id.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.staff, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.staff, PHPthis.staff.value, "Select Staff Name")) 
		{
			PHPthis.staff.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.activity_type, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.activity_type, PHPthis.activity_type.value, "Select Activity Type")) 
		{
			PHPthis.staff.focus();
			return false; 
		}
	}	

	if (document.getElementById('eventstarttime').value > document.getElementById('eventendtime').value)
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Activity Start Time should be less then the Activity End Time";
		return false;
	}
	
	var chks = document.getElementsByName('eventdate[]');
	var hasChecked = false;
	for (var i = 0; i < chks.length; i++)
	{
	if (chks[i].checked)
	{
	hasChecked = true;
	break;
	}
	}
	if (hasChecked == false)
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please select atleast one Activity Date";
		return false;
	}
}

function PHPcheckRole(PHPthis)
{
	if  (!PHPhasValue(PHPthis.desc, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.desc, PHPthis.desc.value, "Please enter Role Description")) 
		{
			PHPthis.desc.focus();
			return false; 
		}
	}		
	if  (!PHPhasValue(PHPthis.menu, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.menu, PHPthis.menu.value, "Please select atleast one Permission Area")) 
		{
			PHPthis.menu.focus();
			return false; 
		}
	}	

}

function PHPcheckResStep1(PHPthis)
{
	if  (!PHPhasValue(PHPthis.legalname, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.legalname, PHPthis.legalname.value, "Please enter Legal Name")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.firstname, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.firstname, PHPthis.firstname.value, "Please enter First Name")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.lastname, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.lastname, PHPthis.lastname.value, "Please enter Last Name")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.gender, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.gender, PHPthis.gender.value, "Please select Gender")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.birthdate, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.birthdate, PHPthis.birthdate.value, "Please enter Date of Birth")) 
		{
			return false; 
		}
	}	
	if(isValidDate(PHPthis.birthdate.value)==false)
	{
		return false;
	}
	
	if  (!PHPhasValue(PHPthis.password, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.password, PHPthis.password.value, "Please enter Password")) 
		{
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.bcell, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.bcell, PHPthis.bcell.value, "Please enter Best Phone Contact No.")) 
		{
			return false; 
		}
	}	
	var re10digit= /^\d{3}-\d{3}-\d{4}$/; 
	if(PHPthis.bcell.value!="")
	{
		if (PHPthis.bcell.value.search(re10digit)==-1)
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a valid Best Phone Contact number \n Exp. 222-222-3334";
			document.getElementById('mess').scrollIntoView();
			return false
		}
	}
	if  (!PHPhasValue(PHPthis.acell, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.acell, PHPthis.acell.value, "Please enter Alternate Phone Contact No.")) 
		{
			return false; 
		}
	}
	var re10digit= /^\d{3}-\d{3}-\d{4}$/; 
	if(PHPthis.acell.value!="")
	{
		if (PHPthis.acell.value.search(re10digit)==-1)
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a valid Alternate Phone Contact number \n Exp. 222-222-3334";
			document.getElementById('mess').scrollIntoView();
			return false
		}
	}	
	if  (!PHPhasValue(PHPthis.street, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.street, PHPthis.street.value, "Please enter Street")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.street, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.street, PHPthis.street.value, "Please enter Street")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.city, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.city, PHPthis.city.value, "Please enter City")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValueSelect(PHPthis.StateID, -1 )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.StateID, PHPthis.StateID.value, "Please select State")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.zip, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.zip, PHPthis.zip.value, "Please enter Zipcode")) 
		{
			return false; 
		}
	}
		var valid = "0123456789-";
		var hyphencount = 0;
		var field=PHPthis.zip.value;

		if (field.length!=5 && field.length!=10)
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter correct Zip code.";
			document.getElementById('mess').scrollIntoView();
			return false;
		}
		for (var i=0; i < field.length; i++) 
		{
			temp = "" + field.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1") 
			{
				document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Invalid characters in your zip code.  Please enter again.";
				document.getElementById('mess').scrollIntoView();
				return false;
			}
			if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) 
			{
				document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please enter again.";
				document.getElementById('mess').scrollIntoView();
				return false;
			   }
		}
		if(document.getElementById('edit_l').value==1) {
			if  (!PHPhasValue(PHPthis.location, "TEXT" )) 
			{
				if  (!PHPonError_new(PHPthis, PHPthis.location, PHPthis.location.value, "Please select Location")) 
				{
					return false; 
				}
			}
		}
	
	if  (!PHPhasValue(PHPthis.highschool, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.highschool, PHPthis.highschool.value, "Please select High School")) 
		{
			return false; 
		}
	}
    
    if  (!PHPhasValueSelect(PHPthis.howDidYouHearAboutUs, -1 )) 
    {
        if  (!PHPonError_new(PHPthis, PHPthis.howDidYouHearAboutUs, PHPthis.howDidYouHearAboutUs.value, "Please select How did you hear about us?")) 
        {
            return false; 
        }
    }
	

}

function PHPcheckResStep2(PHPthis)
{
	if  (!PHPhasValue(PHPthis.location, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.location, PHPthis.location.value, "Please select Location")) 
		{
			return false; 
		}
	}	
	if  (!PHPhasValue(PHPthis.course, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.course, PHPthis.course.value, "Please select Course")) 
		{
			return false; 
		}
	}
}

function PHPonError_new(form_object, input_object, object_value, error_message) {
	document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;"+error_message;
	document.getElementById('mess').scrollIntoView();
	return false;	
}
function PHPonError(form_object, input_object, object_value, error_message) {
		alert(error_message);
	    return false;	
	}
function delVali()
{
	var con=confirm("Are you sure you want to Delete");
	if(con==1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function delDiscard()
{
	var con=confirm("Are you sure you want to Discard this Report");
	if(con==1)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function displaytester(value)
{
	
	if(value==3)
	{
		document.getElementById('testertr').style.display = '';
	}
	else
	{
		document.getElementById('testertr').value="";
		document.getElementById('testertr').style.display = 'none';
	}
}
function PHPcheckStaff(PHPthis)
{
	if  (!PHPhasValue(PHPthis.name, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.name, PHPthis.name.value, "Please enter Name")) 
		{
			PHPthis.name.focus();
			return false; 
		}
	}
	if  (!PHPhasValue(PHPthis.email, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.email, PHPthis.email.value, "Please enter Email")) 
		{
			PHPthis.email.focus();
			return false; 
		}
		
	}
	if(!checkEmail(PHPthis))
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Invalid E-mail Address! Please re-enter.";
		document.getElementById('mess').scrollIntoView();
		return false; 
	}

	var re10digit= /^\d{3}-\d{3}-\d{4}$/; 
	if(PHPthis.hphone.value!="")
	{
		if (PHPthis.hphone.value.search(re10digit)==-1)
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a valid Home Phone number \n Exp. 222-222-3334";
			document.getElementById('mess').scrollIntoView();
			return false
		}
	}
	if(PHPthis.phone.value!="")
	{
		if (PHPthis.phone.value.search(re10digit)==-1)
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a valid Phone number \n Exp. 222-222-3334";
			document.getElementById('mess').scrollIntoView();
			return false
		} 
	}
		
	if  (!PHPhasValue(PHPthis.location, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.location, PHPthis.location.value, "Please enter Location")) 
		{
			PHPthis.location.focus();
			return false; 
		}
		
	}	
	var chks = document.getElementsByName('stafftype[]');
	var hasChecked = false;
	for (var i = 0; i < chks.length; i++)
	{
	if (chks[i].checked)
	{
	hasChecked = true;
	break;
	}
	}
	if (hasChecked == false)
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please select atleast one Staff Type.";
		document.getElementById('mess').scrollIntoView();
	return false;
	}
	
	
}



function PHPcheckPackage(PHPthis)
{
	if  (!PHPhasValue(PHPthis.package_name, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.package_name, PHPthis.package_name.value, "Please enter Package Name")) 
		{
			PHPthis.package_name.focus();
			return false; 
		}
		
	}	
	if  (!PHPhasValue(PHPthis.package_group, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.package_group, PHPthis.package_group.value, "Please select Package Group")) 
		{
			PHPthis.package_group.focus();
			return false; 
		}
		
	}	
	var chks = document.getElementsByName('product[]');
	var hasChecked = false;
	for (var i = 0; i < chks.length; i++)
	{
	if (chks[i].checked)
	{
	hasChecked = true;
	break;
	}
	}
	if (hasChecked == false)
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please select atleast one Product.";
		document.getElementById('mess').scrollIntoView();
	return false;
	}
	if  (!PHPhasValue(PHPthis.package_price, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.package_price, PHPthis.package_price.value, "Please enter Price")) 
		{
			PHPthis.package_price.focus();
			return false; 
		}
		
	}
	
	 var inpVal = parseInt(PHPthis.package_price.value, 10);
       if (isNaN(inpVal)) 
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a number only.";
		document.getElementById('mess').scrollIntoView();
		   
			return false; 
		}
	if  (!PHPhasValue(PHPthis.package_min_pay, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.package_min_pay, PHPthis.package_min_pay.value, "Please enter Package Minimum Payment")) 
		{
			PHPthis.package_min_pay.focus();
			return false; 
		}
		
	}	
		
		var inpVal = parseInt(PHPthis.package_min_pay.value, 10);
       if (isNaN(inpVal)) 
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a number only.";
		document.getElementById('mess').scrollIntoView();           
		  
			return false; 
		}
	
}

function PHPcheckTracker(PHPthis)
{
	
	if(PHPthis.frommonth.value=="" || PHPthis.fromday.value=="" || PHPthis.fromyear.value=="")
	{
		
		 document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Correct From Date";
		document.getElementById('mess').scrollIntoView(); 
		
		return false; 
	}
	
	if(PHPthis.tomonth.value=="" || PHPthis.today.value=="" || PHPthis.toyear.value=="")
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Correct To Date";
		document.getElementById('mess').scrollIntoView(); 
		return false; 
	}	
	
		
}


function PHPcheckDiscount(PHPthis)
{
	if  (!PHPhasValue(PHPthis.offertype, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.offertype, PHPthis.offertype.value, "Please select Offer Type")) 
		{
			PHPthis.offertype.focus();
			return false; 
		}
	}	
	if(document.getElementById('offertype').value==4){
		if(document.getElementById('title').value=="")
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Title";
		document.getElementById('mess').scrollIntoView(); 
			return false; 
		}
		
	}
	if(PHPthis.offertype.value!=1){
		if(document.getElementById('pcode').value=="")
		{
			document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Promotional Code";
		document.getElementById('mess').scrollIntoView(); 
			return false; 
		}
	}
	if(document.getElementById('amtypetext').value=="") {
		 document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please select the active Offer type";
		document.getElementById('mess').scrollIntoView(); 
		return false; 
	}
	if(document.getElementById('amtypetext').value==1 && document.getElementById('percentage').value=="") 
	{
		 document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Percentage for Offer";
		document.getElementById('mess').scrollIntoView(); 
		return false; 	

		if(document.getElementById('percentage').value!="") {
		  var inpVal = parseInt(PHPthis.percentage.value, 10);
	       if (isNaN(inpVal)) 
			{
	            document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter a number only.";
			document.getElementById('mess').scrollIntoView(); 
				
				return false; 
			}
		}
	}	
	if(document.getElementById('amtypetext').value==2 && document.getElementById('fixamount').value=="") 
	{
		 document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Fixed Amount for Offer";
		document.getElementById('mess').scrollIntoView(); 
		return false; 		
	}
	
	
	if(PHPthis.frommonth.value=="" || PHPthis.fromday.value=="" || PHPthis.fromyear.value=="")
	{
		
		 document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Correct From Date";
		document.getElementById('mess').scrollIntoView(); 
		
		return false; 
	}
	
	if(PHPthis.tomonth.value=="" || PHPthis.today.value=="" || PHPthis.toyear.value=="")
	{
		document.getElementById('mess').innerHTML="<img src='./images/error.gif' border='0'>&nbsp;&nbsp;Please enter Correct To Date";
		document.getElementById('mess').scrollIntoView(); 
		return false; 
	}	
	if(doDateCheckDiscount(PHPthis)=="not correct")
	{
		return false;
	}
	if  (!PHPhasValue(PHPthis.package_discount, "TEXT" )) 
	{
		if  (!PHPonError_new(PHPthis, PHPthis.package_discount, PHPthis.package_discount.value, "Please enter Package")) 
		{
			PHPthis.package_discount.focus();
			return false; 
		}
		
	}
		
}


function checkEmail(myForm) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.email.value))
	{
		return true;
	}
	return false;
}
function checkEmail1(myForm) 
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.youremail.value))
	{
		return true;
	}
	return false;
}

function faq(linkto) {

var faqheight = 350;

var faqwidth = 450;

var windowheight = screen.availHeight;

var windowwidth = screen.availWidth;

var contacttop = (windowheight - faqheight)/2;

var contacleft = (windowwidth - faqwidth)/2;

var attr = "location=no";

attr+= ",status=no";

attr+= ",scrollbars=yes";

attr+= ",resizable=no";

attr+= ",width=" + faqwidth;

attr+= ",height=" + faqheight;

attr+= ",screenX=" + contacleft;

attr+= ",screenY=" + contacttop;

attr+= ",titlebar=yes";

window.open("http://www.clientracker.com/docs/faq.php#" + linkto,"faqpop",attr);

}



function phoneformat (usertel) {

if( (usertel.value != "") && (/[0-9]{3}-[0-9]{3}-[0-9]{4}/i.exec(usertel.value) > -1) ) {

window.alert("The phone number must be in this format: 123-456-7890.\n");

usertel.focus();

return;

}

}

function dateformat (userdate) {

if( (userdate.value != "") && (/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/i.exec(userdate.value) > -1) ) {

window.alert("The date must be entered in this format: mm/dd/yyyy.\n");

userdate.focus();

return;

}

}

function doDateCheck(PHPthis) 
{
	var fromdate=PHPthis.frommonth.value+"/"+PHPthis.fromday.value+"/"+PHPthis.fromyear.value;
	var todate=PHPthis.tomonth.value+"/"+PHPthis.today.value+"/"+PHPthis.toyear.value;
	if (Date.parse(fromdate) >= Date.parse(todate)) 
	{
		alert("To date must occur after the from date.");
		PHPthis.frommonth.focus();
		return false;
		
	}

}

function doDateCheckDiscount(PHPthis) 
{
	var fromdate=PHPthis.frommonth.value+"/"+PHPthis.fromday.value+"/"+PHPthis.fromyear.value;
	var todate=PHPthis.tomonth.value+"/"+PHPthis.today.value+"/"+PHPthis.toyear.value;

	if (Date.parse(fromdate) >= Date.parse(todate)) 
	{
		alert("To date must occur after the from date.");
		PHPthis.frommonth.focus();
		return "not correct";
		
	}
	else 
	{
		return "correct";
	}

}


function popitup(url) {
	newwindow=window.open(url,'name','menubar=1,resizable=no,width=900,height=400');
	if (window.focus) {newwindow.focus()}
	return false;
}

