$(document).ready(function() {
	//make sig pretty
	$("#signature div.tel").prepend('Phone: ');
	$("#signature div.fax").prepend('Fax: ');
	$(".locality").append(', ');
	// $(".region").append(', ');
	
			// tiny bit of house keeping!
			var sidebarheight = $("#guts").height();
			if(sidebarheight < 475){ // this is just saul's preferred number - not really based on anything but eye
				$("#sidebar h6").addClass("short");
				
				// $("#footer").css("margin-top", "-120px");
				// $("div").css("border", "solid");
				// $("#footer").css("margin-left", "295px");
			}
			if ($("div.bookwrapper").length > 0) {
				$("div.bookwrapper").css("cursor","pointer").click(function() {
					window.location.href = catreg;
				});
			}
		
		$("#dosearch").click(function() {
			var kw = $("#skeywords").val();
			if(kw == " Search" || kw == "Search"){
				return;
			}else{
				$("#search_form").submit();
			}
		});
		
		$("#skeywords").focus(function(){ 
		        var defaultText = $(this).val(); 
		        $(this).val(''); 
		        $("input").blur( function () { 
		        var userInput = $(this).val(); 
		        if (userInput == ''){  $(this).val(defaultText);  } 
		        }); 
			});
			
	//navigational flyout
	var flyout = function() {
		this.navLi = $('#nav li').children('ul').hide().end();
		this.init();
	};
	flyout.prototype = {

	 	init : function() {
	 		this.setMenu();
	 	},
	 	setMenu : function() {
		
	 	$.each(this.navLi, function() {
	 		if ( $(this).children('ul')[0] ) {
	 			$(this)
	 				.append('<span />')
	 				.children('span')
	 				.addClass('hasChildren')
	 		}
	 	});
	 		this.navLi.hoverIntent(function() {
	 			// mouseover
				$(this).find('> ul').stop(true, true).slideDown('fast', 'linear');
	 		}, function() {
	 			// mouseout
	 			$(this).find('> ul').stop(true, true).hide(); 		
			});

	 	}

	}
	
$('#nav_categories').append("<li><a href=\"http://globesprinkler.com/index.php/products/view/product_related_documents\">Product Related Documents</a></li>");
	$('#nav li ul li ul li ul').children().remove();
	new flyout();
	

/*
$("#subnavigation>li ul").hide();
$('#subnavigation>li').click(function() {
$(this).children('ul').slideToggle(200); //Hides if shown, shows if hidden
}).mouseover(function(){ $(this).addClass("a_hand") }); //Hand!
*/


});


function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'addressbar=0,toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1');");
}
