//'Clicks' the Login button when Enter is pressed in
//the email or password text boxes
function enterHandler(e, buttonID) {
	var bReturn = true;
	
	if (e.which == 13 || e.keyCode == 13) {
		document.getElementById(buttonID).click();
		bReturn = false;
	}

	return bReturn;
}


function detectFlash() {
    alert(navigator.mimeTypes.length);
    if (navigator.plugins && navigator.plugins.length) {
	    if (navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"]) {
	        return true;
	    }
    }
    else if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]){
        return true;
    }
    
    return false;
}

function ToggleCalendarFrame(calendarId, textboxId) {
    var obj = document.getElementById(calendarId);
    var txt = document.getElementById(textboxId);
    
    var changed = obj.innerHTML.indexOf(textboxId) < 0;

    if (obj.innerHTML == "" || changed == true) {
        obj.innerHTML = "<iframe frameborder='0' scrolling='no' style='width: 180px;' src='" + DATE_PICKER_URL + "?target=" + textboxId + "&calendar=" + calendarId + "'></iframe>";
    }
    else {
        obj.innerHTML = "";
    }
}

function InitDate(textboxId) {
	var txt = document.getElementById(textboxId);
	
	if (txt.value == "dd/mm/yyyy") {
		txt.value = '';
	}
}

$(document).ready(function() {
	$('#searchoptions').click(function() {
		//$('#overlay').css({'width' : $(document).width(), 'height' : $(document).height(), 'display' : 'block'});
		$('#user-options').css('display', 'none'); // hide user options, if open, first
		$('#advancedsearchwrapper').css('display', 'block');
		$('#AttractionSearch_4_cboGenreID').focus();
		$('#advancedsearchclose').click(function() {
			//$('#overlay').css({'width' : '0', 'height' : '0', 'display' : 'none'});
			$('#advancedsearchwrapper').css('display', 'none');
		});
	});
	$('#user-options').css('display','none');
	$('#user-options-toggle').click(function() {
		$('#overlay').css({'top' : 0, 'width' : $(document).width(), 'height' : $(document).height(), 'display' : 'block'});
		$('#advancedsearchwrapper').css('display', 'none'); // hide advanced search, if open, first
		$('#user-options').slideDown();
		$('#overlay, #user-options').click(function() {
			$('#overlay').css({'width' : '0', 'height' : '0', 'display' : 'none'});
			$('#overlay, #user-options').slideUp();
		});
	});
	$('#accessibility_wrapper').css('display','none');
	$('h3#accessibility').before('<a id="accessibilityToggle" href="javascript:void(0);" title="Click for accessibility info">Accessible facilities ...</a>').remove();
	$('#accessibilityToggle').click(function() {
		$('#accessibility_wrapper').toggle();
		$('#planwrapper,#otherattractions').hide().show(); // poor IE doesn't get it..
	})
	$("#tabs.home").semantictabs({
	  	head: 'h3'
	});
	$('ul.mainoffers li, #tabs ul.offerlist li', '#bottom').each(function() {
		if($(this).find('a span img').attr('src') == '') {
			$(this).remove();
		}
	});
	$('#promoboxes div.promobox').click(function() {
		window.location = $(this).find('h3 span a').attr('href');
	});
	$('#container_footer').hide().show(); // poor IE doesn't get it here either..
	if(typeof sIFR == "function") {
		//sIFR.replaceElement(named({sSelector:"body h1", sFlashSrc:"tradegothic.swf", sColor:"#000000", sLinkColor:"#000000", sBgColor:"#FFFFFF", sHoverColor:"#CCCCCC", nPaddingTop:20, nPaddingBottom:20, sFlashVars:"textalign=center&offsetTop=6"}));
		//var template = named({sFlashSrc : "./vandenkeere.swf", sColor : "#000", sCase : "upper"});
		//sIFR.replaceElement("h1", template);
		sIFR.replaceElement(named({sSelector:"h1.home_header,h1 span", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", sFlashVars:"textalign=center"}));
		sIFR.replaceElement(named({sSelector:"#top h1#attractionTitle, #top #leftcol h1, #top #maincolumn h1, #top #leftcolumn h1", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#advancedsearchpanel h2", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#ffffff", nPaddingBottom:15, sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"h2", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", nPaddingBottom:15, sFlashVars:"textalign=left"}));
        sIFR.replaceElement(named({sSelector:"#latestoffer h3", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#centralpromos .mainpromo h3", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", nPaddingBottom: 20, nPaddingTop: 10, nPaddingLeft: 10, sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#centralpromos h3", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#tabs h3", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", nPaddingBottom:15, sFlashVars:"textalign=center"}));
		sIFR.replaceElement(named({sSelector:"#attr_right h3", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#003465", nPaddingBottom:15, sFlashVars:"textalign=left"}));
		sIFR.replaceElement(named({sSelector:"#planwrapper h1,#groupsave h1", sCase : "upper", sFlashSrc:"/App_Themes/BVF/flash/futura-std.swf", wmode: 'transparent', sColor:"#ffffff", nPaddingBottom:15, sFlashVars:"textalign=left"}));
	}
});