   //start new script code
   // Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
    function isBrowserSupp() {
        // Get the version of the browser
        version =  parseFloat( navigator.appVersion );

        if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
            return false;
        } else {
            return true;
        }

        return true;
    }

    function isLeapYear( yrStr ) {
        var leapYear = false;
        var year = parseInt( yrStr, 10 );
        // every fourth year is a leap year
        if ( year % 4 == 0 ) {
            leapYear = true;
            // unless it's a multiple of 100
            if( year % 100 == 0 ) {
                leapYear = false;
                // unless it's a multiple of 400
                if( year % 400 == 0 ) {
                    leapYear=true;
                }
            }
        }
        return leapYear;
    }

    function getDaysInMonth( mthIdx, YrStr ) {
        // all the rest have 31
        var maxDays = 31
        // expect Feb. (of course)
        if( mthIdx == 1 ) {
            if( isLeapYear( YrStr ) ) {
                maxDays=29;
            } else {
                maxDays=28;
            }
        }

        // thirty days hath...
        if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {
            maxDays=30;
        }
        return maxDays;
    }

    //the function which does some magic to the date fields
    // return non-zero if it is the last day of the month
    function adjustDate( mthIdx, Dt ) {
        var value = 0;

        var today = new Date()
        var theYear = parseInt( today.getYear(), 10 )

        if( mthIdx < today.getMonth() ) {
            theYear = ( parseInt( today.getYear(), 10 ) + 1 )
        }
        if( theYear < 100 ) {
            theYear = "19" + theYear
        } else {
            if( ( theYear - 100 ) < 10 ) {
                theYear = "0" + ( theYear - 100 )
            } else {
                theYear = ( theYear - 100 ) + ""
            }
            theYear = "20" + theYear
        }


        var numDays = getDaysInMonth( mthIdx, theYear );

        if( mthIdx == 1 ) {
            if( Dt.options.selectedIndex + 1 < numDays ) {
                return 0;
            } else {
                Dt.options.selectedIndex=numDays - 1;
                //check for leap year
                if( numDays == 29 ) {
                    return 99;
                } else {
                    return 1;
                }
            }
        }

        if( Dt.options.selectedIndex + 1 < numDays ) {
            value = 0;
        } else {
            if ( Dt.options.selectedIndex + 1 > numDays ) {
                Dt.options.selectedIndex--;
                value = 3;
            } else {
                //index is 31 or 30
                value = 2;
            }
        }
        return value;
    }

    //changes departure month when arrival month is changed
    function amadChange( inM, inD, outM, outD ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        var res = adjustDate( inM.options.selectedIndex, inD );
        if( res != 0 ) {
               outD.options.selectedIndex = 0;
               if ( outM.options.selectedIndex == 11 ) {
                    outM.options.selectedIndex = 0
               } else {
                    outM.options.selectedIndex=inM.options.selectedIndex + 1;
                    outD.options.selectedIndex = 1;
               }
        } else {
            outM.options.selectedIndex = inM.options.selectedIndex;
            if (outD.options.selectedIndex <= inD.options.selectedIndex) {
                outD.options.selectedIndex = inD.options.selectedIndex + 2;
            }
        }
        return;
    }


    function dmddChange( outM, outD ) {
        if ( !isBrowserSupp() ) {
            return;
        }

        adjustDate( outM.options.selectedIndex, outD );
        return;
    }

function loadDates(arrivalMonthSelect,  arrivalDaySelect, departureMonthSelect, departureDaySelect)
{
	var calendar = new Date();
	var calendar2 = new Date();
	var cal
	var cal2
	var date;
	var month;
	var year;
	var date2;
	var month2;
	var year2;

	//Here is the variable to change for to advance the arrival Date
	 var advanceArrival = 14;
	//Here is the variable to change for to advance the departure Date
	 var advanceDeparture = 16;


	//Set the arrival Days
	calendar.setDate(calendar.getDate()+ advanceArrival);
	date = calendar.getDate();
	month = calendar.getMonth();

	//Set the Departure Days
	calendar2.setDate(calendar2.getDate()+advanceDeparture);
	date2 = calendar2.getDate();
	month2 = calendar2.getMonth();

	arrivalMonthSelect.value=month;
	arrivalDaySelect.value=date;
	departureMonthSelect.value=month2;
	departureDaySelect.value=date2;
}


function isValidEmail(emailElement)
{

	emailStr = new String("");
	emailStr = emailElement.value ;
	
	if( isBlank( emailStr ) )
		return true ;

	var bFoundAt = false;
	var bFoundDot = false;

	for(i = 0; i < emailStr.length - 2; i++)
	{
	   if (emailStr.charAt(i) == '@')
	   {
	   		// if @ more than once ...	 return false
			if (bFoundAt)
			{
				emailElement.focus();
				alert( "Please enter a valid email address" );
				return false;
			}
			bFoundAt = true;
		}

		if (emailStr.charAt(i) == '.')
		{
			// if . appears before @ ... return false
		   if (!bFoundAt)
		   {
		   		emailElement.focus();
		   		alert( "Please enter a valid email address" );
				return false;
			}
		    bFoundDot = true;
		}
	 }

	 // if only one . & one @ ... return true
	 if ( bFoundDot && bFoundAt)
		return true;

	 emailElement.focus();
	 alert( "Please enter a valid email address" );
	 return false;
}

