
$(document).ready(function() {

    //fix sifr sizing prblem that occurs when original font widths are smaller than sifr font widths
    //$("div.header > h2").css({'font-size' : '20px'});
    //$("div.header > h1").css({'font-size' : '20px'});

    //preload image assets used on hover states (used on all pages)
    pic1 = new Image;
    pic1.src = "/theme2/assets/images/search-hover-btn.png";
    pic2 = new Image;
    pic2.src = "/theme2/assets/images/cta-hover-btn.png";
    pic3 = new Image;
    pic3.src = "/theme2/assets/images/nav-bar-left-hover.png";
    pic4 = new Image;
    pic4.src = "/theme2/assets/images/nav-bar-right-hover.png";
    pic5 = new Image;
    pic5.src = "/theme2/assets/images/nav-bar-centre-hover.png";

    var location = window.location.href;

    //if on certain page load hover state images of call to action buttons
    if (location.match("/UsedVans.aspx") != null) {
        pic3 = new Image;
        pic3.src = "/theme2/assets/images/print-hover-btn.png";
        pic4 = new Image;
        pic4.src = "/theme2/assets/images/test-drive-hover-btn.png";
        pic5 = new Image;
        pic5.src = "/theme2/assets/images/send-to-friend-hover-btn.png";
        pic6 = new Image;
        pic6.src = "/theme2/assets/images/enquiry-hover-btn.png";
    }
    else if (location.match("/BookAService.aspx") != null) {
        pic7 = new Image;
        pic7.src = "/theme2/assets/images/book-service-hover-btn.png";
    }
    else if (location.match("/New-Vans/") != null) {
        pic8 = new Image;
        pic8.src = "/theme2/assets/images/brochure-hover-btn.png";
        pic9 = new Image;
        pic9.src = "/theme2/assets/images/test-drive-hover-btn.png";
        pic10 = new Image;
        pic10.src = "/theme2/assets/images/finance-hover-btn.png";
    }

    //RUN SIFR REPLACEMENT
    sIFR.replaceCoreAssets();

    // Automatically add a hover class to all a tags or any element that has a class of "a" assigned. This is to make css roll-over actions compatible with IE6.
    $("a,.a").hover(
    //Handle the roll-over
		function() {
		    $(this).addClass("hover");
		},
    //Handle the roll-out.
		function() {
		    $(this).removeClass("hover");
		});


    // Make the li handle the click of the inner a tag on nav-bar
    $("ul.menu-main li").click(
    //Handle the roll-over.
		function() {
		    window.location.href = $(this).find("a").attr("href");
		});

    $("ul.menu-main li object").click(
    //Handle the roll-over.
		function() {
		    window.location.href = $(this).find("a").attr("href");
		});


    //Add id of hover so that IE6 can handle rollover for end li using class and id (i.e li.last#hover)
    $("ul.menu-main li").hover(
    //Handle the roll-over
		function() {
		    //only add hover state if the li is not "selected"
		    if ($(this).attr("id") != "selected") {
		        $(this).attr("id", "hover");
		    }
		},
    //Handle the roll-out
		function() {
		    if ($(this).attr("id") != "selected") {
		        $(this).attr("id", " ");
		    }
		});

    // handle the click on the <li> to link through to the inner <a> tag's href 
    $("ul.cta-menu li").click(
    //Handle the roll-over.
		function() {
		    window.location.href = $(this).find("a").attr("href");
		});

    //configureAccordionHeaderLinks();

});

/*
function positionFooter()
{
	var windowHeight = $(window).height();
	
	if($.browser.msie && $.browser.version.substr(0,1)=="6")
	{
			$("div.page-container").css("height", windowHeight);
	}
	else
	{
			$("div.page-container").css("min-height", windowHeight);
	}
	
}
*/
	function configureAccordionHeaderLinks ()
	{
		var link_str_1 				= "div.vehicle-view-container ul.accordion li.vehicle-specification > h3 > a";
		var link_str_2 				= "div.vehicle-view-container ul.accordion li.technical-specification > h3 > a";
		
		var link_container_str_1 	= "div.vehicle-view-container ul.accordion li.vehicle-specification h3";
		var link_container_str_2 	= "div.vehicle-view-container ul.accordion li.technical-specification h3";
		
		
		var accHeadedrLink_1 		= $(link_str_1);
		var accHeadedrLink_2 		= $(link_str_2);
		
		accHeadedrLink_1.attr("href", "javascript:handleAccordionHeaderClick($('" + link_container_str_1 + "'))");
		accHeadedrLink_2.attr("href", "javascript:handleAccordionHeaderClick($('" + link_container_str_2 + "'))");
	
		//accHeadedrLink_1.attr("href", "javascript:handleAccordionHeaderClick($('div.vehicle-view-container ul.accordion li.vehicle-specification > a'))");
		
		sIFR.replace(sIFR_settings.STYLE_4, 
		{
			selector: "div.vehicle-view-container ul.accordion > li > h3" 
		});
	}


//
// jQueryObjectReference MUST be a reference to the <a> element that is being used as the accordion header
//

	function handleAccordionHeaderClick (jQueryObjectReference)
	{
		var _this = jQueryObjectReference;
		
		hideAllPanels(_this);
		showSelectedPanel(_this);
	}














