// replace contact us image with contact vw image
function replaceLeftNavImage(e, obj){
	if(obj.isDealerSession){ 
	    timesCreated++
	    if(timesCreated <= 1){
		    var pTag1 = window.document.getElementById("m_contactUs_img");
		    var loc = pTag1.src;
		    var locArr = loc.split('/');
		    var baseImagePath = "/"+locArr[3]+"/"+locArr[4]+"/"+locArr[5]+"/"+locArr[6]+"/"+locArr[7]+"/"+locArr[8]+"/m_contactVW_";
		    var basePingPong = "pngpong.util.swapImage('m_contactUS_img', '";
		    if(util.getBrowser() != "ie"){
			    if(pTag1.getAttribute("onmousedown") == null){
				    pTag1.src = baseImagePath+"active.gif";
			    }else{
				    pTag1.src = baseImagePath+"out.gif";
				    pTag1.setAttribute("onmouseover", basePingPong+baseImagePath+"over.gif');");
				    pTag1.setAttribute("onmouseout", basePingPong+baseImagePath+"out.gif');");
			    }
		    }else{
			    if(pTag1.onmousedown == null){
				    pTag1.src = baseImagePath+"active.gif";
			    }else{
				    pTag1.src = baseImagePath+"out.gif";
				    pTag1.onmouseover = function(){pTag1.src = baseImagePath+"over.gif"};
	    		    pTag1.onmouseout = function(){pTag1.src = baseImagePath+"out.gif"};
			    }
		    }
    		
		    var url = window.location.href;
		    var location = url.split("/");
		    if(location[3]+"/"+location[4]+"/"+location[5]+"/"+location[6] == "customerservice/contactus/en/us"){
			    $('#q4').find('div:last a').next().remove();
			    $('#q4').find('div:last a').next().remove();
			    $('#q4').find('div:last a').remove();
			    $('#q5').find('div:first').html('Contact Dealer');
			    $('#q5').find('div:last a u').html('Click here to contact dealer');
			    $('#q5').find('div:last a').attr({href:"http://"+dealersession.dealerDomain+"/ContactUsForm"});
		    }
		    // FAQ section - swap some text/add some text
		    switch(document.title){
			    case "Customer Service FAQS - Top FAQs":
				    var csquestion = '<br/>&bull; <a href="#q4">How do I contact my local dealership?</a>';
					csquestion += '<br/>&bull; <a href="#q5">How do I change dealerships?</a>';
				    var csitems = '<div id="q4" class="cs_item"><div class="cs_item_heading">How do I contact my local dealership?</div><div class="cs_item_body">Simply <a href="http://'+dealersession.dealerDomain+'/ContactUsForm/">click here.</a> If it were any easier, telepathy would be involved. We\'re looking into it.</div></div>';
				    csitems += '<div id="q5" class="cs_item"><div class="cs_item_heading">How do I change dealerships?</div><div class="cs_item_body">Locate the widget on the top left of the page. Select "Your Dealer. Then click "Switch Dealer" on the bottom right. Enter the zip code for the dealership region you prefer, then click "Launch Dealer Site."</div></div>';
					$('.cs_headerNav_anchors').append(csquestion);
				    $('.cs_items').append(csitems);
				    break;
			    case "Customer Service FAQS - Vehicle Pricing and Purchase":
				    var csitems = '<div class="cs_item_body">Yes, just go to your <a href="http://'+dealersession.dealerDomain+'/NewVehicleSearch/">local dealer\'s site</a> to check out their collection of Volkswagen models and find the one that\'s perfect for you.</div>';
				    $('.cs_items').find('#q3').find('.cs_item_body').html(csitems);
				    break;
		    }
        }
	}
}

var timesCreated = 0;
$(document).ready( function(){
	$(document).bind("session:dealer", replaceLeftNavImage);
	try{
		if(dealersession){ //used if not cached
			if(dealersession.isDealerSession == true){
				replaceLeftNavImage({}, dealersession);
			}
		}
	}catch(e){
	}
});