hld_documentReady("addEthanolMessageWindow");
hld_documentReady("addDisclaimerMessageWindow");
hld_documentReady("addNZDisclaimerMessageWindow");
hld_documentReady("addFleetMessageWindow");
hld_documentReady("addEvaluationFormWindow");
hld_documentReady("addGoogleMapWindow");

function addGoogleMapWindow() {
	try {
		$("div.googlemap a").unbind(); 
		$("div.googlemap a").click(function() 
		 {		
			$("#loadAjaxMessage").jqmShow();
			$("#loadAjaxMessage").load("/Satellite?c=Page&pagename=Holden.com.au/Page/HLDDealersGoogleMap&cid=1220631020297 #gmap",
				 function(responseText) {
					fireOffPngFix();
					jQuery("#disclaimerPopupImage").attr('src', "/resources/images/Pagetitles/Page_headers/disclaimer.gif");	  
					jQuery("#closeWindow").attr('src', "/resources/images/popups/closePopup.gif");	 
					addDisclaimerCloseWindowButton();
				 } 
			 );
			 return false;
		 });
	} catch (err) {
		return false;
	}
}

function addEvaluationFormWindow() {
	try {
		$(".evaluationForm a").unbind(); 
		$(".evaluationForm a").click(function() {
			$("#inpregonumb").val('');
			var currentButton = this;
		  	$("#loadAjaxMessage").jqmShow();
			$("#loadAjaxMessage").load("/fleet/home #hpLogin2",
				 function(responseText) {
					$("#hpLogin2").show();
					$(".evaluationForm .error-registration").hide();
					fireOffPngFix();
					$("#disclaimerPopupImage").attr('src', hld_resource_path + "/images/Pagetitles/Page_headers/disclaimer.gif");	  
					$("#closeWindow").attr('src', hld_resource_path + "/images/popups/closePopup.gif");	 
					addDisclaimerCloseWindowButton();
				 } 
			 );
			 return false;
		 });
	} catch (err) {
		return false;
	}
}

function addFleetMessageWindow()
{
	try {
		$(".fleetDownload").unbind(); 
		$(".fleetDownload").click(function() 
		 {		
			var currentButton = this;
		  	$("#loadAjaxMessage").jqmShow();
			$("#loadAjaxMessage").load(hld_resource_path + "/html/BrochureDownload.html",
				 function(responseText)
				 {
					fireOffPngFix();
					$("#disclaimerPopupImage").attr('src', hld_resource_path + "/images/Pagetitles/Page_headers/disclaimer.gif");	  
					$("#closeWindow").attr('src', hld_resource_path + "/images/popups/closePopup.gif");	 
					addDisclaimerCloseWindowButton();
				 } 
			 );
			 return false;
		 });
	} catch (err) {
		return false;
	}
}

function addEthanolMessageWindow()
{
	try {
	$("#1220618342869-Bottom-GA").unbind();
	$("#1220618342869-Bottom-GA").click(function() 
	 {		
		var currentButton = this;
	  $("#loadAjaxMessage").css("left","40%");
	 	$("#loadAjaxMessage").jqmShow();
		$("#loadAjaxMessage").load(hld_resource_path + "/html/EthanolMessage.html",
			 function(responseText)
			 {
				fireOffPngFix();
				$("#disclaimerPopupImage").attr('src', hld_resource_path + "/images/Pagetitles/Page_headers/disclaimer.gif");	  
				$("#closeWindow").attr('src', hld_resource_path + "/images/popups/closePopup.gif");	 
				addDisclaimerCloseWindowButton();
			 } 
		 );
		 return false;
	 });
	} catch (err) {
		return false;
	}
}

function addNZDisclaimerMessageWindow()
{
	try {
	$("#1220618342869-Bottom-GA").unbind();
	$("#1220618342869-Bottom-GA").click(function() 
	 {		
		var currentButton = this;
	  $("#loadAjaxMessage").css("left","40%");
	 	$("#loadAjaxMessage").jqmShow();
		$("#loadAjaxMessage").load(hld_resource_path + "/html/EthanolMessage.html",
			 function(responseText)
			 {
				fireOffPngFix();
				$("#disclaimerPopupImage").attr('src', hld_resource_path + "/images/Pagetitles/Page_headers/disclaimer.gif");	  
				$("#closeWindow").attr('src', hld_resource_path + "/images/popups/closePopup.gif");	 
				addDisclaimerCloseWindowButton();
			 } 
		 );
		 return false;
	 });
	} catch (err) {
		return false;
	}
}

function htmlOverlay (domElement, filename, width, top, cssClass, onBeforeLoad, onClose){
	domElement.overlay(
		{
		target:"#overlayWrapper",
		mask: {color : '#fff'},
		top: top,
		left: "50%",
		onBeforeLoad:function()
			{
				$("#overlayContent").load(hld_resource_path + "/html/" + filename,
					function(){Cufon.refresh();}	
				);
				$("#overlayWrapper").width(width).css('margin-left',-(width/2)+"px").addClass(cssClass);
				if (onBeforeLoad) {
					onBeforeLoad();
				}
			},
		onClose:function()
			{
				$("#overlayWrapper").removeClass(cssClass);
				if (onClose) {
					onClose();
				}						
			},
		closeOnClick:true
		}
	);
}


function addDisclaimerMessageWindow()
{
	//This script was moved to overlay.js
}

function addDisclaimerCloseWindowButton()
{
	$("#closeWindowLink").unbind();
	$("#closeWindowLink").click(function() 
	 {
		var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
		var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
//		if (jQuery.browser.msie && (ie55 || ie6)) 
//			alert("Close button clicked");
		$("#loadAjaxMessage").jqmHide();
		return false;
	 });
}



function addImportantInfoWindow()
{
	$("#loadAjaxMessage").jqm({toTop: true});
	$("#1220612194429-Bottom-GA").unbind();
	$("#1220612194429-Bottom-GA").click(function() 
	 {
		var currentButton = this;
		$("#loadAjaxMessage").jqmShow();
		$("#loadAjaxMessage").load(hld_resource_path + "/html/ImportantMessage.html",
			 function(responseText)
			 {
				fireOffPngFix();
				$("#disclaimerPopupImage").attr('src', hld_resource_path + "/images/Pagetitles/Page_headers/disclaimer.gif");	  
				$("#closeWindow").attr('src', hld_resource_path + "/images/popups/closePopup.gif");	 
				addDisclaimerCloseWindowButton();
			 } 
		 );
		 return false;
	 });
}


function addBuildAndPriceWindow()
{
	HLD.loadHtmlOverlay("BuildAndPriceMessage.html", 450, "20%", "pricingDisclaimer");
}
