/*
Add Load Events
*/
function addLoadEvent(a){var b=window.onload;if(typeof window.onload!='function'){window.onload=a}else{window.onload=function(){if(b){b()}a()}}}function addUnloadEvent(a){var b=window.onunload;if(typeof window.onunload!='function'){window.onunload=a}else{window.onunload=function(){if(b){b()}a()}}};




var bwIE60 = (navigator.appVersion.indexOf("MSIE 6.0") != -1) ? "True" : "False";
var bwIE70 = (navigator.appVersion.indexOf("MSIE 7.0") != -1) ? "True" : "False";

$(document).ready(function () {
	// top menu
	$(".menuMain li").each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("menuMainSelected");
			var offset = $("a:first", this)[0].offsetLeft;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
			}
			$("div:first", this).css("left", offset + "px");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("menuMainSelected");
		});
	});

	// model menu
	$(".menuModel li", this).each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("menuModelSelected");
			$("div:first", this).show();
			var offset = $("a:first", this)[0].offsetLeft;
			var width = $("div:first", this)[0].offsetWidth;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
			}
			if (offset + width > 900) {
				var diff = 899 - (offset + width);
				offset = offset + diff;
			}
			$("div:first", this).css("left", offset + "px");
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("menuModelSelected");
		});
	});
	
	// Third Level menu
	$(".menuModelDetail li").each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("menuModelDetailSelected");
			var offset = $("a:first", this)[0].offsetLeft;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
			}
			$("div:first", this).css("left", offset + "px");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("menuModelDetailSelected");
		});
	});
	
	// Vertical menu
	$(".menuVertical li").each(function () {
		// menu SHOW
		$(this).mouseenter(function () {
			$("a:first", this).toggleClass("menuVerticalSelected");
			var offset = $("a:first", this)[0].offsetLeft;
			if (bwIE60 == "True" || bwIE70 == "True") {
				offset = this.offsetLeft;
			}
			$("div:first", this).css("left", 210 + "px");
			$("div:first", this).show();
		});
		// menu HIDE
		$(this).mouseleave(function () {
			$("div:first", this).hide();
			$("a:first", this).toggleClass("menuVerticalSelected");
		});
	});
});


// Outrider Tracking Tags

var refr=document.referrer; /* get the http referer */

var dom=location.hostname; /* get the host domain */

var matchRegEx = new RegExp("^https?://" + dom.replace(/\W/g, "\\$&") + "([:/?].*|)$", "i");

if( (refr && !matchRegEx.test(refr)) && (location.href.toUpperCase().indexOf("247SEO=N") == -1) ){ /* if the referrer is external preload the image request and does not contain 247SEO argument = "N" */

var stURL="http://au.track.decideinteractive.com/n/66723/66725/www.skoda.com.au/drzys4;11;3;;6;;ak78h1;;;;;1;/i/c?0&1pixgif&referer=" + escape(refr);

imageTR = new Image();

imageTR.src = stURL;

}



//Mediacom tracking tag for brochures

function ebConversionTracker(conv)
{
      var ebConversionImg = new Image(); 
      var ebConversionURL =  "HTTP://bs.serving-sys.com/BurstingPipe/ActivityServer.bs?"  
      ebConversionURL +=  "cn=as&ActivityID="+conv+"&ns=1";
      ebConversionImg.src = ebConversionURL;
}



