﻿/*
// JScript File

function js_change_price_range(obj) {
//fmLeads
with (document.fmLeads.ddlPriceRange) 
    {
        //empty list
		for(i=options.length-1;i>0;i--) options[i] = null;
    
        options[0] = new Option("UnSure","UnSure",true,true);
        
        switch (obj.value) 
        {
            case "Motorhomes / RV":
            {
                options[1] = new Option("up to $50000");
                options[2] = new Option("$50000 - $100000");
                options[3] = new Option("$100000+");
                options[4] = new Option("All","All Prices");
                break;
            }
			
			case "Tent Trailers":
            {
                options[1] = new Option("up to $5000","up to $5000");
                options[2] = new Option("$5000 - $15000","$5000 - $15000");
                options[3] = new Option("Over $15000","Over $15000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Slide-on Campers":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $50000","$30000 - $50000");
                options[3] = new Option("Over $50000","Over $50000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Camper Trailers":
            {
                options[1] = new Option("up to $20000","up to $20000");
                options[2] = new Option("$20000 - $30000","$20000 - $30000");
                options[3] = new Option("Over $30000","Over $30000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Pop-Top Caravans":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $40000","$30000 - $40000");
                options[3] = new Option("Over $40000","Over $40000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Camper Vans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Caravans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                options[4] = new Option("All","All Prices");
                break;
            }

            case "5th Wheelers":
            {
                options[1] = new Option("up to $100000","up to $100000");
                options[2] = new Option("$100000 - $300000","$100000 - $300000");
                options[3] = new Option("Over $300000","Over $300000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "All":
            {                
                options[0] = new Option("All Prices","All");
                break;
            }
        }
    }

    
}

function js_select_price_range(obj) 
{
    with (document.fmEnquiry.ddlPriceRange) 
    {
        //empty list
		for(i=options.length-1;i>0;i--) options[i] = null;
    
        options[0] = new Option("UnSure","UnSure",true,true);
        
        switch (obj.value) 
        {
           		
			case "Motorhomes / RV":
            {
                options[1] = new Option("up to $50000");
                options[2] = new Option("$50000 - $100000");
                options[3] = new Option("$100000+");
                break;
            }
			
			case "Tent Trailers":
            {
                options[1] = new Option("up to $5000","up to $5000");
                options[2] = new Option("$5000 - $15000","$5000 - $15000");
                options[3] = new Option("Over $15000","Over $15000");
                break;
            }
            case "Slide-on Campers":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $50000","$30000 - $50000");
                options[3] = new Option("Over $50000","Over $50000");
                break;
            }
            case "Camper Trailers":
            {
                options[1] = new Option("up to $20000","up to $20000");
                options[2] = new Option("$20000 - $30000","$20000 - $30000");
                options[3] = new Option("Over $30000","Over $30000");
                break;
            }
            case "Pop-Top Caravans":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $40000","$30000 - $40000");
                options[3] = new Option("Over $40000","Over $40000");
                break;
            }
            case "Camper Vans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                break;
            }
            case "Caravans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                break;
            }
 
			
	
			
			
			
            case "5th Wheelers":
            {
                options[1] = new Option("up to $100000","up to $100000");
                options[2] = new Option("$100000 - $300000","$100000 - $300000");
                options[3] = new Option("Over $300000","Over $300000");
                break;
            }
        }
    }

    
}

function js_validateForm() {

    var size;

    //check product type
    if (document.fmEnquiry.ddlProductType.value == "") {
        alert("Please select a product type");
        document.fmEnquiry.ddlProductType.focus();
        return false;
    }
    
    //check preferred brand name
//    if (document.fmEnquiry.tbPrefBand.value == "") {
//        alert("Please enter your preferred brand");
//        document.fmEnquiry.tbPrefBand.focus();
//        return false;
//    }
    
    //check price range
    if (document.fmEnquiry.ddlPriceRange.value == "") {
        alert("Please select a price range");
        document.fmEnquiry.ddlPriceRange.focus();
        return false;
    }

    //check full name
    if(document.fmEnquiry.tbCustName.value == "") {
        alert("Please enter your full name");
        document.fmEnquiry.tbCustName.focus();
        return false;
    }
    	//check SUBURB
    if(document.fmEnquiry.tbSuburb.value == "") {
        alert("Please enter your Suburb");
        document.fmEnquiry.tbSuburb.focus();
        return false;
    }
    //check postcode
    if(document.fmEnquiry.tbPostCode.value == "") {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.focus();
        return false;
    }
    
    if(isNaN(document.fmEnquiry.tbPostCode.value)) {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.value = "";
        document.fmEnquiry.tbPostCode.focus();
        return false;
    }
    
    size = document.fmEnquiry.tbPostCode.length;
    
    if(size > 4) {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.value = "";
        document.fmEnquiry.tbPostCode.focus();
        return false;        
    }
    
    //check contact number
    if (document.fmEnquiry.tbContactNumber.value == "") {
        alert("Please enter a valid contact number");
        document.fmEnquiry.tbContactNumber.focus();
        return false;
    }
    
    //check email
    if (document.fmEnquiry.tbEmail.value == "") {
        alert("Please enter your email address");
        document.fmEnquiry.tbEmail.focus();
        return false;
    }
     //check Referral
    if (document.fmEnquiry.ddlReferral.value == "") {
        alert("Please select a how did you find out about our buyers service?");
        document.fmEnquiry.ddlReferral.focus();
        return false;
    }
    
    //RV Product validation
    if (document.fmEnquiry.ddlRVProduct.value == "") {
        alert("Please select if you currently own a RV Product?");
        document.fmEnquiry.ddlRVProduct.focus();
        return false;
    }
	
	
    if(checkemail(document.fmEnquiry.tbEmail.value) == false){
        alert("Please enter a valid email address");
        document.fmEnquiry.tbEmail.value = "";
        document.fmEnquiry.tbEmail.focus();
        return false;
    }
    
    //RV Product Purchase
    if (document.fmEnquiry.ddlPP.value == "") {
        alert("Please select your interest in product purchase");
        document.fmEnquiry.ddlPP.focus();
        return false;
    }
    
    return true;

}

function checkemail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	//Memeber login validation script
	function js_check_login_frm() 
	{
	  	    
	    
	    if ((document.fmlogin.tbuserid.value == null) || 
	        (document.fmlogin.tbuserid.value == ""))
	        {
	            alert("Please enter a valid user id");	            
	            document.fmlogin.tbuserid.focus();
	            return false;
	        }
	        
	    if ((document.fmlogin.tbPassword.value == null) || 
	        (document.fmlogin.tbPassword.value == ""))
	        {
	            alert("Please enter a valid password");	            
	            document.fmlogin.tbPassword.focus();
	            return false;
	        }	        
	        
	        return true;
	}
	*/
	
