/* 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>");
	});
};
	
/* Recruitment form */
recruitmentForm = function() {
		$j('div.reveal').hide();
		$j("li p.readMore a").click(function() {
        $j(this).parents('p').next('div.reveal').slideDown('medium');return false; 	
	});	
			$j("li p.close a").click(function() {
        $j(this).parents('div.reveal').slideUp('slow');return false; 	
	});	
		};

/* DOM Ready events */
$j(document).ready(function() {
    utilBrowserTests();
    utilFormLegends();
    initsideMenus();
    recruitmentForm();
    $j(".ir").prepend("<span></span>");
    $j("#footer p.ir span").remove();
    $j("#footer p.ir a").prepend("<span></span>");
    $j("h1,h2").wrapInner(document.createElement("span"));
    $j.localScroll();
    $j('h1.text-display-content, h2.text-display-content').hide();
    $j('h1.text-display-content').show('slow');
    $j(this).delay(350, function() {
        $j('h2.text-display-content').show('slow');
    });
});