function ValidateEmail(emailElement,maxlen)
{

	emailStr = new String("");
	emailStr = emailElement.value ;

	if( isBlank( emailStr ) )
		return true ;

	var bFoundAt = false;
	var bFoundDot = false;

	if(maxlen > 0)
	 if(emailStr.length > maxlen) {
	alert("Email length should not exceed 50chars.") ;
	return false;		
	}

	for(i = 0; i < emailStr.length - 2; i++)
	{
	   if (emailStr.charAt(i) == '@')
	   {
	   		// if @ more than once ...	 return false
			if (bFoundAt)
			{
				emailElement.focus();
				alert( "Please enter a valid email address" );
				return false;
			}
			bFoundAt = true;
		}

		if (emailStr.charAt(i) == '.')
		{
			// if . appears before @ ... return false
		   if (!bFoundAt)
		   {
		   		emailElement.focus();
		   		alert( "Please enter a valid email address" );
				return false;
			}
		    bFoundDot = true;
		}
	 }

	 // if only one . & one @ ... return true
	 if ( bFoundDot && bFoundAt)
		return true;

	 emailElement.focus();
	 alert( "Please enter a valid email address" );
	 return false;
}


function validateNSForm()
{
	var reqfldsArray = new Array("txtEmailAddress");
	var fldNamesArray = new Array("Email Address");
	if( chkRequiredFlds( reqfldsArray, fldNamesArray, "frmNewsletter" ) )
		return isValidEmail(document.frmNewsletter.txtEmailAddress);

	return false;	
}



function chkRequiredFlds( reqfldsArray, fldNamesArray, formName )
{

	var myvar = new String("") ;
	var fieldval = new String("") ;
	var errorfields = new String("") ;
	var errorfield1 = new String("") ;
	var i ;
	var flag = true;

	for( i=0 ; i < reqfldsArray.length; i++ )
	{
		myvar = reqfldsArray[i] ;
		fieldval = Trim( document.forms[formName].elements[myvar].value ) ;
		if( fieldval.length <= 0 )
		{
//			document.forms[0].elements[myvar].value = fieldval ;
			document.forms[formName].elements[myvar].value = fieldval ;
			if( flag == true )
			{
				errorfield1 = myvar ;
				errorfields = errorfields + "\n\n* "+fldNamesArray[i] ;
			}
			else
				errorfields = errorfields + '\n* ' + fldNamesArray[i] ;
			flag = false ;
		}
	}
	
	if( flag == false )
	{
		//document.forms[0].elements[errorfield1].focus();
		alert( "The following field(s) are required: " + errorfields ) ;
	}
	return flag ;
}

function validateForm(frmName)
{
			
	if( chkRequiredFlds( reqfldsArray, fldNamesArray, frmName ) )
	{
		switch (frmName)
		{
		case "frmSearch":
			for( i=0; i<document.frmSearch.rdCity.length; i++ )
			{
				if( document.frmSearch.rdCity[i].value == "" && 
				    document.frmSearch.rdCity[i].checked == true &&
				    document.frmSearch.city.value == "" )
				{
					alert("Please enter a city");
					return false;
				}
			}	
			return ( validateDates(document.frmSearch) );
			break;
		case "frmSignup":
			return ( compareFields("Password",document.frmSignup.txtPassword.value,"Confirm Password",document.frmSignup.txtCPassword.value) );
			break;
		case "frmChangePassword":
			if( compareFields("Password",document.frmChangePassword.txtNewPassword.value,"Confirm Password",document.frmChangePassword.txtCNewPassword.value) )
			{
				frmChangePassword.submit();
				return true; 
			}
			return false;
			break;
		case "frmReserve" :
			if(document.frmReserve.selCountry.value == "US") minlen = 10; else minlen = 6;
			if(document.frmReserve.txtEAddress.value != document.frmReserve.txtCEAddress.value) { alert("Confirm Email dont match."); return false; }
			if(Validatephone(document.frmReserve.txtHomePhone,minlen)) return true; else return false;
			if(ValidateEmail(document.frmReserve.txtEAddress,50)) return true; else return false;
			if(!document.frmReserve.chkAgreePolicy.checked)	{
				alert("* If you agree to the cancellation policy please check 'I agree to the above Cancellation Policy'.");
				return false;
			} 

						
			return true;
			
			break;			
		case "frmCarReserve" :
			if( isValidEmail(document.frmCarReserve.txtEAddress) )
			{
				return ( compareFields("Email",document.frmCarReserve.txtEAddress.value,"Confirm Email",document.frmCarReserve.txtCEAddress.value) );
			}
			else 
				return false;
			break;
		case "frmSearchCar" :
				if(document.frmSearchCar.city.value == "" )
				{
					alert("Please enter a city");
					return false;
				}
			return ( validateDatesCars(document.frmSearchCar) );
		break;
		case "frmCancelReserver" :
					return true;
		break;
		
		case "frmCancelReserver" :
					return true;
		break;
		
		case "editaccountinfo" :
			return true;
		break;
		
		default :
			return true;
			break;
		}
	}
	else
		return false;
}

function ipval() {
var ip = '38.107.191.96'
var pname = document.URLUnencoded;
document.hotSearch.temp1.value=ip;
document.hotSearch.temp2.value=pname;
}

function showMoneyback(URL)
{
	window.open(URL, '', 'width=820,height=500,toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0');
}




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 LTrim(str)
{
	for (var i=0; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i++);
	return str.substring(i,str.length);
}
function RTrim(str)
{
	for (var i=str.length-1; ((str.charAt(i)<=" ")&&(str.charAt(i)!="")); i--);
	return str.substring(0,i+1);
}
function Trim(str)
{
	return LTrim(RTrim(str));
}


