/// <reference path="~/scripts/jquery-1.3.2-vsdoc.js" />

$(document).ready(function() {
	$("div#menu ul a").hover(
		function () {
			var $img = $(this).find("img");
			$img.attr("src", "./images/menu/" + $img.attr("alt").replace(/ /g, "-").toLowerCase() + "-on.jpg");
		}, 
		function () {
			var $img = $(this).find("img");
			if (!$(this).hasClass("current")) {
				$img.attr("src", "./images/menu/" + $img.attr("alt").replace(/ /g, "-").toLowerCase() + ".jpg");
			}
		}
	);
	
	// preload images
	var img;
	img = new Image(); img.src = "./images/menu/about-us-on.jpg";
	img = new Image(); img.src = "./images/menu/stores-on.jpg";
	img = new Image(); img.src = "./images/menu/music-on.jpg";
	img = new Image(); img.src = "./images/menu/blog-on.jpg";
	img = new Image(); img.src = "./images/menu/careers-on.jpg";
});

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}

function _open(event, source)
{
	var newWindow = window.open(source);
	newWindow.focus();
	event.returnValue = false;
	return false;
}
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();
}
    
function _isValidEmail(email)
{
    var reg_exp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    return reg_exp.test(email);
}


function _getScrollY()
{
   var scrollY;

   if (document.all) /* Internet Explorer */
   {
        if (!document.documentElement.scrollTop)
           scrollY = document.body.scrollTop;
        else
           scrollY = document.documentElement.scrollTop;
   }   
   else
       scrollY = window.pageYOffset;
        
   return scrollY;
}

function _getWindowHeight()
{
	var height;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		height = window.innerHeight;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		height = document.documentElement.clientHeight;
	}
	return height;
}

function _getDocHeight()
{
	return Math.max(document.documentElement.scrollHeight, _getWindowHeight());
}