jQuery(document).ready(function() {	
	// Menu
	$("#PrimaryNavigation .menu li").hoverIntent({
		sensitivity: 1, 
		interval: 1, 
		over: function() {
			$(this).addClass("selected");
			$(".sub", this).removeClass("hide").animate({opacity: .95}, 100);
		}, 
		timeout: 50, 
		out: function() {
			$(this).removeClass("selected");
			$(".sub", this).addClass("hide").animate({opacity: .0}, 100);
		}
	});
	$("#PrimaryNavigation .menu .sub").addClass("hide");
	
	// Homepage Feature Panel
	$("#Homepage .productlist li").click(
		function() {
			if($(this)[0].className != "" && $(this)[0].className != "view-range" && !$(this)[0].className.match("selected")) {
				$("#HeroImage img").attr("src", "media/images/hero-"+$(this)[0].className+".jpg");
				$(this).parents("ul").find("li").removeClass("selected");
				
				cUrl = window.location.toString().split("#");
				window.location = cUrl[0]+"#"+$(this)[0].className;				
				
				$(this).addClass("selected");
				
				return false;
			}
		}
	);
	if(document.getElementById('Homepage')) {
		if(window.location.toString().indexOf("#")>0) {
			cUrl = window.location.toString().split("#");			
			$(".productlist li").removeClass("selected");
			$(".productlist li."+cUrl[1]).addClass("selected");
		}
	}
	
	// Tooltips
	if(document.getElementById('Homepage')) {
		$("body").append('<div id="demotip">&nbsp;</div>');
		$("#Homepage img[title]").tooltip({ 
			tip: '#demotip',
			effect: 'slide',
			delay: 0
		}); 
	}
});

function printPage() {
	if (window.print) {
		window.print() ;
	} else {
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box WebBrowser1.outerHTML = "";
	}
}

// Debugging
jQuery.fn.debug = function() {
  return this.each(function(){
    alert(this);
  });
};
jQuery.log = function(message) {
  if(window.console) {
     console.debug(message);
  } else {
     alert(message);
  }
};