$(function() {
	// lazy load thawte logo asyc
	$("#thawte-logo").after('<script type="text/javascript" src="https://seal.thawte.com/getthawteseal?host_name=www.henbrandt.co.uk&amp;size=M&amp;lang=en" async="async"></script>');
	
    //hide when JS off
    $('.search').val('');
    // Select Internet Explorer
    if ($.browser.msie) {
        $("#search_site").css("top","2px");
    };
    // Select Internet Explorer 7 and below
    if (jQuery.browser.msie && jQuery.browser.version <= 7) {
        $("#f-ss legend").css("left","-102px");
    };
    // Select Internet Explorer 7 and below
    if (jQuery.browser.msie && jQuery.browser.version <= 7) {
        //$("#menu .wrap").css("height","310px");
    };    
        
    // Select Internet Explorer 7
    if (jQuery.browser.msie && jQuery.browser.version == 7) {
        $("#featured").css("z-index","-1");
    };
    //hover handlers
    $("#menu li").mouseover(function() {
        $(this).addClass('hover');
    });
    $("#menu li").mouseout(function() {
        $(this).removeClass('hover');
    });
    $("#menu li").children().mouseout(function() {
        $(this).removeClass('hover');
    });
    //main menu
    //$('#menu .hi').append('<div class="br"></div>');
    
    //mac only
    if(navigator.appVersion.indexOf("Mac")!=-1) {
        //$('#menu li.last').addClass('last-mac');
    };
    //if side left height is bigger than content make content same height
	if (parseInt( $('#side-left').height() ) + $("#border").height() > parseInt ( $('#main').height() ) ){
		$('#main').css('height', parseInt($('#side-left').height()) + 153);
    };

	//bring links to parent level
	$(".side-link").live("click",function() {
		self.location = $(this).find('a').attr("href");
	});
	//print page
	$(".print").click(function(){
		window.print();
		return false;
	});

	// make popup notifications
	if($("p.popup-alert").size())
	{
		$("p.popup-alert").dialog(
		{
			modal:true,
			draggable:false,
			resizable:false,
			width:500,
			height:100,
			dialogClass:'jq-popup'
		});

		// close popup after a set time
		closeAfter = $("p.popup-alert").attr('rel');
		if (!closeAfter) closeAfter = 1500;
		//alert($("p.popup-alert").attr('rel'));
		setTimeout('$("p.popup-alert").dialog("close");', closeAfter);

		// close dialogue box when user clicks anywhere
		$('body').click(function()
		{
			$("p.popup-alert").dialog("close");
		});
	}
	if($("p.popup-alert-wait").size())
	{
		$("p.popup-alert-wait").dialog(
		{
			modal:true,
			draggable:false,
			resizable:false,
			width:500,
			height:200,
			dialogClass:'jq-popup',
			buttons: [
			    {
			        text: "Ok",
			        click: function() { $(this).dialog("close"); }
			    }
			]
		});

		// close dialogue box when user clicks anywhere
		$('body').click(function()
		{
			$("p.popup-alert-wait").dialog("close");
		});
	}

	// disable 'enter' submit on forms with many buttons
	$('form.noenter').keypress( function(evt){
		var evt = (evt) ? evt : ((event) ? event : null);
		var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
		if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
	} )

});
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
window.onload=startList;
