
//Testing save
function doPickupValidation() {
	
	var form = document.forms[1];
	var isvalid = true;

	//***********************
	//Saturday & Sunday check
	//***********************
    if(form.pickupdate.value.length == 10)
	{	
		var thisDay = new Date(form.pickupdate.value);
		var x = thisDay.getDay();
		//alert(x);
		if(x == 0 || x == 6)
		{
			alert("Date entered was either a Saturday or Sunday. Please select a different date.");
			form.pickuptimehr.focus();
			isvalid = false;
			return;
		}
	}//end 	

	//**********************************************
	//validate that there is a name contact section
	//**********************************************
	val_fn=form.reqname.value;
	if (val_fn.length >= 1) {
		// test for invalid characters
		if (isEmptyTest(val_fn) ||  isNumber(val_fn)) {
			alert("You must provide your name using only letters or numbers.");
			if (isvalid == true) {
				form.reqname.focus();
				isvalid = false;
				return;		
			}
		}
	} else {
		alert("You must provide your name.");
		if (isvalid == true) {
			form.reqname.focus();
			isvalid = false;
			return;		
		}
	}
	
	//Check email field is not blank
	//form.ccemail.value = form.reqaddemail.value;
	form.ccemail.value = '';
	form.toemail.value = form.reqemail.value;
	
	if (form.toemail.value == ""){
		alert("Please enter a valid e-mail address.");
		if (isvalid == true) {
			form.reqemail.focus();
			isvalid = false;
			return;
		}
	}
	//Use format checker
	//if (!emailCheck(form.toemail.value)) {
	//	if (isvalid == true) {
	//			form.reqemail.focus();
	//		isvalid = false;
	//		return;
	//	}
	//}
	
	//test
	val_pikupext = form.reqext.value;
	val_reqcomp = form.reqcompext.value;

	//check phone is not blank
	//Validation for Req. phone
	if (form.reqphone1.value == "" || form.reqphone2.value == "" || form.reqphone3.value == "" ){
	    alert("Please enter your Phone  number.");
		if (isvalid == true) {
			form.reqphone1.focus();
			isvalid = false;
			return;
		}
	}	

	//Validate length and numeric for individual parts
	val_phone1 = form.reqphone1.value;
	val_phone2 = form.reqphone2.value;
	val_phone3 = form.reqphone3.value;
  	if (val_phone1.length < 3 || !isNumber(val_phone1)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqphone1.focus();
			isvalid = false;
			return;
		}
	} else {
		//validate that the area code starts with at least a 1
		var areaCodeTest = parseInt(val_phone1);
		if (!isNaN(areaCodeTest)) {
			if ( areaCodeTest < 100) {
				alert("Please enter a valid phone number.");
				if (isvalid == true) {
					form.reqphone1.focus();
					isvalid = false;
					return;
				}
			}
		}
	}
	if (val_phone2.length < 3 || !isNumber(val_phone2)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqphone2.focus();
			isvalid = false;
			return;
		}
	}
	if (val_phone3.length < 4 || !isNumber(val_phone3)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqphone3.focus();
			isvalid = false;
			return;
		}
	}


	//validate that there is a Request-company name
	val_fn=form.reqcompany.value;
	
	if (val_fn.length >= 1) {
		if (isEmptyTest(val_fn) ||  isNumber(val_fn)) {
			alert("You must provide your Company name using only letters or number.");
			if (isvalid == true) {
				form.reqcompany.focus();
				isvalid = false;
				return;			
			}
		}
	} else {
		alert("You must provide your Company name.");
		if (isvalid == true) {
			form.reqcompany.focus();
			isvalid = false;
			return;			
		}
	}


	//validate that there is a Request-address
	val_add=form.reqaddress.value;
	if (val_add == "") {
		alert("You must provide your Address.")
		if (isvalid == true) {
			form.reqaddress.focus();
			isvalid = false;
			return;
		}
	} else {
		if (val_add.length > 30) {
			alert("Address must be less than 30 characters in length.");
			if (isvalid == true) {
				form.reqaddress.focus();
				isvalid = false;
				return;
			}			
		}
	}


	//validate that there is a Request-city
	val_reqcity =form.reqcity.value;
	if (val_reqcity == "") {
		alert("You must provide your City.")
		if (isvalid == true) {
			form.reqcompphone1.focus();
			isvalid = false;
			return;
		}
	}


	//Validate that there is Req-Comp phone
	if (form.reqcompphone1.value =="" || form.reqcompphone2.value == "" || form.reqcompphone3.value == "" ){
		alert("Please enter your Phone  number.");
		if (isvalid == true) {
			form.reqcompphone1.focus();
			isvalid = false;
			return;
		}
	}	

	//Validate length and numeric for individual parts
	val_phone1 = form.reqcompphone1.value;
	val_phone2 = form.reqcompphone2.value;
	val_phone3 = form.reqcompphone3.value;
	if (val_phone1.length < 3 || !isNumber(val_phone1)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqcompphone1.focus();
			isvalid = false;
			return;
		}
	}else {
		//validate that the area code starts with at least a 1
		var areaCodeTest = parseInt(val_phone1);
		if (!isNaN(areaCodeTest)) {
			if ( areaCodeTest < 100) {
				alert("Please enter a valid phone number.");
				if (isvalid == true) {
					form.reqcompphone1.focus();
					isvalid = false;
					return;
				}
			}
		}
	}
	if (val_phone2.length < 3 || !isNumber(val_phone2)){

		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqcompphone2.focus();
			isvalid = false;
			return;
		}
	}
	if (val_phone3.length < 4 || !isNumber(val_phone3)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.reqcompphone3.focus();
			isvalid = false;
			return;
		}
	}


	//validate that extenstion is a number
	if (form.reqcompext.value != '') {
		if (!isNumber(form.reqcompext.value)) {
			alert("Please enter a valid extension number that contains only a numeric value.");
			if (isvalid == true) {
				form.reqcompext.focus();
				isvalid = false;
				return;
			}
		}
	} else {
		form.reqcompext.value = '0';
	}
	
	if (form.pickcompext.value != '') {
		if (!isNumber(form.pickcompext.value)) {
			alert("Please enter a valid extension number that contains only a numeric value.");
			if (isvalid == true) {
				form.pickcompext.focus();
				isvalid = false;
				return;
			}
		}
	}else {
		form.pickcompext.value = '0';
	}


	//validate that there is a PickLoc-company name
	val_fn=form.pickloccompany.value;
	
	if (val_fn.length >= 1) {
		if (isEmptyTest(val_fn) ||  isNumber(val_fn)) {
			alert("You must provide your Company name using only letters or numbers.");
			if (isvalid == true) {
				form.pickloccompany.focus();
				isvalid = false;
				return;	
			}
		}	
	} else {
		alert("You must provide your Company name.");
		if (isvalid == true) {
			form.pickloccompany.focus();
			isvalid = false;
			return;	
		}
	}

	//validate that there is a Request-address
	val_add=form.picklocaddress.value;
	if (val_add == "") {
		alert("You must provide your Address.")
		if (isvalid == true) {
			form.picklocaddress.focus();
			isvalid = false;
			return;
		}
	} else {
		if (val_add.length > 30) {
			alert("Address must be less than 30 characters in length.");
			if (isvalid == true) {
				form.picklocaddress.focus();
				isvalid = false;	
				return;
			}			
		}
	}


	//validate that there is a Pickup-city
	
	val_pickcity =form.pickloccity.value;
	if (val_pickcity == "") {
		alert("You must provide your City.")
		if (isvalid == true) {
			form.pickcompphone1.focus();
			isvalid = false;
			return;
		}
	}

	//check phone is not blank
	//Validation for Req. phone
	if (form.pickcompphone1.value =="" || form.pickcompphone2.value == "" || form.pickcompphone3.value == "" ){
		alert("Please enter your Phone  number.");
		if (isvalid == true) {
			form.pickcompphone1.focus();
			isvalid = false;	
			return;
		}
	}	

	val_phone1 = form.pickcompphone1.value;
	val_phone2 = form.pickcompphone2.value;
	val_phone3 = form.pickcompphone3.value;
	if (val_phone1.length < 3 || !isNumber(val_phone1)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.pickcompphone1.focus();
			isvalid = false;
			return;
		}
	}else {
		//validate that the area code starts with at least a 1
		var areaCodeTest = parseInt(val_phone1);
		if (!isNaN(areaCodeTest)) {
			if ( areaCodeTest < 100) {
				alert("Please enter a valid phone number.");
				if (isvalid == true) {
					form.pickcompphone1.focus();
					isvalid = false;
					return;
				}
			}
		}
	}
	if (val_phone2.length < 3 || !isNumber(val_phone2)){

		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.pickcompphone2.focus();
			isvalid = false;
			return;
		}
	}
	if (val_phone3.length < 4 || !isNumber(val_phone3)){
		alert("Please enter a valid phone number.");
		if (isvalid == true) {
			form.pickcompphone3.focus();
			isvalid = false;
			return;
		}
	}

	// Make sure Pickup Date is not blank
	if (form.pickupdate.value == "" ){
		alert("Please enter the Pickup date.");
		if (isvalid == true) {
			form.reqphone1.focus();
			isvalid = false;
			return;
		}
	}



	//====================================================================================
	// Make sure Pickup Date >= Today
	//============================================
	if(form.pickupdate.value.length == 10) {
		var pickupDate = form.pickupdate.value ;
		if(isLessThanToday(pickupDate))
		{
		   alert("Entered date cannot be less than today's date");
				form.pickuptimehr.focus();
				isvalid = false;
				return;
		}
	} 

	// checking if pickup date is not Greater Than  30days.
	if(form.pickupdate.value.length == 10) {
		var pickupDate = form.pickupdate.value ;
		if(days_between(pickupDate))
		{
		   alert("Pickup Date can not be greater than 30 days. Please select a different date.");
				form.pickuptimehr.focus();
				isvalid = false;
				return;
		}
	} 


	//Before validating Time, Switch out Midnight and Noon
	convertNoonMidnight(form);
	

	//Make sure Pickup time and Dock Close time has 2 hrs. window
	if(form.pickuptimehr.value.length == 5){
		var pickuptimehourmin = form.pickuptimehr.value ;
		var pickuptimeampm = form.pickuptimeam.value ;
		var pickupTime =  pickuptimehourmin + pickuptimeampm;	
		var closetimehourmin = form.docclosehr.value ;
		var closetimeampm = form.doccloseam.value ;
		var doccloseTime = closetimehourmin + closetimeampm ;
	
		if(compareTimes(doccloseTime, pickupTime) < 0){
			alert("Pickup time cannot be greater than Dock close time.");
			form.pickuptimehr.focus();
			convertNoonMidnightBack(form);
			isvalid = false;
			return;	
		}
	
		//If Pickup time is > than close time
		if(compareTimes(doccloseTime, pickupTime) < 120){
			alert("We require at least a 2 hour pickup window between the time your shipment is ready and the latest time we make a pickup.");
			form.pickuptimehr.focus();
			convertNoonMidnightBack(form);
			isvalid = false;
			return;	
		}
	} else { 
		alert("Please select the Pickup Time.");
			form.pickuptimehr.focus();
			convertNoonMidnightBack(form);
			isvalid = false;
			return;	
	}

	
	//Pickup Time validatin
	if (form.pickuptimehr.value == 0 ){
		alert("Please enter the Pickup Time.");
		if (isvalid == true) {
			form.reqphone1.focus();
			convertNoonMidnightBack(form);
			isvalid = false;	
			return;
		}
	}

	//Testing for Warning msg.
	var myString  = form.pickuptimehr.value;
	var newString = myString.substring(1,2);
	var elevenCheck = myString.substring(0,2);
	var newMidnight = myString.substring(0,2);


	//Pickup AM/PM validatin
	if (form.pickuptimeam.value == 0 ){
		alert("Please select AM or PM.");
	
		if (isvalid == true) {
			form.pickuptimeam.focus();
			convertNoonMidnightBack(form);
			isvalid = false;	
			return;
		}
	}

	//Dock Close validation
	if (form.docclosehr.value == 0 ){
		alert("Please enter the Dock Close Time.");
	
		if (isvalid == true) {
			form.docclosehr.focus();
			convertNoonMidnightBack(form);
			isvalid = false;
			return;
		}
	}	


	//Dock AM/PM validatin
	if (form.doccloseam.value == 0 ){
		alert("Please select AM or PM.");
	
		if (isvalid == true) {
			form.doccloseam.focus();
			convertNoonMidnightBack(form);
			isvalid = false;	
			return;
		}
	}
	
	convertNoonMidnightBack(form);



	//****************************
	//Shipment Detail validations
	//****************************
	if (form.detaildestzip[0].value.length == 0) {
		alert("Please enter at least one line item.");
		if (isvalid == true) {
			form.detaildestzip[0].focus();
			isvalid = false;
			return;
		}
	}

	//Validate Shipment details
	for (var i=0;i<form.detaildestzip.length;i++){
	   
		if (form.detaildestzip[i].value.length > 0 && form.detaildestzip[i].value.length < 5) {
			alert("Please enter at least 5 characters length.");
			if (isvalid == true) {
			    form.detaildestzip[i].focus();
			    isvalid = false;
			    return;
			}
		}
	
		// this is not the first row
		if (form.detaildestzip[i].value.length == 0) {
			if(form.detailtothandunit[i].value.length > 0 || form.detailhandunittype[i].selectedIndex > 0 || form.detailhandunitweight[i].length > 0){
				alert("Please enter a zip, or empty other shipment fields.");
				if (isvalid == true) {
		    		form.detaildestzip[i].focus();
		    		isvalid = false;
		    		return;
				}
			}
		}
	   
		// check detailtothandunit
		if (form.detailtothandunit[i].value.length == 0){
			if(form.detaildestzip[i].value.length > 0 || form.detailhandunittype[i].selectedIndex > 0 || form.detailhandunitweight[i].length > 0){
				alert("Please enter handling units , or empty other shipment fields.");
				if (isvalid == true) {
				    form.detailtothandunit[i].focus();
				    isvalid = false;
				    return;
				}
			}
		}
	
		// check detailhandunittype
		if (form.detailhandunittype[i].selectedIndex == 0) {
			if(form.detaildestzip[i].value.length > 0 || form.detailtothandunit[i].value.length > 0 || form.detailhandunitweight[i].length > 0){
				alert("Please enter a handling unit type , or empty other shipment fields.");
				if (isvalid == true) {
				    form.detailhandunittype[i].focus();
				    isvalid = false;
				    return;
				}
			}
		}
	
		// check detailhandunitweight
		if (form.detailhandunitweight[i].value.length == 0) {
			if(form.detaildestzip[i].value.length > 0 || form.detailtothandunit[i].value.length > 0 || form.detailhandunittype[i].selectedIndex > 0){
				alert("Please enter weight value, or empty other shipment fields.");
				if (isvalid == true) {
				    form.detailhandunitweight[i].focus();
				    isvalid = false;
				    return;
				}
			}
		} else {
			try {
				var f = "" + parseFloat(form.detailhandunitweight[i].value);
				//alert(f);
				if(f.indexOf("NaN")>=0){
					alert("Please enter proper weight value.");
			    	if (isvalid == true) {
			      		form.detailhandunitweight[i].focus();
			      		isvalid = false;
			      		return;
			    	}
		  		}
			} catch(e){
		    	alert("Please enter proper weight value.");
			    if (isvalid == true) {
			      form.detailhandunitweight[i].focus();
			      isvalid = false;
			      return;
			    }
	       }
	   }
	}// end for
		
	

	//Start Validation for CHECK BOXES--abb

	//1. Shipment Detail--Hazmat
	for(var i=0;i<form.detaildestzip.length;i++){
	    if (form.detailhazmatchk[i].checked == true ){
			form.detailhazmat[i].value = 'Y';
	    }else{
			form.detailhazmat[i].value = 'N';
	    } 
	}

	//2. Additional Options-- Private Res.
	if (form.privaterespickupchk.checked == true ){
		form.privaterespickup.value = 'Y';
	} else{
		form.privaterespickup.value = 'N';
	}

	//3. Additional Options--Insidepickup.
	if (form.insidepickupchk.checked == true ){
		form.insidepickup.value = 'Y';
	} else{
		form.insidepickup.value = 'N';
	}
	
	//4. Additional Options-- limited
	if (form.limitedaccpickupchk.checked == true ){
		form.limitedaccpickup.value = 'Y';
	} else{
		form.limitedaccpickup.value = 'N';
	}

	//5. Additional Options--Liftgate
	if (form.liftgaterequiredchk.checked == true ){
		form.liftgaterequired.value = 'Y';
	}else{
		form.liftgaterequired.value = 'N';
	}
	
	//6. Additional Options-- Oversize
	if (form.oversizechk.checked == true ){
		form.oversize.value = 'Y';
	}  else{
		form.oversize.value = 'N';
	}

	//7. Additional Options-- freezable
	if (form.freezablechk.checked == true ){
		form.freezable.value = 'Y';
	}else{
		form.freezable.value = 'N';
	}

	//8. Additional Options-- Food
	if (form.foodchk.checked == true ){
		form.food.value = 'Y';
	} else{
		form.food.value = 'N';
	}

	//9. Additional Options-- Poison
	if (form.poisonchk.checked == true ){
		form.poison.value = 'Y';
	}else{
		form.poison.value = 'N';
	}
	//End CHECK BOX Validations


	// start radio buttons
	if (form.reqtype[0].checked == true ){
		form.reqtype.value = 'S';
	}else if (form.reqtype[1].checked == true ){
		form.reqtype.value = 'C';
	} else {
		form.reqtype.value = 'T';
	}

	// reqcountry 
	if (form.reqcountry[0].checked == true ){
		form.reqcountry.value = 'US';
	}else if (form.reqtype[1].checked == true ){
		form.reqcountry.value = 'CA';
	} 

	// pickloccountry 
	if (form.pickloccountry[0].checked == true ){
		form.pickloccountry.value = 'US';
	}else if (form.pickloccountry[1].checked == true ){
		form.pickloccountry.value = 'CA';
	}	 
	//end radio buttons

	//If all went ok, submit it.
	if (isvalid == true) {
		convertNoonMidnight(form);
		form.pickupSubmit.disabled = true;
		form.submit();
	}	
}  //end function doValidation


