/// <reference path="~/scripts/jquery-1.3.2-vsdoc.js" />

var mmTimeout;
var mmCurHover, mmTmpHover;

$(document).ready(function() {
	// h1 -> replace w/ image
	/*
	$("h1.h1img").each(function() {
		var h1Text =  $(this).html();
		$(this)
		// /g: global search
		.html('<img src="/images/h1/' + h1Text.toLowerCase().replace(/ /g, "") + '.jpg" alt="' + h1Text + '" />')
		.css("padding", "0");
	});
	*/
	
	// logo 
	$("#logo img").hover(
		function () { 
			$(this).attr("src", "/images/logo-hover.jpg");
		}, 
		function () {
			$(this).attr("src", "/images/logo.jpg");
		}
	);
	
	// main menu hover functionality
	$("#menu li.wSub").hover(
		function () { 
			$(this).find("div.mmSub").show();
			/*
			mmTmpHover = $(this).attr("id");
			if (mmCurHover == mmTmpHover)
				clearTimeout(mmTimeout); // don't hide if we're on the same menu item
			
			mmCurHover = mmTmpHover;
			$(this).find("div.mmSub").fadeIn(300);
			*/
		}, 
		function () {
			$(this).find("div.mmSub").hide();
			//var menuHandle = $(this).find("div.mmSub");
			//mmTimeout = setTimeout(function() { hideMenuSub(menuHandle);}, 300);
		}
	);
	
	
	// set new window functionality for all external links
	$("a[rel=external]").click(function(event) {
		event.preventDefault();
		
		var newWindow = window.open($(this).attr("href"));
		newWindow.focus();
	});
	
	$("a.designCenterLnk").click(function(event) {
		event.preventDefault();
		_openPopUp('http://www.wayne-dalton.com/dsc2/index.html', 'DesignCenter', 1006, 667);
	});
	
});


function hideMenuSub($this) {
	$this.hide();
}

function _openPopUp(source, name, width, height)
{
	var selectSource = window.open(source, name,'width=' + width + ',height=' + height + ',top=' + height/2 + ',left=' + width/2 + ',scrollbars=1,location=0,status=1,resizable=1,menubar=0');
	selectSource.focus();
}