$(document).ready(function(){
	var menuWidth = $("body").width() - $("#logo").width() - 25;
	$("#mainNav").css("width", menuWidth)
						   
    var liveBase = 'http://www.cybersleigh.com';
	var baseUrl = getBaseURL();
	$("#mainNav li:first-child>a").attr("href", baseUrl);
	var trailingUrl = getTrailingURL();
	
	try{
		if(trailingUrl.length != 0 && trailingUrl != "index.html"){
			if(trailingUrl == "santa-claus.html"){
				trailingUrl = liveBase;
			}
			$("#mainNav li>div>a[href=" + trailingUrl + "]").children("img").attr("src", $("#mainNav li>div>a[href=" + trailingUrl + "]").children("img").attr("src").replace(/.png$/gi, "_over.png"));
			$("#mainNav li>div>a[href=" + trailingUrl + "]").parent().css("background", 'url(images/layoutImages/AnimatedSnowflakes.gif) no-repeat');
		}else{
			$("#mainNav li>div>a[href=" + liveBase + "]").children("img").attr("src", $("#mainNav li>div>a[href=" + liveBase + "]").children("img").attr("src").replace(/.png$/gi, "_over.png"));
			$("#mainNav li>div>a[href=" + liveBase + "]").parent().css("background", 'url(images/layoutImages/AnimatedSnowflakes.gif) no-repeat');
		}
	}catch(ex){}
	try{
		$("#mainNav li>div>a[href=" + liveBase + "]").attr("href", baseUrl);
	}catch(ex){}
	
	$("#mainNav a").mouseover(function(){
		imgsrc = $(this).children("img").attr("src");
		matches = imgsrc.match(/_over/);
		imgsrcON = imgsrc.replace(/.png$/gi, "_over.png");
		if (!matches) {
			$(this).children("img").attr("src", imgsrcON);
		}
	});
	$("#mainNav a").mouseout(function(){
		$(this).children("img").attr("src", imgsrc);
		$(this).parent("div").attr("background", 'none');
	});
});
