// Core JavaScript Document for Jacqui-E //

$(function(){

	//always add class 'last-child' to last element in a list
	$("li:last-child").addClass("last-child");
	
	//animation effect in header menu
	$(".header").append("<div class='moving-block'></li>");
	var current = $(".header li a."+$("body").attr("id")); //cant use .current b/c jquery.dimensions has not run on it
	$(".header .moving-block").css("width", current.outerWidth()  );
	$(".header .moving-block").css("left", ($(".header .menu").position()).left + (current.position()).left +17 );
	$(".header li a").hover(
		function () {
			$(".header .moving-block").stop().animate({ 
				width: $(this).outerWidth(),
				left: ($(".header .menu").position()).left + ($(this).position()).left +17
			}, 600 );
		},
		function () {
			$(".header .moving-block").stop().animate({ 
				width: current.outerWidth(),
				left: ($(".header .menu").position()).left + (current.position()).left +17
			}, 400 );
		}
	);
	
	//make curent link 'current'
	$("a").each(function(i){
		if( $("body").attr("id") == $(this).attr("class") || $("body").attr("class") == $(this).attr("class") || $(".content").attr("id") == $(this).attr("class") ) {
			$(this).addClass("current");
		}
	});
	
	//banner
	//var randBanner = "/images/banner/banner" + String(Math.floor(Math.random()*3)+1) + ".jpg";
	//$(".banner img").attr("src",randBanner);
	swfobject.embedSWF("/swf/banner.swf", "flashbanner", "950", "200", "8.0.0", "/swf/expressInstall.swf", null, {wmode: "transparent", menu: "false"}, null);
	$(".banner").css("display","block");
	
	//share bar
	$(".sharebar").css("display","block");
	
	//add quotes to Blockquote tag
	$("blockquote").prepend("&quot;");
	$("blockquote").append("&quot;");
	
	//add letters 'Q' and 'A' to faq lists
	$("dl.faqs dt").prepend("<span>Q.</span>");
	$("dl.faqs dd").prepend("<span>A.</span>");

	//add notification on DEV & STAGING
	if( window.location.hostname == "10.0.7.141" ) {
		$("body").prepend("<div class='server-name'>Development</div>");
	} else if ( window.location.hostname == "10.0.7.128" ) {
		$("body").prepend("<div class='server-name'>Staging</div>");
	}
	
});

//popup window
function popup( url, width, height ) {
	var winLeft = (screen.width - width)/2;  	//Auto position popup in center of screen
	var winTop = (screen.height - height)/2;	//Auto position popup in center of screen
	var newwindow = window.open( url, "popup", ('width='+width+', height='+height+', resizable=yes, scrollbars=yes, menubar=no, status=yes, top='+winTop+', left='+winLeft )); 
	if (window.focus) {newwindow.focus()}
}
