<!--//--><![CDATA[//><!--

var timer;
var count = 0;
// preloaded images array (this array is populated in function preloadImages which is called when the page is loaded)
var imageArr2 = new Array();
var imageVehArr2 = new Array();
// image alt tag array           
var imageAltArr = new Array("Hunter Valley Tours", "Blue Mountain Tours", "Sydney Highlight Tours", "Sydney by Night Tours");
// image link array           
var imageLinkArr = new Array("#hv", "#bm", "#s8", "#s2");

function addOption(selectbox,text,value)
{        
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}

function event_pickup_change(location, page_load)
{
    // This function populates the destination drop down based on the value selected in the pickup drop down and displays prices if relevant

    //alert(location);
    //alert(page_load);
    pickup = document.getElementById('pickup'); 
    //alert("pickup: " + pickup.value);
    destination = document.getElementById('destination'); 
    //alert("destination: " + destination.value);   
   
    if ((page_load == true) && (location == "Sydney"))
    {
        document.getElementById('location').value = "Sydney";
        destination_value = "City (Sydney)|1";
    }
    else if ((page_load == true) && (location == "Sydney_SC"))
    {
        document.getElementById('location').value = "Sydney_SC";
        destination_value = "City (Sydney)|1";
    }
    else if ((page_load == true) && (location == "Canberra"))
    {
        document.getElementById('location').value = "Canberra";
        destination_value = "Canberra City|2";
    }    
    else if ((page_load == true) && (location == "Melbourne"))
    {
        document.getElementById('location').value = "Melbourne";
        destination_value = "City (Melbourne)|3";
    }
    else if ((page_load == true) && (location == "Brisbane"))
    {
        document.getElementById('location').value = "Brisbane";
        destination_value = "City (Brisbane)|2";
    }
    else if ((page_load == true) && (location == "Gold Coast"))
    {
        document.getElementById('location').value = "Gold Coast";
        destination_value = "Surfers Paradise|3";
    }
    else
    {
        destination_value = destination.value;
    }
     
    if (pickup.value.length > 0)
    {
        populate_dest(pickup, destination, destination_value);                                                       
    } 
                       
    calculate_prices(location);   
}

function populate_dest(pickup, destination, destination_value)
{
    // Clear destination drop down box & add Select item      
    destination.options.length = 0;
    addOption(destination, "Select " + String.fromCharCode(187), "");
    zone = pickup.value.split("|")[1];
    for (i = 1; i < pickup.options.length; i++)
    {
        // Pickup selected is a fixed location - only add suburbs to destination
        if ((zone == undefined) && (pickup[i].value.split("|")[1] > 0))
        {
                addOption(destination, pickup[i].text, pickup[i].value);
        }
        // Pickup selected is a suburb - only add fixed locations to destination
        else if ((zone > 0) && (pickup[i].value.split("|")[1] == undefined))
        {
                addOption(destination, pickup[i].text, pickup[i].value);                   
        }            
    }
    // If there are only 2 choices i.e. Select & another, then ensure that the value after Select is selected                  
    if (destination.options.length == 2)
    {
        destination.selectedIndex = 1;
        //alert("1: " + destination.value);
    }
    else 
    {                
        destination.value = destination_value; 
        //alert("2: " + destination.value);
        //destination.selectedIndex = 0;
    }
    if (destination.selectedIndex == -1) 
            destination.selectedIndex = 0;  
}

function calculate_prices(location)
{                       
    //alert("calculate_prices: " + location);
    //if (location == "Canberra")
    if (location.indexOf("Canberra") != -1)
    {
        //vehicles = new Array ("chr", "bmw2", "hia");
        //prices_i = new Array (0,1,2); 
        vehicles = new Array ("chr", "bmw2");
        prices_i = new Array (0,1);                

    }
    else if (location.indexOf("Melbourne") != -1)
    {
        vehicles = new Array ("cap", "bmw", "mer", "lex1", "str", "via", "hia");
        prices_i = new Array (0,1,1,1,2,2,2);        

    }
    else if ((location.indexOf("Brisbane") != -1) || (location.indexOf("Gold Coast") != -1))
    {
        vehicles = new Array ("cap", "bmw", "mer", "str", "vit");
        prices_i = new Array (0,1,1,2,3);
    }           
    else
    {
        vehicles = new Array ("cap", "bmw", "mer", "str", "rwg", "vw", "via", "hia");
        prices_i = new Array (0,1,1,2,3,3,3,3);
    }
    
    pickup = document.getElementById("pickup");
    //alert(pickup);
    destination = document.getElementById("destination");
    //alert(destination);
    //alert(destination.split("|")[1]);
    if ((pickup.value.length > 0) && (destination.value.length > 0))
    {
        document.getElementById("b_pickup").value = pickup.value;  
        document.getElementById("b_destination").value = destination.value;          
        zone = pickup.value.split("|")[1];
        if (zone == undefined) // Fixed pickup location
            zone = destination.value.split("|")[1];
        //alert(zone);                        
        if (zone)
        {
            price1 = jsPrices_nd[zone-1].split("|");
            price2 = jsPrices[zone-1].split("|");
            for (i in vehicles)
            {
                if (document.getElementById("book_" + vehicles[i]) != null) // Needed to add this code, as "VW Highliner" was taken away from Sydney fleet temporarily
                {
                    document.getElementById("book_" + vehicles[i]).style.display = "";
                    document.getElementById("prices_" + vehicles[i]).innerHTML = "<p>Cost: <span class='emph'>$" + price1[prices_i[i]] + "</span></p><p>Online: <span class='emph'>$" + price2[prices_i[i]] + "</span></p>";
                }
            }
        } 
    }
    else
    {
        for (i in vehicles)
        {
            if (document.getElementById("book_" + vehicles[i]) != null) // Needed to add this code, as "VW Highliner" was taken away from Sydney fleet temporarily
            {
                document.getElementById("book_" + vehicles[i]).style.display = "none";
            }
        }
    }    
}