function doPickupValidation1() {
	form.submit();
}

//Start IsNumer Function
function isNumber(entry) {
    //alert("isNumber() Called");
    validChar='0123456789'; // characters allowed
    strlen=entry.length;          // how long is test string
    if (strlen < 1) {
    	return false;
    } // no check!
    // Now scan string for illegal characters
    for (i=0; i < strlen; i++ ) {
        if (validChar.indexOf(entry.charAt(i)) < 0) {
            return false;
        }
    }
    //alert("returning true");
    return true;

}//end IsNumber

function isEmpty(val)
{
    strlen=val.length;          // how long is test string
    if (strlen < 1) {return true;} // check for string length
    if(val.indexOf(" ")>=0){return true;} // check for blank char
    if(val.indexOf("$")>=0){return true;} // check for $
    if(val.indexOf("%")>=0){return true;} // check for %	
    if(val.indexOf("/")>=0){return true;} // check for /
    if(val.indexOf("*")>=0){return true;} // check for *
    if(val.indexOf("!")>=0){return true;} // check for !
    if(val.indexOf("#")>=0){return true;} // check for #
    if(val.indexOf("^")>=0){return true;} // check for ^
    if(val.indexOf("&")>=0){return true;} // check for &
    if(val.indexOf("(")>=0){return true;} // check for (
    if(val.indexOf(")")>=0){return true;} // check for )
    if(val.indexOf("[")>=0){return true;} // check for [
    if(val.indexOf("]")>=0){return true;} // check for ]
    if(val.indexOf("{")>=0){return true;} // check for {
    if(val.indexOf("}")>=0){return true;} // check for }
	//var illegalChars = /\W/;
  	// allow only letters, numbers, and underscores
   // if (illegalChars.test(val)) {
       //error = "The username contains illegal characters.\n";
      // return true;
  //  }
    return false;
}

