﻿jQuery(function() {

    $('#home-image-container').cycle('fade');
    $('#retail-image-container').cycle('fade');

});

function showLoginContainer() {
    jQuery("#login-form").show(600);
}

function hideLoginContainer() {
    jQuery("#login-form").hide(600);
}

function clearSearchText() {
    jQuery("#tbxSearch").attr("value", "");
}

function ToggleBasketView() {
    $("#basket-contents-container").slideToggle(600);
}

function ToggleLegendView() {
    $("#legend-content").slideToggle(600);
}

function ShowDisabledBanned() {
    $("#backgroundPopup").css({
        "opacity": "0.7"
    });

    centerPopup("#disabled-banned");
    jQuery("#disabled-banned").fadeIn(600);
    jQuery("#backgroundPopup").fadeIn(600);
}

function ShowLoginForm() {
    $.nyroModalManual({
        url: 'Login.aspx'
    });
    return false;
}

function ShowLogoutForm() {
    $.nyroModalManual({
        url: 'Logout.aspx',
        selIndicator: 'nyroModalSel',
        formIndicator: 'nyroModal'
    });
    return false;
}

function ShowMyAccount() {
    $("#my-account-sections").slideToggle(600);
}


function ShowCats(mVar) {
    if ($('.ulcats_' + mVar).css("display") == "none") {
        $('.ulcats_' + mVar).show(400);
        $('#link_' + mVar).removeClass("headerinactive").addClass("headeractive");
    }
    else {
        $('.ulcats_' + mVar).hide(400);
        $('#link_' + mVar).removeClass("headeractive").addClass("headerinactive");
    }
}

function ExpandCustomer(mVar) {
    
    // Clear all friends colour back to white and hide them all
    $("[class^='ulOptions']").hide(400);
    $("[class^='friendHeader']").css("background-color", "#FFFFFF");
    
    // Now show the selected friend and make its background blue
    $('.ulOptions' + mVar).show(400);
    $('.friendHeader' + mVar).css("background-color", "#6AC6EE");
}
function ActiveCustomer(mVar) {

    $('#ctl00_mainpanel_ActiveCustomer').val(mVar);
    // $('a[id^="link"]').removeClass("customer-list-header-on").addClass("customer-list-header-off");

    // $('#link_' + mVar).removeClass("customer-list-header-off").addClass("customer-list-header-on");
}
function SetActiveCustomer(mVar) {

 
   //$('#ctl00_mainpanel_ctrConfiguratorMenu1_ActiveCustomer').val(mVar);
    $('#ctl00_mainpanel_ctrConfiguratoStep1_ActiveCustomer').val(mVar);
    
    if (mVar != $('.LoadedCustomer').text()) {
       
        $('.LoadCards').click();
    }
   // $('a[id^="link"]').removeClass("customer-list-header-on").addClass("customer-list-header-off");

   // $('#link_' + mVar).removeClass("customer-list-header-off").addClass("customer-list-header-on");
}
function SetActiveCustomerFromSeats(mVar) {
    alert(mVar);
    $('a[id^="link"]').removeClass("customer-list-header-on").addClass("customer-list-header-off");
  
    $('#link_' + mVar).removeClass("customer-list-header-off").addClass("customer-list-header-on");
}
function LoadAddons()
{
    $('.LoadAddons').click();
}
function LoadReservations() {
    $('.LoadReservations').click();
}
function RefreshGridStep0() {
 
    $('.LoadGrid').click();
}
function ExpandAddons(mVar) {
   
    if ($('#ulAddons' + mVar).css("display") == "none") {

        $('#ulAddons' + mVar).show(400);
    }
    else {
        $('#ulAddons' + mVar).hide(400);
    }
}
function ExpandAddon(mVar) {

    if ($('#addon-' + mVar).css("display") == "none") {

        $('#addon-' + mVar).show(400);
    }
    else {
        $('#addon-' + mVar).hide(400);
    }
}

