/*
	On ready for all pages
*/
var $nav_obj;
$(function(){
	//set up main nav
	$nav_obj = $("#mainNav").nav({
		defaultPage	: "/",
		$loaderBar	: ($("#loaderBarWrapper")),
		changeHash	: true,
		modifyURL	: function(reqObj){
			var href = reqObj.href, d = reqObj.data;
			//articles are pulled dynamically (implementation specific)
			hrefArr = href.split("/");
			if(hrefArr[1] === "article"){
				//articles are dynamic hrefArr
				href = hrefArr[0]+"/"+hrefArr[1]+".php";
				d.article_id = hrefArr[2];
								
			}else if(hrefArr[2] === "request_pro_forma"){
				//send som cool data dadyyo
				href = hrefArr[0]+"/"+hrefArr[1]+"/"+hrefArr[2]+".php";
				d[hrefArr[3]] = true;											
			}
			return {href:href, data:d}
		}			
	});
    $nav_obj.mainNav();
    
   //some textarea/input effects				
	$("textarea, input").live("focus", function(){
		var $t = $(this);					
		if($t.attr("rel") !== "focused"){
			$t.attr("rel", "focused").val("").css("color", "#848484");
		}
	});
	
	$("#footerRight a").css({opacity: 0.6}).hover(function(){
		$(this).clearQueue().fadeTo(250, 1);
	}, function(){
		$(this).clearQueue().fadeTo(250, 0.6);
	});
	
	
	$("a.print").live("click", function(e){
		window.print();
		e.preventDefault();
		return false;
	});
});				
function clearNavPage(href){
	$nav_obj.nav("clearPage", href);
}	


/*
	Typekit init block

	Typekit looks bad in old windows. soooo lets not use it for old windows
*/		
var userAgentArr = navigator.userAgent.split(/\s*[;)(]\s*/), i, windowsArr, windowsVersion = 0, useTypekit = true, typeKitReady=false;			
for(i=0; i<userAgentArr.length; i++){
	if(userAgentArr[i].search("Windows NT ") != -1){
		windowsVersion = Number((userAgentArr[i].split("Windows NT "))[1]);
		if(!isNaN(windowsVersion)){
			useTypekit = windowsVersion >= 6;
		}
	}
}		
if(useTypekit){
	try{Typekit.load({
		active : function(){
			typeKitReady = true;
		}
	});}catch(e){}
}	