function ClearContactInfo()

{
	//alert("in clear func");
	frm = document.forms[1];

if (frm.cinfo.checked == true) {
	document.frm.reqname.value = "none";
}else{
//alert("heeeeeeeeeeeeeeeey");
}

}

function isEmptyTest(val)
{
    strlen=val.length;          // how long is test string
    if (strlen < 1) {return true;} // check for string length
   //if(val.indexOf(" ")>=0){return true;} // check for blank char
    if(val.indexOf("$")>=0){return true;} // check for $
    if(val.indexOf("%")>=0){return true;} // check for %	
    if(val.indexOf("/")>=0){return true;} // check for /
    if(val.indexOf("*")>=0){return true;} // check for *
    if(val.indexOf("!")>=0){return true;} // check for !
    if(val.indexOf("#")>=0){return true;} // check for #
    if(val.indexOf("^")>=0){return true;} // check for ^
    //if(val.indexOf("&")>=0){return true;} // check for &
    if(val.indexOf("(")>=0){return true;} // check for (
    if(val.indexOf(")")>=0){return true;} // check for )
    if(val.indexOf("[")>=0){return true;} // check for [
    if(val.indexOf("]")>=0){return true;} // check for ]
    if(val.indexOf("{")>=0){return true;} // check for {
    if(val.indexOf("}")>=0){return true;} // check for }
	//var illegalChars = /\W/;
  	// allow only letters, numbers, and underscores
   // if (illegalChars.test(val)) {
       //error = "The username contains illegal characters.\n";
      // return true;
  //  }
    return false;
}