function ChangeStep(mVar) {

    $('.Configurator-Welcome').hide(400);

    switch (mVar) {

        case 0:
            $('#ui_lblStep' + mVar).text('Step 1: Choose a membership card');
            $('#ui_lblStep1').removeClass("text-page-subtitle-inactive").addClass("text-page-subtitle-active");

            $('#ui_lblStep2').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep2').text('/Step 2');

            $('#ui_lblStep3').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep3').text('/Step 3');

            $('.Configurator-Step1').hide(400);
            $('.Configurator-Step2').hide(400);
            $('.Configurator-Step3').hide(400);
            $('.Configurator-Step4').hide(400);
            break;
        case 1:
            $('#ui_lblStep' + mVar).text('Step 1: Choose a membership card');
            $('#ui_lblStep1').removeClass("text-page-subtitle-inactive").addClass("text-page-subtitle-active");

            $('#ui_lblStep2').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep2').text('/Step 2');

            $('#ui_lblStep3').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep3').text('/Step 3');

            $('.Configurator-Step0').hide(400);
            $('.Configurator-Step2').hide(400);
            $('.Configurator-Step3').hide(400);
            $('.Configurator-Step4').hide(400);
            break;
        case 2:
            $('#ui_lblStep' + mVar).text('Step 1: Choose a membership card');
            $('#ui_lblStep1').removeClass("text-page-subtitle-inactive").addClass("text-page-subtitle-active");

            $('#ui_lblStep2').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep2').text('/Step 2');

            $('#ui_lblStep3').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep3').text('/Step 3');
            $('.Configurator-Step0').hide(400);
            $('.Configurator-Step1').hide(400);
            $('.Configurator-Step3').hide(400);
            $('.Configurator-Step4').hide(400);
            break;
        case 3:
            $('#ui_lblStep' + mVar).text('/Step 3: Select your add ons');
            $('#ui_lblStep3').removeClass("text-page-subtitle-inactive").addClass("text-page-subtitle-active");

            $('#ui_lblStep1').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep1').text('Step 1');
           
            $('#ui_lblStep2').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep2').text('/Step 2');
            $('.Configurator-Step0').hide(400);
            $('.Configurator-Step1').hide(400);
            $('.Configurator-Step2').hide(400);
            $('.Configurator-Step4').hide(400);
            break;
        case 4:
            $('#ui_lblStep2').text('/Step 2: Choose a seat');
            $('#ui_lblStep2').removeClass("text-page-subtitle-inactive").addClass("text-page-subtitle-active");
            
            $('#ui_lblStep1').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep1').text('Step 1');

            $('#ui_lblStep3').removeClass("text-page-subtitle-active").addClass("text-page-subtitle-inactive");
            $('#ui_lblStep3').text('/Step 3');
            $('.Configurator-Step0').hide(400);
            $('.Configurator-Step2').hide(400);
            $('.Configurator-Step1').hide(400);
            $('.Configurator-Step3').hide(400);
            break;
        default:


    }

    if ($('.Configurator-Step' + mVar).css("display") == "none") {
        $('.Configurator-Step' + mVar).show(400);
//        $('.Configurator-Step' + mVar).animate({ width: 'toggle' });

    }

}

jQuery(function() {

    //    $('#home-image-container').cycle('fade');

});

function showLoginContainer() {


    if ($(".Blanket").css("display") == "none") {
        jQuery(".Blanket").fadeIn(600);
    }
    else {
        jQuery(".Blanket").fadeOut(600);
    }
}

function hideLoginContainer() {
    jQuery(".Blanket").fadeOut(600);
}

function showLoginContainerpay() {
    if ($(".Blanketpay").css("display") == "none") {
        jQuery(".Blanketpay").fadeIn(600);
    }
    else {
        jQuery(".Blanketpay").fadeOut(600);
    }
}

function hideLoginContainerpay() {
    jQuery(".Blanketpay").fadeOut(600);
}