function event_veh_click(vehicle)
{         
    document.getElementById("b_vehicle").value = vehicle;
    document.frm_home2.submit();
}

function event_veh_onmouseover(vehicle_num)
{         
    //document.getElementById("content_book1_inner").style.backgroundImage = "url(images_wide_media/" + vehicle_img + ".jpg)";
    // Check if all images have been loaded
    //alert(imageVehArr2.length);
    if (imageVehArr2.length >= 3)
        document.getElementById("content_book1_inner").style.backgroundImage = "url(" + imageVehArr2[vehicle_num].src + ")";        
}

function preloadImages(location)
{
    // Booking vehicle images (home page)
    //var imageVehArr = new Array("home_bookings_cap", "home_bookings_bmw", "home_bookings_mer", "home_bookings_str", "home_bookings_vit", "home_bookings_chr", "home_bookings_hia", "home_bookings_lex1");	
    //if (location == "Canberra")
    //alert(location);
    if (location.indexOf("Canberra") != -1)
        imageVehArr = new Array("home_bookings_chr", "home_bookings_bmw", "home_bookings_hia");
    else if (location.indexOf("Melbourne") != -1)
        imageVehArr = new Array("home_bookings_cap", "home_bookings_bmw2", "home_bookings_mer", "home_bookings_lex", "home_bookings_str", "home_bookings_via", "home_bookings_hia");
    else if ((location.indexOf("Brisbane") != -1) || (location.indexOf("Gold Coast") != -1))
        imageVehArr = new Array("home_bookings_cap", "home_bookings_bmw", "home_bookings_mer", "home_bookings_str", "home_bookings_vit"); 
    else
        imageVehArr = new Array("home_bookings_cap", "home_bookings_bmw", "home_bookings_mer", "home_bookings_rwg", "home_bookings_vw", "home_bookings_str", "home_bookings_via", "home_bookings_vit", "home_bookings_hia");         

	for(var count=0; count < imageVehArr.length; count++)
	{
		imageVehArr2[count] = new Image();
		imageVehArr2[count].src = "images_wide_media/" + imageVehArr[count] + ".jpg";
		//alert(imageVehArr2[count].src);
	} 
	
    // Tour images (home page RHS)
    var imageArr = new Array("tour_hunter_valley", "tour_blue_mountains", "tour_sydney_highlights", "tour_sydney_by_night");  

	// Pre-load your images - create a new array of images and assign the appropriate source value (from the imageArr array)
	// The count variable is again defined in this function and is only local to this function (it does not affect the value of the count variable defined above outside this function)
	for(var count=0; count < imageArr.length; count++)
	{
		imageArr2[count] = new Image();
		imageArr2[count].src = "images_wide_media/" + imageArr[count] + ".jpg";
	}
}

// This function will loop every three seconds (setTimeout is called at the end and set to execute in 3000 milliseconds)
// Assign a timer to the variable so we can stop the loop when we want
function startRotate()
{
    // Check if all images have been loaded
    if (imageArr2.length == 4)
    {
        // Get the image name from the array imageArr2
        document.getElementById("rhs_pic").src = imageArr2[count].src;
        document.getElementById("rhs_pic").alt = imageAltArr[count];
        // Image link
        document.getElementById("rhs_link").href = "http://www.royalelimousines.com.au/attractions_nsw.asp" + imageLinkArr[count]; 

        count++;
        //alert(count);
        if(count == imageArr2.length)
	        count = 0;
    }
	timer = setTimeout("startRotate()", 10000);
}

//--><!]]>