function isEmpty1(entry) {
    validChar='/^s+$/'; // characters allowed
    strlen=entry.length;          // how long is test string
    if (strlen < 1) {return true;} // no check!
    if(entry.indexOf(" ")>=0){return true;}

    // Now scan string for illegal characters--
    for (i=0; i < strlen; i++ ) {
        if (validChar.indexOf(entry.charAt(i) ) > 0) {
            return false;
        }
    }
    return true;

}


//Functions for Date and Time(Ready and Close) validations




function compareTimes(time1, time2)
{
	var date1 = new Date();
	var date2 = new Date();
	var hh1 = parseInt(time1.substring(0,2),10);
	var mm1 = parseInt(time1.substring(3,5),10);
	var am1 = time1.substring(5);
	if(am1 == "PM") {
		if(hh1 != 12 ){
			hh1 += 12;	
		}
		//else{
		//	hh1 = 12;
		//	mm1 = 59;
		//}
	}
	date1.setHours(hh1,mm1,0);
	
	var hh2 = parseInt(time2.substring(0,2),10);
	var mm2 = parseInt(time2.substring(3,5),10);
	var am2 = time2.substring(5);
	if(am2 == "PM") {
		if(hh2 != 12 ){
			hh2 += 12;	
		}
		//else {
		//	hh2 = 12;
		//	mm2 = 59;
		//}
	}
	date2.setHours(hh2,mm2,0);
	
	//alert("date1="+ date1.getTime() + ",date2=" + date2.getTime());
	var diff = date1.getTime() - date2.getTime();
	diff = diff/(1000*60);
	return diff;
	
}
	/** returns time in milliseconds from epoch give a date in mm/dd/yyyy format.
		today is the Date object passed to get the correct time hh, mm, ss, milliseconds	
	*/	
	function getEpochTime(enteredDt,today) {
		if(enteredDt.length == 10 ) 
		{
			 var mm = parseInt(enteredDt.substring(0,2),10) - 1;
			 var dd = parseInt(enteredDt.substring(3,5),10);
			 var yyyy = parseInt(enteredDt.substring(6),10);
			 //alert("mm" + mm + ",dd=" + dd + ",yyyy=" + yyyy); 
			 var enteredDtObj = new Date();
			 enteredDtObj.setDate(dd);
			 enteredDtObj.setMonth(mm);
			 enteredDtObj.setFullYear(yyyy);
			 enteredDtObj.setHours(today.getHours());
			 enteredDtObj.setMinutes(today.getMinutes());
			 enteredDtObj.setSeconds(today.getSeconds());
			 enteredDtObj.setMilliseconds(today.getMilliseconds());		 
			 var enteredTime = enteredDtObj.getTime();
			 //alert("entered time = " + enteredTime);		 
			 return enteredTime; 
		}
	}

	/** gets a date in mm/dd/yyyy format and compares with the today's date and returns 
	 * true if entered date is greater than todays date.
	*/	
	function isLessThanToday(enteredDt) {
		var today = new Date();




		var todayTime = today.getTime();
		var enteredTime = getEpochTime(enteredDt,today);	
		//alert("enteredTime=" + enteredTime + ",todayTime=" + todayTime);	 
		if(enteredTime<todayTime){
		   		return true;
		 } else {	
			 	return false; 
		 }
	}