function OpenPostcode() {

    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();

    var mBodyHeight;

    if (navigator.appName.indexOf("Microsoft") != -1) {

        mBodyHeight = document.documentElement.clientHeight;

    }
    else {
        mBodyHeight = window.innerHeight;
    }

    var mBodyScroll = document.documentElement.scrollTop;
    //mBodyHeight = mBodyHeight.innerHeight;
    var mElementWidth = $("#divSelectAddress").css("width");
    var mElementHeight = $("#divSelectAddress").css("height");

    //    var mBorderWidth =  $("#divSelectAddress").css("border");
    var mElementPadding = $("#divSelectAddress").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    //alert(mBodyHeight + " / " + mBodyWidth);

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    //    mBorderWidth = mBorderWidth.substring(0,1);

    //Replace the px dim
    //    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    //    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2)) + parseFloat(mBodyScroll);

    $("#divSelectAddress").css("margin-left", mXpos + "px")
    $("#divSelectAddress").css("margin-top", mYpos + "px")


    jQuery(".BlanketRegPostcode").fadeIn(600);

}
function ShowReminder() {
    $("#backgroundPopup").css({
        "opacity": "0.7"
    });
      centerPopup("#reminder-popup");
    jQuery("#reminder-popup").fadeIn(600);
    jQuery("#backgroundPopup").fadeIn(600);
}
function ShowNotElegiable() {
    $("#backgroundPopup").css({
        "opacity": "0.7"
    });
    centerPopup("#not-elegiable");
    jQuery("#not-elegiable").fadeIn(600);
    jQuery("#backgroundPopup").fadeIn(600);
}
function HideNotElegiable() {

    jQuery("#not-elegiable").fadeOut(600);
    jQuery("#backgroundPopup").fadeOut(600);
}
function HideReminder() {

    jQuery("#reminder-popup").fadeOut(600);
    jQuery("#backgroundPopup").fadeOut(600);
}
//centering popup  
function centerPopup(popupID) {
    //request data for centering  
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = $(popupID).height();
    var popupWidth = $(popupID).width();
    //centering
    $(popupID).css({
        "position": "fixed",
        "top": windowHeight / 2 - popupHeight / 2,
        "left": windowWidth / 2 - popupWidth / 2
    });
    //only need force for IE6  

    $("#backgroundPopup").css({
        "height": windowHeight
    });

}  
function ClosePostcode() {
    jQuery(".BlanketRegPostcode").fadeOut(600);
}

function OpenFoundUsers() {
    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight = document.documentElement.clientHeight;
    
    var mElementWidth = $("#divFoundUsers").css("width");
    var mElementHeight = $("#divFoundUsers").css("height");

    var mBorderWidth = $("#divFoundUsers").css("border");
    var mElementPadding = $("#divFoundUsers").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    //alert(mBodyHeight + " / " + mBodyWidth);

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    mBorderWidth = "1";

    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    $("#divFoundUsers").css("margin-left", mXpos + "px")
    $("#divFoundUsers").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegUsers").fadeIn(600);
}

function OpenFoundCorporate() {
    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight = document.documentElement.clientHeight;
    
    var mElementWidth = $("#divFoundCorporate").css("width");
    var mElementHeight = $("#divFoundCorporate").css("height");

    var mBorderWidth = $("#divFoundCorporate").css("border");
    var mElementPadding = $("#divFoundCorporate").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    //alert(mBodyHeight + " / " + mBodyWidth);

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    mBorderWidth = "1";

    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    $("#divFoundCorporate").css("margin-left", mXpos + "px")
    $("#divFoundCorporate").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegUsers").fadeIn(600);
}

function OpenFoundCorporateForm() {
    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight = document.documentElement.clientHeight;
    
    var mElementWidth = $("#divFoundCorporateForm").css("width");
    var mElementHeight = $("#divFoundCorporateForm").css("height");

    var mBorderWidth = $("#divFoundCorporateForm").css("border");
    var mElementPadding = $("#divFoundCorporateForm").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    //alert(mBodyHeight + " / " + mBodyWidth);

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    mBorderWidth = "1";

    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    $("#divFoundCorporateForm").css("margin-left", mXpos + "px")
    $("#divFoundCorporateForm").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegUsers").fadeIn(600);
}

function CloseFoundUsers() {
    jQuery(".BlanketRegUsers").fadeOut(600);
}

function ShowRegSuccess() {

    jQuery(".updateRegSucess").fadeIn(600);
}

