$(document).ready(function() {

	if ( typeof(menu) !== "undefined") {
		// add the menus to the DOM
		for(key in menu) {
			var str = '<div class="subMenu">';
			var subMenu = menu[key];
			for(subKey in subMenu) {
				str += '<div><a href="' + subMenu[subKey] + '">' + subKey + '</a></div>';
			}
			str += '</div>';
			$("#" + key).append(str);
		}
		// show and hide the sub-menus on hover 
		$("#priNav .menu").hover( function () {
			$(this).find(".subMenu").show();
			t = $(this).find("img").attr("title"); // hide the images title as was
			$(this).find("img").attr("title", ""); // causing mouseout probs in safari
		}, function () {
			$(this).find(".subMenu").hide();
			$(this).find("img").attr("title", t); // restore the image title
		} );
		// add a hover class - because ie doesn't support 
		// css :hover styles on anything other than an anchor
		$("#priNav .menu .subMenu div").hover( function () {
			$(this).addClass("hover");
		}, function () {
			$(this).removeClass("hover");
		} );
		// trigger the image hover on the parent menu image
		$("#priNav .menu .subMenu").hover( function () {
			$(this).prev("a").find("img").trigger('mouseover');
		}, function () {
			$(this).prev("a").find("img").trigger('mouseout');
		} );
	}

	// product image zoom
	var jqzoomOptions = {
		zoomWidth: 438,
		zoomHeight: 390,
		title: false
	}
	$("#mainPic").jqzoom(jqzoomOptions);

	// mouse over images
	$('#priNav img').imghover();

});
