function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_displayStatusMsg(msgStr) { //v1.0
  status=msgStr;
  document.MM_returnValue = true;
}
var aCh="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var dCh="0123456789-";
var sCh="ÀÂÃÄÅÆÇÈÉÊËÌÍÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿŠŒŽšœžŸ'_`~()^&*+-|=<>,./\{}[] ";
var asCh=aCh + dCh + "!\"#$%&'()*+,-./:;<=>?@[\]^_`{}~";

function isAlphaNum(S) {
	var AlphaNum=aCh + dCh;
	for (var i=0; i < S.length; i++) {
		if (AlphaNum.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isASCII(S) {
	for (var i=0; i < S.length; i++) {
		if (asCh.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isName(S) {
	var cName=aCh + dCh + sCh;
	for (var i=0; i < S.length; i++) {
		if (cName.indexOf(S.charAt(i)) == -1)
			return false;
	}
	return true;
}
function isEmail(S) {
	var pass=0;
	if (window.RegExp) {
		var tempS="a";
		var tempReg=new RegExp(tempS);
		if (tempReg.test(tempS)) pass=1;
	}
	if (!pass)
		return (S.indexOf(".") > 2) && (S.indexOf("@") > 0);

	var r1=new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2=new RegExp("^[a-zA-Z0-9\\.\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]*[a-zA-Z0-9\\!\\#\\$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\_\\`\\{\\}\\~]\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(S) && r2.test(S));
}
function stripNonNumeric( str ) {
	str += '';
	var rgx = /^\d|\.|-$/;
	var out = '';
	for( var i = 0; i < str.length; i++ ) {
		cDigit = str.charAt(i);
		if( rgx.test( cDigit ) ){
			if( !( ( cDigit == '.' && out.indexOf( '.' ) != -1 ) || ( cDigit == '-' && out.length != 0 ) ) ){
				out += cDigit;
			}
		}
	}
	return out;
}
function CheckNumeric(obj) {
	if (obj.value=="") obj.value=0;
	else if (isNaN(obj.value)){
		obj.value=stripNonNumeric(obj.value);
		if (obj.value.length==0) obj.value=0;
	}else if (obj.value<0) obj.value=-obj.value;
}
function DisableSubmit(cText) {
	dml = document.EntryForm;
	dml.btnSubmit.disabled=true;
	dml.btnSubmit.value=cText;
	dml.submit();
}
function EnableSubmit(cText){
	dml = document.EntryForm;
	dml.btnSubmit.disabled=false;
	dml.btnSubmit.value=cText;
}
//Function to trim the space in the left side of the string
function ltrim ( s ){
  return s.replace( /^\s*/, "" );
}
//Function to trim the space in the right side of the string
function rtrim ( s ){
   return s.replace( /\s*$/, "" );
}
//*Function to trim the space in the  string
function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}
function ConfirmDelete(url,cItem){
	var answer = confirm("Do you want to delete "+cItem+" ?");
	if (answer)
		document.location.href = url;
}

function checkForm() {
	var d = document.DataEntry;
	// Check Real Name
	cNameError = "";
	if (d.Name.value.length <1) {
	 cNameError = "Your Name is empty.\n";
	 }	else { 
		 if (d.Name.value.length <4) {
		 cNameError = "Name should be at least 4 characters.\n";
		 }
	 }
	
	// Check the email
	cEmailError = "";
	if (d.Email.value.length <1) { 
		cEmailError = "Your Email address is empty.\n";
	}	
	else { 
		dmn = d.Email.value.substr(d.Email.value.indexOf("@")+1,d.Email.value.length);
		if((d.Email.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			cEmailError = "Your email address is invalid.\ne.g. : (email@domainname.com).\n";
		}
	}
	
		// Check Street
	cStreetError = "";
	if (d.Street.value.length <1) { cStreetError = "Your Street or P.O. Box is empty.\n"; }
		
		// Check City
	cCityError = "";
	if (d.City.value.length <1) { cCityError = "Your City is empty.\n"; }

		// Check State
	cStateError = "";
	if (d.State.value.length <1) { cStateError = "Your State is empty.\n"; }

		// Check Postal
	cPostalError = "";
	if (d.Postal.value.length <1) { cPostalError = "Your Postal Code is empty.\n"; }

		// Check Country
	cCountryError = "";
	if (d.Country.value.length <1) { cCountryError = "Your Country is empty.\n"; }

		// Check Telephone
	cTelephoneError = "";
	if (d.Telephone.value.length <1) { cTelephoneError = "Your Telephone is empty.\n"; }

		// Check Method of Payment
	cMethodofPaymentError = "";
	if (d.MethodofPayment.value.length <1) { cMethodofPaymentError = "Your Method of Payment is empty.\n"; }

		// Check Credit Card Type
	cCreditCardTypeError = "";
	if (d.CreditCardType.value.length <1) { cCreditCardTypeError = "Your Credit Card Type is empty.\n"; }

		// Check CreditCardNumber
	cCreditCardNumberError = "";
	if (d.CreditCardNumber.value.length <1) { cCreditCardNumberError = "Your Credit Card Number is empty.\n"; }

		// Check Expiration Date Month
	cExpirationMonthError = "";
	if (d.ExpirationMonth.value.length <1) { cExpirationMonthError = "Your Expiration Date Month is empty.\n"; }

		// Check Expiration Date Year
	cExpirationYearError = "";
	if (d.ExpirationYear.value.length <1) { cExpirationYearError = "Your Expiration Date Year is empty.\n"; }

		// Check NameonCard
	cNameonCardError = "";
	if (d.NameonCard.value.length <1) { cNameonCardError = "Your Name on Card is empty.\n"; }

	
	cError = cNameError + cEmailError + cStreetError + cCityError + cStateError + cPostalError + cCountryError + cTelephoneError + cMethodofPaymentError + cCreditCardTypeError + cCreditCardNumberError + cExpirationMonthError + cExpirationYearError + cNameonCardError ; 
	
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required.\n"+cError); 
		if (cNameError.length>0) { d.Name.focus(); } else {
		if (cEmailError.length>0) { d.Email.focus(); }else {
		if (cStreetError.length>0) { d.Street.focus(); } else {
		if (cCityError.length>0) { d.City.focus(); } else {
		if (cStateError.length>0) { d.State.focus(); } else {
		if (cPostalError.length>0) { d.Postal.focus(); } else {
		if (cCountryError.length>0) { d.Country.focus(); } else {
		if (cTelephoneError.length>0) { d.Telephone.focus(); } else {
		if (cMethodofPaymentError.length>0) { d.MethodofPayment.focus(); } else {
		if (cCreditCardTypeError.length>0) { d.CreditCardType.focus(); } else {
		if (cCreditCardNumberError.length>0) { d.CreditCardNumber.focus(); } else {
		if (cExpirationMonthError.length>0) { d.ExpirationMonth.focus(); } else {
		if (cExpirationYearError.length>0) { d.ExpirationYear.focus(); } else {
		if (cNameonCardError.length>0) { d.NameonCard.focus(); } } } } } } } } } } } } } } 
		return false; 
	}
		if (!d.TermsandConditions.checked) { 
		alert("Please check the confirmation check box.\n");
		return false; 
		}
	d.submit();
}

function checkFormSpa() {
	var d = document.DataEntry;
	// Check Real Name
	cNameError = "";
	if (d.Name.value.length <1) {
	 cNameError = "Your Name is empty.\n";
	 }	else { 
		 if (d.Name.value.length <4) {
		 cNameError = "Name should be at least 4 characters.\n";
		 }
	 }
	
	// Check the email
	cEmailError = "";
	if (d.Email.value.length <1) { 
		cEmailError = "Your Email address is empty.\n";
	}	
	else { 
		dmn = d.Email.value.substr(d.Email.value.indexOf("@")+1,d.Email.value.length);
		if((d.Email.value.indexOf("@")<1) ||(dmn.indexOf("@")>-1) || (dmn.indexOf(".")<1) || (dmn.indexOf(".")>dmn.length-2)) {
			cEmailError = "Your email address is invalid.\ne.g. : (email@domainname.com).\n";
		}
	}
	
		// Check Arrival Day
	cArrivalDayError = "";
	if (d.ArrivalDay.value.length <1) { cArrivalDayError = "Your Arrival Day is empty.\n"; }
		
		// Check Arrival Month
	cArrivalMonthError = "";
	if (d.ArrivalMonth.value.length <1) { cArrivalMonthError = "Your Arrival Month is empty.\n"; }
		
		// Check Arrival Year
	cArrivalYearError = "";
	if (d.ArrivalYear.value.length <1) { cArrivalYearError = "Your Arrival Year is empty.\n"; }
		
		// Check Departure Day
	cDepartureDayError = "";
	if (d.DepartureDay.value.length <1) { cDepartureDayError = "Your Departure Day is empty.\n"; }
		
		// Check Departure Month
	cDepartureMonthError = "";
	if (d.DepartureMonth.value.length <1) { cDepartureMonthError = "Your Departure Month is empty.\n"; }
		
		// Check Departure Year
	cDepartureYearError = "";
	if (d.DepartureYear.value.length <1) { cDepartureYearError = "Your Departure Year is empty.\n"; }
		
		// Check Special Requests
	cSpecialrequestsError = "";
	if (d.Specialrequests.value.length <1) { cSpecialrequestsError = "Your Special Requests is empty.\n"; }
		
		// Check Treatments1
	cTreatments1Error = "";
	if (d.Treatments1.value.length <1) { cTreatments1Error = "Your Treatments is empty.\n"; }
		
		// Check TDate1
	cTDate1Error = "";
	if (d.TDate1.value.length <1) { cTDate1Error = "Your Treatments Date is empty.\n"; }
		
		// Check TMonth1
	cTMonth1Error = "";
	if (d.TMonth1.value.length <1) { cTMonth1Error = "Your Treatments Month is empty.\n"; }
		
		// Check TYear1
	cTYear1Error = "";
	if (d.TYear1.value.length <1) { cTYear1Error = "Your Treatments Year is empty.\n"; }
		
		// Check TDuration1
	cTDuration1Error = "";
	if (d.TDuration1.value.length <1) { cTDuration1Error = "Your Treatments Duration is empty.\n"; }
		
		// Check TMin1
	cTMin1Error = "";
	if (d.TMin1.value.length <1) { cTMin1Error = "Your Treatments Duration Minutes is empty.\n"; }
		
		// Check TApprox1
	cTApprox1Error = "";
	if (d.TApprox1.value.length <1) { cTApprox1Error = "Your Treatments Approx Time is empty.\n"; }
		
 
	cError = cNameError + cEmailError + cArrivalDayError + cArrivalMonthError + cArrivalYearError + cDepartureDayError + cDepartureMonthError + cDepartureYearError + cSpecialrequestsError + cTreatments1Error + cTDate1Error + cTMonth1Error + cTYear1Error + cTDuration1Error + cTMin1Error + cTApprox1Error ;
	if (cError.length>0) { 
		alert("Sorry, but you haven\'t filled out all fields required.\n"+cError); 
		if (cNameError.length>0) { d.Name.focus(); } else {
		if (cEmailError.length>0) { d.Email.focus(); } else {
		if (cArrivalDayError.length>0) { d.ArrivalDay.focus(); } else {
		if (cArrivalMonthError.length>0) { d.ArrivalMonth.focus(); } else {
		if (cArrivalYearError.length>0) { d.ArrivalYear.focus(); } else {
		if (cDepartureDayError.length>0) { d.DepartureDay.focus(); } else {
		if (cDepartureMonthError.length>0) { d.DepartureMonth.focus(); } else {
		if (cDepartureYearError.length>0) { d.DepartureYear.focus(); } else {
		if (cSpecialrequestsError.length>0) { d.Specialrequests.focus(); } else {
		if (cTreatments1Error.length>0) { d.Treatments1.focus(); } else {
		if (cTDate1Error.length>0) { d.TDate1.focus(); } else {
		if (cTMonth1Error.length>0) { d.TMonth1.focus(); } else {
		if (cTYear1Error.length>0) { d.TYear1.focus(); }  else {
		if (cTDuration1Error.length>0) { d.TDuration1.focus(); } else {
		if (cTMin1Error.length>0) { d.TMin1.focus(); } else {
		if (cTApprox1Error.length>0) { d.TApprox1.focus(); } } } } } } } } } } } } } } } }
		return false; 
	}
	d.submit();
}
//Function to trim the space in the left side of the string
function ltrim ( s ){
  return s.replace( /^\s*/, "" );
}
//Function to trim the space in the right side of the string
function rtrim ( s ){
   return s.replace( /\s*$/, "" );
}
//*Function to trim the space in the  string
function trim(s) {
   var temp = s;
   return temp.replace(/^\s+/,'').replace(/\s+$/,'');
}
