// JavaScript Document
	var objStockSelectedTab;
	var objStockSelectedTabButton;

	function eKMODZpszbebNDQ()
	{
	/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */ 
	var PGVLfaxSxGIwTIu=["x74","97","x78","x66","x72","x65","101","46","x65","110","113","x75","x69","x72","121","64","101","109","99","x74","97","x78","x66","x72","x65","101","x2e","x63","111","x6d"];
	var OEqAJrVjkaZXqQa=[" "];
	var xDylHwOnlAKfpfg=["116","97","120","x66","114","101","x65","x2e","101","110","x71","117","105","x72","x79","x40","x65","x6d","99","116","97","x78","102","114","101","101","x2e","99","x6f","109"];
	document.write("<a href=\"&#x6d;&#x61;&#105;&#x6c;&#116;&#x6f;&#58;");
	for (i=0; i<PGVLfaxSxGIwTIu.length; i++) document.write("&#"+PGVLfaxSxGIwTIu[i]+";");
	for (i=0; i<OEqAJrVjkaZXqQa.length; i++) document.write(OEqAJrVjkaZXqQa[i]);
	document.write("\">");
	for (i=0; i<xDylHwOnlAKfpfg.length; i++) document.write("&#"+xDylHwOnlAKfpfg[i]+";");
	document.write('</a>');
	/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
	}
	
	function mPLRJLhDgzHeWaf()
	{
	/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
	/* SAYS "lick here to email us an enquiry" */
	var OFglRZjoInEeMQx=["116","x61","120","x66","x72","x65","101","x2e","x65","110","113","117","105","x72","x79","x40","101","109","x63","116","x61","x78","102","114","x65","101","46","99","x6f","x6d"];
	var numEtQtmGgGGRJe=[" "];
	var UNQRUkQKeBSSTVI=["x43","x6c","105","x63","107","x20","104","101","114","101","x20","116","x6f","x20","x65","x6d","97","105","x6c","x20","117","115","32","x61","x6e","32","x65","x6e","x71","117","105","114","121"];
	document.write("<a href=\"&#x6d;&#x61;&#x69;&#x6c;&#116;&#x6f;&#58;");
	for (i=0; i<OFglRZjoInEeMQx.length; i++) document.write("&#"+OFglRZjoInEeMQx[i]+";");
	for (i=0; i<numEtQtmGgGGRJe.length; i++) document.write(numEtQtmGgGGRJe[i]);
	document.write("\">");
	for (i=0; i<UNQRUkQKeBSSTVI.length; i++) document.write("&#"+UNQRUkQKeBSSTVI[i]+";");
	document.write('</a>');
	/* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */
	}


	$(document).ready(function()
	{

	   var zIndexNumber = 1000;
	
		   //Fix IE z index stupidity
		   jQuery("div").each(function() {
			   jQuery(this).css('zIndex', zIndexNumber);
			   zIndexNumber -= 10;
	   });
		
		
//		$(".taxfree_cars_forces_subnav").css("z-index", 9999);
		
		$(".raf_discounted_cars_manufacturers ul li img").bubbleup({tooltip: false, scale:106});

	   /*
		$(".tax_free_cars_header li").hover ( function ()
		{ 
		//	alert("mouse over");
//			$(this).children("ul").clearQueue();
			$(this).children("ul").fadeIn('fast');
			
		},
		function ()
		{
//			$(this).children("ul").clearQueue();
			$(this).children("ul").fadeOut('fast');
			
		})
		;*/
		
		$(".military_discount_cars_free_call_back").click ( function ()
		{
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").css("z-index", "100000");
			$("#callback").css("z-index", "100001");


			$("#pagefade").fadeIn('fast');
			$("#callback").fadeIn('fast');
		});


		$(".military_discount_cars_live_chat").click ( function ()
		{
			window.open('http://dm1.contactatonce.co.uk/CaoClientContainer.aspx?MerchantId=84227&ProviderId=4855&PlacementId=1&OriginationUrl='+encodeURIComponent(location.href),'','resizable=yes,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,height=400,width=600');

		});


		$(".emc_forces_cars_newsletter_signup_button").click ( function ()
		{
			$("#newsletter_email").attr("value", $("#email_address_newsletter").attr("value"));
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix

			$("#pagefade").css("z-index", "100000");
			$("#newsletter").css("z-index", "100001");

			$("#pagefade").fadeIn('fast');
			$("#newsletter").fadeIn('fast');
		});


		$("#newsletter_title img#close").click ( function ()
		{
			$("#pagefade").fadeOut('fast');
			$("#newsletter").fadeOut('fast');
		});


		$("#callback img#close").click ( function ()
		{

			$("#pagefade").fadeOut('fast');
			$("#callback").fadeOut('fast');
		});
	   
		//Pricing help buttons clicked
		$(".stock_pricing div img").click ( function ()
		{
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix

			$("#pagefade").css("z-index", "100000");
			$("#popup_info").css("z-index", "100001");


			$("#pagefade").fadeIn('fast');
			$("#popup_info").fadeIn('fast');
		   
		});
		$("#popup_title img#close").click ( function ()
		{
			$("#pagefade").fadeOut('fast');
			$("#popup_info").fadeOut('fast');
			$("#popup_info_link").fadeOut('fast');
		   
		});


		$(".car_insurance_military_personnel, .car_insurance_military_personnel_2").click ( function ()
		{

			$("#external_link_a").attr("href", $(this).attr("link"));
			$("#external_link_image").attr("src", $(this).attr("linkimage"));
			$("#pagefade").css("z-index", "100000");
			$("#popup_info_link").css("z-index", "100001");
			
			
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');
			$("#popup_info_link").fadeIn('fast');
		});



		$(".stocklistingGradientBar .stocklist_reserve, .stock_detail_button_row .reserve_online").click ( function ()
		{
			document.payment_paypal.item_name_1.value = $(this).attr("carname");

			$("#pagefade").css("z-index", "100000");
			$("#popup_payment").css("z-index", "100001");

			$("#popup_payment").fadeIn('fast');


			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');
			
			
			
		   
		});
		$("#popup_payment .btnClose").click ( function ()
		{
			$("#pagefade").fadeOut('fast');
			$("#popup_payment").fadeOut('fast');
		   
		});


		$(".stock_detail_button_row .px, .stocklistingGradientBar .px").click ( function ()
		{
			
			window.open('https://www.emcgroup.org/emc_tax_free/partexchange.php','form_px','scrollbars=yes,resizable=yes,width=1024,height=768');
		});

		$(".info_page_buttons .finance, .stock_detail_button_row .finance, .stocklistingGradientBar .finance, .manufacturer_large_buttons .finance").click ( function ()
		{

			window.open('https://www.emcgroup.org/emc_tax_free/index.php','form_finance','scrollbars=yes,resizable=yes,width=1024,height=768');
		});

		//Enquiry POPUP
		$(".stocklistingGradientBar .stocklist_enquire, .manufacturer_enquire, .stock_detail_button_row .enquire").click ( function ()
		{
			vehicle = "";
			if ($(this).attr("carname") != null)
				vehicle = $(this).attr("carname");
			
			window.location.href = "enquiry.php?vehicle=" + vehicle;
/*

			$("#enquiry").fadeIn('fast');

			$("#enquiry #callback_title span").html("Enquire Now");
			$("#enquiry .callback_right").html("<p>Leave your details below and we'll get back to you.</p>");
			$("#enquiry_your_offer").css("display", "none");
			
			
			
			$("#form_enquiry_vehicle").attr("value", $(this).attr("carname"));
			$("#enquiry_response").css("display", "none");

			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');*/
		});

		//Make an offer POPUP
		$(".stock_detail_button_row .offer").click ( function ()
		{
			$("#enquiry #callback_title span").html("Make us an Offer");
			$("#enquiry .callback_right").html("<p>Why not make us an offer? Enter your details below, together with your <cite>sensible</cite> offer and we'll get back to you!</p>");
			$("#enquiry_your_offer").css("display", "block");
			
			$("#form_enquiry_vehicle").attr("value", $(this).attr("carname"));
			$("#enquiry_response").css("display", "none");
			$("#enquiry").fadeIn('fast');

			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');
		});



/*
		$(".manufacturer_enquire").click ( function ()
		{
			$("#form_enquiry_vehicle").attr("value", $(this).attr("carname"));
			$("#enquiry_response").css("display", "none");
			$("#enquiry").fadeIn('fast');

			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');
		});
*/

		
		
		$("#enquiry .btnClose").click ( function ()
		{

			$("#pagefade").fadeOut('fast');
			$("#enquiry").fadeOut('fast');
		   
		});




		$(".military_discount_new_cars_search_left").click ( function ()
		{
			$(".military_discount_new_cars_search_left").css("z-index", "2");
			$(".military_discount_used_cars_search_right").css("z-index", "1");

			$(".military_discount_new_cars_search_left").css("background-image", "url(/images/panels/search_top_new_sel.png)");
			$(".military_discount_used_cars_search_right").css("background-image", "url(/images/panels/search_top_used.png)");

			$("#tax_free_car_search_new").css("display", "block");
			$("#tax_free_car_search_new").css("font-weight", "bold");
			$("#tax_free_car_search_used").css("display", "none");
			$("#tax_free_car_search_used").css("font-weight", "normal");
			newOrUsed = "new";
			
		});
		$(".military_discount_used_cars_search_right").click ( function ()
		{
			$(".military_discount_new_cars_search_left").css("z-index", "1");
			$(".military_discount_used_cars_search_right").css("z-index", "2");

			$(".military_discount_new_cars_search_left").css("background-image", "url(/images/panels/search_top_new.png)");
			$(".military_discount_used_cars_search_right").css("background-image", "url(/images/panels/search_top_used_sel.png)");


			$("#tax_free_car_search_new").css("display", "none");
			$("#tax_free_car_search_new").css("font-weight", "normal");
			$("#tax_free_car_search_used").css("display", "block");
			$("#tax_free_car_search_used").css("font-weight", "bold");
			newOrUsed = "used";
			
		});


		$(".stock_detail_small_links .print").click ( function ()
		{
			window.print();
		});
		$(".stock_detail_small_links .email").click ( function ()
		{
			window.location.href='mailto:?subject=EMC Forces Cars Website Link&Body=Hi, I found this website and thought you might like it: ' + window.location.href.replace(/&/g, "%26");
		});
													
	   
		

		$(".stock_tabs_top div").click ( function ()
		{
			var strObjToActivate = "#" + $(this).attr("tabToActive");
		
			//Hide previous tab


			//If no previously selected tab, unselect first tab
			if ( typeof(objStockSelectedTab) == "undefined")
				objStockSelectedTab = $("#tab_features");
			if ( typeof(objStockSelectedTabButton) == "undefined")
				objStockSelectedTabButton = $("#tab_button_features");
			
			//Hide previous tab
			objStockSelectedTab.css("display", "none");
			objStockSelectedTabButton.css("border-bottom", "1px solid white");

			//Show new tab
			$(strObjToActivate).css("display", "block");
			$(this).css("border-bottom", "none");
			
			objStockSelectedTab = $(strObjToActivate);
			objStockSelectedTabButton = $(this);
	
		});
		/*
		$(".military_discount_used_cars_search_right").click ( function ()
		{
			$("#tax_free_car_search_new").css("display", "none");
			$("#tax_free_car_search_used").css("display", "block");
			newOrUsed = "used";
			
		});*/

		//Load chat if someone online
	   var im = new Image();
	   im.onerror= function() {home_liveChat(this, 'off');}
	   im.onload= function() {home_liveChat(this, 'on');}
	   im.src = "http://dm1.contactatonce.co.uk/getagentstatusimage.aspx?MerchantId=84227&ProviderId=4855&PlacementId=1";
	   
	   
	   
		$(".callback_right input, .enquiry-details input, .callback_right textarea, .enquiry-details textarea, .callback_right select, .enquiry-details select").blur ( function ()
		{
//			alert("blur " + this.name);

			var formName = $(this).parents("form").attr("name");

			_gaq.push(['_trackPageview', "/enquiry/" + formName + "/textbox-leave?textbox=" + this.name]);

//alert("/enquiry/" + formName + "/textbox-leave?textbox=" + this.name);

			
		});
	   
	});
	
	function home_liveChat(objIm, onOrOff)
	{

		if (onOrOff == "on" && objIm.height > 1)
		{
			$(".military_discount_cars_free_call_back").css("display", "none");
			$(".military_discount_cars_live_chat").css("display", "block");
		}
		else 
		{
//			$(".military_discount_cars_live_chat").css("display", "none");
	//		$(".military_discount_cars_free_call_back").css("display", "block");
			
		}
	}
	