// JScript File

function js_change_price_range(obj) {
//fmLeads
with (document.fmLeads.ddlPriceRange) 
    {
        //empty list
		for(i=options.length-1;i>0;i--) options[i] = null;
    
        options[0] = new Option("UnSure","UnSure",true,true);
        
        switch (obj.value) 
        {
            case "Motorhomes / RV":

            {
                options[1] = new Option("up to $50000");
                options[2] = new Option("$50000 - $100000");
                options[3] = new Option("$100000+");
                options[4] = new Option("All","All Prices");
                break;
            }
			
			case "Tent Trailers":
            {
                options[1] = new Option("up to $5000","up to $5000");
                options[2] = new Option("$5000 - $15000","$5000 - $15000");
                options[3] = new Option("Over $15000","Over $15000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Slide-on Campers":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $50000","$30000 - $50000");
                options[3] = new Option("Over $50000","Over $50000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Camper Trailers":
            {
                options[1] = new Option("up to $20000","up to $20000");
                options[2] = new Option("$20000 - $30000","$20000 - $30000");
                options[3] = new Option("Over $30000","Over $30000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Pop-Top Caravans":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $40000","$30000 - $40000");
                options[3] = new Option("Over $40000","Over $40000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Camper Vans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "Caravans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                options[4] = new Option("All","All Prices");
                break;
            }

            case "5th Wheelers":
            {
                options[1] = new Option("up to $100000","up to $100000");
                options[2] = new Option("$100000 - $300000","$100000 - $300000");
                options[3] = new Option("Over $300000","Over $300000");
                options[4] = new Option("All","All Prices");
                break;
            }
            case "All":
            {                
                options[0] = new Option("All Prices","All");
                break;
            }
        }
    }

    
}

function js_select_price_range(obj) 
{
    with (document.fmEnquiry.ddlPriceRange) 
    {
        //empty list
		for(i=options.length-1;i>0;i--) options[i] = null;
    
        options[0] = new Option("UnSure","UnSure",true,true);
        
        switch (obj.value) 
        {
           		
   case "Motorhomes / RV":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("$100000+","$100000+");
                break;
            }
				
			
			
			case "Tent Trailers":
            {
                options[1] = new Option("up to $5000","up to $5000");
                options[2] = new Option("$5000 - $15000","$5000 - $15000");
                options[3] = new Option("Over $15000","Over $15000");
                break;
            }			
			
			case "Slide-on Campers":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $50000","$30000 - $50000");
                options[3] = new Option("Over $50000","Over $50000");
                break;
            }
            case "Camper Trailers":
            {
                options[1] = new Option("up to $20000","up to $20000");
                options[2] = new Option("$20000 - $30000","$20000 - $30000");
                options[3] = new Option("Over $30000","Over $30000");
                break;
            }
            case "Pop-Top Caravans":
            {
                options[1] = new Option("up to $30000","up to $30000");
                options[2] = new Option("$30000 - $40000","$30000 - $40000");
                options[3] = new Option("Over $40000","Over $40000");
                break;
            }
            case "Camper Vans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                break;
            }
            case "Caravans":
            {
                options[1] = new Option("up to $50000","up to $50000");
                options[2] = new Option("$50000 - $100000","$50000 - $100000");
                options[3] = new Option("Over $100000","Over $100000");
                break;
            } 		
            case "5th Wheelers":
            {
                options[1] = new Option("up to $100000","up to $100000");
                options[2] = new Option("$100000 - $300000","$100000 - $300000");
                options[3] = new Option("Over $300000","Over $300000");
                break;            }
        }
    }

    
}

function js_validateForm() {

    var size;

    //check product type
    if (document.fmEnquiry.ddlProductType.value == "") {
        alert("Please select a product type");
        document.fmEnquiry.ddlProductType.focus();
        return false;
    }
    
    //check preferred brand name
//    if (document.fmEnquiry.tbPrefBand.value == "") {
//        alert("Please enter your preferred brand");
//        document.fmEnquiry.tbPrefBand.focus();
//        return false;
//    }
    
    //check price range
    if (document.fmEnquiry.ddlPriceRange.value == "") {
        alert("Please select a price range");
        document.fmEnquiry.ddlPriceRange.focus();
        return false;
    }

    //check full name
    if(document.fmEnquiry.tbCustName.value == "") {
        alert("Please enter your full name");
        document.fmEnquiry.tbCustName.focus();
        return false;
    }
    	//check SUBURB
    if(document.fmEnquiry.tbSuburb.value == "") {
        alert("Please enter your Suburb");
        document.fmEnquiry.tbSuburb.focus();
        return false;
    }
    //check postcode
    if(document.fmEnquiry.tbPostCode.value == "") {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.focus();
        return false;
    }
    
    if(isNaN(document.fmEnquiry.tbPostCode.value)) {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.value = "";
        document.fmEnquiry.tbPostCode.focus();
        return false;
    }
    
    size = document.fmEnquiry.tbPostCode.length;
    
    if(size > 4) {
        alert("Please enter a valid post code");
        document.fmEnquiry.tbPostCode.value = "";
        document.fmEnquiry.tbPostCode.focus();
        return false;        
    }
    
    //check contact number
    if (document.fmEnquiry.tbContactNumber.value == "") {
        alert("Please enter a valid contact number");
        document.fmEnquiry.tbContactNumber.focus();
        return false;
    }
    
    //check email
    if (document.fmEnquiry.tbEmail.value == "") {
        alert("Please enter your email address");
        document.fmEnquiry.tbEmail.focus();
        return false;
    }
     //check Referral
    if (document.fmEnquiry.ddlReferral.value == "") {
        alert("Please select a how did you find out about our buyers service?");
        document.fmEnquiry.ddlReferral.focus();
        return false;
    }
    
    //RV Product validation
    if (document.fmEnquiry.ddlRVProduct.value == "") {
        alert("Please select if you currently own a RV Product?");
        document.fmEnquiry.ddlRVProduct.focus();
        return false;
    }
	
	
    if(checkemail(document.fmEnquiry.tbEmail.value) == false){
        alert("Please enter a valid email address");
        document.fmEnquiry.tbEmail.value = "";
        document.fmEnquiry.tbEmail.focus();
        return false;
    }
    
    //RV Product Purchase
    if (document.fmEnquiry.ddlPP.value == "") {
        alert("Please select your interest in product purchase");
        document.fmEnquiry.ddlPP.focus();
        return false;
    }
    
    return true;

}

function checkemail(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}
	
	//Memeber login validation script
	function js_check_login_frm() 
	{
	  	    
	    
	    if ((document.fmlogin.tbuserid.value == null) || 
	        (document.fmlogin.tbuserid.value == ""))
	        {
	            alert("Please enter a valid user id");	            
	            document.fmlogin.tbuserid.focus();
	            return false;
	        }
	        
	    if ((document.fmlogin.tbPassword.value == null) || 
	        (document.fmlogin.tbPassword.value == ""))
	        {
	            alert("Please enter a valid password");	            
	            document.fmlogin.tbPassword.focus();
	            return false;
	        }	        
	        
	        return true;
	}