// 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()
	{
		
		$(".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").fadeIn('fast');
			
		},
		function ()
		{

			$(this).children("ul").fadeOut('fast');
			
		})
		;
		
		$(".usede_citroen_eastbourne_free_call_back").click ( function ()
		{
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#pagefade").fadeIn('fast');
			$("#callback").fadeIn('fast');
		});


		$(".used_bmw_eastbourne_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").fadeIn('fast');
			$("#newsletter").fadeIn('fast');
		});


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


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

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

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

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

		//Pricing help buttons clicked
		$(".stock_pricing div img").click ( function ()
		{
			$("#pagefade").css('filter', 'alpha(opacity=70)'); //IE8 Bug Fix
			$("#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('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");

			$("#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 .brochure, .stocklistingGradientBar .px").click ( function ()
		{
			
			window.open(window.location.href.replace("#","") + "&brochure=true",'brochure','scrollbars=yes,resizable=yes,width=1024,height=768');
			return false;
		});

		

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

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

		//Enquiry POPUP
		$(".stocklistingGradientBar .stocklist_enquire, .manufacturer_enquire, .stock_detail_button_row .enquire, .linkEnquiry, .btnEnquiry").click ( function ()
		{
			
			vehicle = "";
			if ($(this).attr("carname") != null)
				vehicle = $(this).attr("carname");

//			alert($(this).attr("isMobile"));
				
			if ($(this).attr("isMobile") == "true")
			{
				vehicle = vehicle.replace("#", "");
				
				window.location.href="mobile_contact.php?vehicle=" + vehicle;
			}
			else
			{
				popup_new_launch("pop_enquire", this, vehicle);
			}

/*			
//			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');
			
			*/
		});



		//Friend POPUP
		$(".stocklistingGradientBar .stocklist_email, .manufacturer_email, .stock_detail_button_row .email").click ( function ()
		{
			
			vehicle = "";
			if ($(this).attr("carname") != null)
				vehicle = $(this).attr("carname");

			popup_new_launch("pop_email", this, vehicle);

			/*
//			window.location.href = "enquiry.php?vehicle=" + vehicle;


			$("#email_friend").fadeIn('fast');
//			alert($("#email_friend").attr("id"));

			
//			alert( $(this).attr("carname"));
			$("#form_email_vehicle").attr("value", $(this).attr("carname"));
			$("#email_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');
		});
*/

		
		
		$(".popup_new_title .btnClose").click ( function ()
		{

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

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

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




		$(".military_discount_new_cars_search_left").click ( function ()
		{
			$("#tax_free_car_search_new").css("display", "block");
			$("#tax_free_car_search_used").css("display", "none");
			newOrUsed = "new";
			
		});
		$(".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";
			
		});

		$(".stock_detail_small_links .print").click ( function ()
		{
//			window.print();
		});
		$(".stock_detail_small_links .email").click ( function ()
		{
//			window.location.href='mailto:?subject=EMC Tax Free 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";
	   
	   
	   
		$(".stock_detail_button_row .social").click ( function ()
		{
			popup_new_launch("pop_social", this, "");
		});

		$(".stock_detail_button_row .carfinder, .linkCarFinder").click ( function ()
		{
			popup_new_launch("pop_carfinder", this, "");
		});

		$(".btnBookService").click ( function ()
		{
			popup_new_launch("pop_bookservice", this, "");
		});

		$(".eastbourne_car_sales_live_video_presentation, .stock_detail_live_video").click ( function ()
		{
			vehicle = "";
			if ($(this).attr("carname") != null)
				vehicle = $(this).attr("carname");
//alert(vehicle);
			popup_new_launch("pop_video", this, vehicle);
		});

		



		$(".stock_detail_button_row .testdrive").click ( function ()
		{
			vehicle = "";
			if ($(this).attr("carname") != null)
				vehicle = $(this).attr("carname");

			popup_new_launch("pop_testdrive", this, vehicle);
		});

		$(".btnAddTestimonials").click ( function ()
		{
			popup_new_launch("pop_testimonial", this, "");
		});


		$(".home_panel_top_right_mask, #home_image_swap_reduced").click ( function ()
		{

			window.location.href = click_href;
			
		});

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


		$(".eastbourne_car_sales_mobile_seach_site").click ( function ()
		{

			window.location.href = "mobile_intro.php";
			
		});

	   
	});
	
	function home_liveChat(objIm, onOrOff)
	{

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

	function popup_new_launch (divname, objClicked, vehicle)
	{
			

		var contentDiv = $("#" + divname);

		//Set popup window title
		$("#popup_new_title_text").text(contentDiv.attr("popup_title"));
		
		//Hide any existing content
		$(".popup_new_right div.content_holder").css("display", "none");
		$(".popup_new_right #response").css("display", "none");
				
		contentDiv.css("display", "block");
		contentDiv.find("form").css("display", "block");

		
		contentDiv.find(".vehicle").attr("value", vehicle);
		
//		alert(contentDiv.find(".vehicle").length)

		var popupWidth = parseInt(contentDiv.attr("popup_width"));
		var popupMarginLeft = Math.round((popupWidth/2), 0);
		var popupHeight = parseInt(contentDiv.attr("popup_height"));
		var popupMarginTop = Math.round((popupHeight/2), 0);

		$(".popup_new").css("width", (popupWidth + "px"));
		
		$(".popup_new").css("margin-left", "-" + popupMarginLeft + "px");

		$(".popup_new").css("height", popupHeight + "px");
		$(".popup_new").css("margin-top", "-" + popupMarginTop + "px");

		
		$(".popup_new").fadeIn('fast');

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

		

	}