//Start email validation

function emailCheck (emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Email address seems incorrect (check @ and .'s)");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("The username doesn't seem to be valid.");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("This address is missing a hostname!");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

//  End -->Email validation

//****************Testing 30days	

function days_between(pkdate) {

    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;

	var today = new Date();

	var ETime = getEpochTime(pkdate,today);

    // Convert both dates to milliseconds
    var today_ms = today.getTime();
    //var pkdate_ms = pkdate.getTime();

    // Calculate the difference in milliseconds
   // var difference_ms = Math.abs(today_ms - pkdate_ms);
 	var difference_ms = Math.abs(today_ms - ETime);
    
    // Convert back to days and return
    var abba =  Math.round(difference_ms/ONE_DAY);


	if(abba > 30){
		   		return true;
		 } else {	
			 	return false; 
		 }


} //end days_between





















function lala()

{

// Store the current date and time
var current_date = new Date()

// Store the date of the next New Year's Day
var new_years_date = new Date()
new_years_date.setYear(new_years_date.getFullYear() + 1)
new_years_date.setMonth(1)
new_years_date.setDate(1)

// Call the days_between function
var days_left = days_between(current_date, new_years_date)

// Write the result to the page
if (days_left > 1) {
   alert("There are=" + days_left);
}
else {
    alert("There is=" + days_left);
}

}//end lala

function convertNoonMidnight(form) {
	if (form.pickuptimehr.value == "Noon") {
		form.pickuptimehr.value = "12:00";
		form.pickuptimeam.value = "AM";
	} else if (form.pickuptimehr.value == "Midnight") {
		form.pickuptimehr.value = "12:00";
		form.pickuptimeam.value = "PM";
	}
	
	if (form.docclosehr.value == "Noon") {
		form.docclosehr.value = "12:00";
		form.doccloseam.value = "AM";
	} else if (form.docclosehr.value == "Midnight") {
		form.docclosehr.value = "12:00";
		form.doccloseam.value = "PM";
	}
}

function convertNoonMidnightBack(form) {
	if (form.pickuptimehr.value == "12:00") {
		if (form.pickuptimeam.value == "AM") {
			form.pickuptimehr.value = "Noon";
			form.pickuptimeam.value = "0";
		} else {
			form.pickuptimehr.value = "Midnight";
			form.pickuptimeam.value = "0";
		}
	}
	
	if (form.docclosehr.value == "12:00") {
		if (form.doccloseam.value == "AM") {
			form.docclosehr.value = "Noon";
			form.doccloseam.value = "0";
		} else {
			form.docclosehr.value = "Midnight";
			form.doccloseam.value = "0";
		}
	}

}
