/*	Global Configuration
----------------------------------------------- */
jQuery.noConflict();
var $j = jQuery;
var isIE6 = false;
var isMac = false;
var isSafari = false;


/*	Browser Tests
----------------------------------------------- */
utilBrowserTests = function() {


	/* Checks for IE6 using object detection, then applies the fix for background flicker bug */
	if (typeof document.body.style.maxHeight == "undefined") { isIE6 = true; try { document.execCommand('BackgroundImageCache', false, true); } catch(e) { } }

	/* Checks for Safari and adds class of .safari to div#Container */
	if($j.browser.safari) { isSafari = true; $j("body").addClass("safari"); }

	/* Checks for Mozilla and applies the Opacity fix for Mac */
  	var userAgent = navigator.userAgent.toLowerCase();
	if (userAgent.indexOf('mac') != -1) { isMac = true; }
	if ($j.browser.mozilla && isMac) { $j("body").css('opacity', '.9999'); }

};


/*	Form Legends
----------------------------------------------- */
utilFormLegends = function() {
	$j("legend.accessibility").hide();
	$j("legend.ir").each(function(){
		var jObj = $j(this);
		var cssClassesStr = jObj.attr("class").toString();
		var cssClasses = cssClassesStr.split("ir replace-");
		jObj.after("<"+ cssClasses[1] + " class=\"ir legend\">"+ jObj.html() +"</"+ cssClasses[1] +">").remove();
		$j("h3.legend").prepend("<span></span>");
		$j("div.newsletter_form h4.legend").prepend("<span></span>");
		$j("div.hotelSelect form h4.legend").prepend("<span></span>");
	});
};



/*	Navigation highlighting
----------------------------------------------- */
bollocks = function() {
	$j("#wrap.home #header ul.sectionNav li:first-child").addClass("active");
	$j("#wrap.alice-howe #header ul.sectionNav li:first-child").next().addClass("active");
	$j("#wrap.boston-house #header ul.sectionNav li:first-child").next().next().addClass("active");
	$j("#wrap.bannerrigg #header ul.sectionNav li:first-child").next().next().next().addClass("active");
	$j("#wrap.marine-crescent #header ul.sectionNav li:first-child").next().next().next().next().addClass("active");
	$j("#wrap.oaklands #header ul.sectionNav li:first-child").next().next().next().next().next().addClass("active");
	};
	


/*	Visitors Book Form
----------------------------------------------- */

function revealVisitorForm() {
	
	var revealArea = $j('div#reveal');
	var vistorFormClick = $j("form#visitors_book p.action a");

	revealArea.hide();
	vistorFormClick.toggle(function() {
		revealArea.slideDown('slow');
	}, function() {
		revealArea.slideUp('slow');
	});	
}
	
	

	
	

/*	DOM Ready events
----------------------------------------------- */
$j(document).ready(function() {

	utilBrowserTests();
	utilFormLegends();
	bollocks();
	revealVisitorForm();

	
});