function CloseSucessReg() {
    jQuery(".updateRegSucess").fadeOut(600);
}
function OpenExceededAllocation() {
    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight = document.documentElement.clientHeight;
    
    var mElementWidth = $("#divExceededAllocation").css("width");
    var mElementHeight = $("#divExceededAllocation").css("height");

    var mBorderWidth = $("#divExceededAllocation").css("border");
    var mElementPadding = $("#divExceededAllocation").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    //alert(mBodyHeight + " / " + mBodyWidth);

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    mBorderWidth = "1";

    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    $("#divExceededAllocation").css("margin-left", mXpos + "px")
    $("#divExceededAllocation").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegUsers").fadeIn(600);
}



function OpenReminder() {

    jQuery(".Blanket").fadeIn(600);
}

function CloseReminder() {
    jQuery(".Blanket").fadeOut(600);
}

function OpenNewReg() {
    jQuery(".BlanketSuccess").fadeIn(600);
    
}


function OpenAddReg() {
    jQuery(".BlanketSuccess").fadeOut(600);
    jQuery(".Blanket3").fadeIn(600);
}


function OpenErr() {

    jQuery(".Blanket4").fadeIn(600);
}

function CloseErr() {
    jQuery(".Blanket4").fadeOut(600);
}

function OpenMessage() {

    jQuery(".BlanketMessage").fadeIn(600);
}

function CloseMessage() {
    jQuery(".BlanketMessage").fadeOut(600);
}

function OpenPwd() {
    jQuery(".BlanketPwd").fadeIn(600);
}

function OpenReg0() {
    jQuery(".BlanketReg0").fadeIn(600);
}

function CloseReg0() {
    jQuery(".BlanketReg0").fadeOut(600);
}

function OpenReg1() {

    //debugger;
    //hideSelects("hidden");
    //$(".dropdownfield").css("display","none");

    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight;

    if (navigator.appName.indexOf("Microsoft") != -1) {

        mBodyHeight = document.documentElement.clientHeight;

    }
    else {

        mBodyHeight = window.innerHeight;
    }

    //mBodyHeight = mBodyHeight.innerHeight;
    var mElementWidth = $("#reminder-form").css("width");
    var mElementHeight = $("#reminder-form").css("height");

    var mBorderWidth = $("#reminder-form").css("border");
    var mElementPadding = $("#reminder-form").css("padding");

    mElementPadding = mElementPadding.substring(0, 2);
    mElementWidth = mElementWidth.replace("px", "");
    mElementHeight = mElementHeight.replace("px", "");

    mElementWidth = parseFloat(mElementWidth) + parseFloat(mElementPadding * 2);
    mElementHeight = parseFloat(mElementHeight) + parseFloat(mElementPadding * 2);
    mBorderWidth = mBorderWidth.substring(0, 1);

    if (navigator.appName.indexOf("Microsoft") != -1) {
        mBorderWidth = 0;
    }

    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2) - (mBorderWidth * 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2) - (mBorderWidth * 2));

    $("#reminder-form").css("margin-left", mXpos + "px")
    $("#reminder-form").css("margin-top", mYpos + 80 + "px")

    jQuery(".BlanketReg1").fadeIn(600);

    //reminder-form
}

function CloseReg1() {
    //$(".dropdownfield").css("display","inline");
    jQuery(".BlanketReg1").fadeOut(600);
}


function OpenReg2() {

    jQuery(".BlanketReg2").fadeIn(600);

    //$(".dropdownfield").css("display","none");
}

function CloseReg2() {

    jQuery(".BlanketReg2").fadeOut(600);
}

function OpenReg3() {
    //$("#ctl00_ContentPlaceHolder1_salu").css("display","none");
    $(".dropdownfield").css("display", "none");
    //setInterval(function(){
    jQuery(".BlanketReg3").fadeIn(100);
    //}, 100);

}


function OpenRegTerms() {
    jQuery(".BlanketTerms").fadeIn(100);
}

function CloseRegTerms() {
    jQuery(".BlanketTerms").fadeOut(600);
}


function OpenReg4() {
    $(".dropdownfield").css("display", "none");
    jQuery(".BlanketReg4").fadeIn(100);
}

function OpenReg5() {
    jQuery(".BlanketReg5").fadeIn(600);
}

function CloseReg5() {
    jQuery(".BlanketReg5").fadeOut(600);
}


