/* setup the fantastic deals panel
----------------------------------------------------------------------- */
$(function() {
	// add the easyDeals banner
	$("#offer1").after("<p>easyDeals</p>");
	
	// create the dealall div
	$("<div id=\"dealall\"></div>").insertAfter("#dealcycle");
	$(".deals").clone().appendTo("#dealall");
	
	// hide the dealall div
	$("#dealall").hide();

	// cycle round the tbody table elements
	$("#dealcycle").cycle({
		fx:"fade",
		speed:2000,
		timeout:6000,
		cleartype:1
	});

	// show all deals when link is clicked
	$("a.seeall").toggle(function(){
		$("#dealcycle").fadeOut(300,function(){
            try{var sText = getElementById_s("uc_WeeklyDeals_hdnHideAllTxt").value;}
            catch (e){sText = getElementById_s("_ctl0_uc_WeeklyDeals_hdnHideAllTxt").value;}
			$(".seeall").html(sText);
			$("#dealall").slideDown(350);
	        $("#terms").show();
			$("#offer1").height(248).slideDown(350);
		});
	}, function(){
		// hide all deals when link clicked again
		$("#dealall").slideUp(450, function(){
			$("#offer1").height(87);
            try{var sText = getElementById_s("uc_WeeklyDeals_hdnShowAllTxt").value;}
            catch (e){sText = getElementById_s("_ctl0_uc_WeeklyDeals_hdnShowAllTxt").value;}
			$(".seeall").html(sText);
	        $("#terms").hide();
			$("#dealcycle").fadeIn(1000);
		});
	});
});

/* move factbox from top of page to after the newsletter/finder wrapper
----------------------------------------------------------------------- */
$(function() {
    $("#factbox").show();
	$("#factbox").remove().insertAfter("#newsletter_finder_wrapper");
});


/* One-way return location show/hide
----------------------------------------------------------------------- */
$(function() {
	$("#quote li.returnlocn").hide();
	$("#oneway").attr("checked",true);
	$("#oneway").click(function(){
		if ($("#oneway").is(":checked")){
			$("#quote li.returnlocn").slideToggle(200);
		} else {
			$("#quote li.returnlocn").slideToggle(400);
		}
	});
});




/* set the main_nav on state
----------------------------------------------------------------------- */
$(function() {
	$("#LogoTopBanner1_nav_main li").click(function(){
		$("#LogoTopBanner1_nav_main li").removeClass("on");
		$(this).addClass("on");
	});
});


/* set the sub_nav on state
----------------------------------------------------------------------- */
$(function() {
	$("#LogoTopBanner1_nav_sub li").click(function(){
		$("#LogoTopBanner1_nav_sub li").removeClass("on");
		$(this).addClass("on");
	});
});


/* datepicker invocation
----------------------------------------------------------------------- */
/*
$(function() {
	$("#LocationDateControl_txtStartDate, #LocationDateControl_txtEndDate").datepicker({
		yearRange:'2008:2011',
		dateFormat:'dd/mm/yy'
	});
});
*/

/* customer login show-hide
----------------------------------------------------------------------- */
$(function() {
	// hide the main form
	// Show the Main form if Error has occured in Login : Maulik : 12/Oct/08
    if ($("#LogoTopBanner1_BookerLogonErrLbl").text() == "")
    {
    	$("#loginform fieldset").hide();
    }
    else
    {
        // reveal the form and remove the last 2 nav options and the stelios logo
        $("#loginform fieldset").show();
		$("#LogoTopBanner1_nav_sub li:gt(0), #branding a + a").hide();
		$("#loginform fieldset").fadeIn(250);			
    }

	$(".btn_slide").toggle(function(){
		// reveal the form and remove the last 2 nav options and the stelios logo
		$("#loginform .hide").hide();
		$("#LogoTopBanner1_nav_sub li:gt(0), #branding a + a").hide();
		$("#loginform fieldset").fadeIn(250);			
		$(this).toggleClass("active");
	}, function(){
		// remove the form panel and re-display the nav options and stelios logo
		$("#loginform fieldset").fadeOut(150, function(){
			$("#LogoTopBanner1_nav_sub li:gt(0), #branding a + a").show();
		});
		$(this).toggleClass("active");
	});
});


/* remove input field default text on focus
----------------------------------------------------------------------- */
$(function() {
	$("input[type=\"text\"]").focus(function() {
		if ( $(this).val() == this.defaultValue ) {
			$(this).val("");
		}
	});
	$("input[type=\"text\"]").blur(function() {
		if ( $(this).val() == "" ) {
			$(this).val(this.defaultValue);
		}
	});
});

/* remove password field default text on focus
----------------------------------------------------------------------- */
$(function() {
	$("input[type=\"password\"]").focus(function() {
		if ( $(this).val() == this.defaultValue ) {
			$(this).val("");
		}
	});
	$("input[type=\"password\"]").blur(function() {
		if ( $(this).val() == "" ) {
			$(this).val(this.defaultValue);
		}
	});
});