﻿jQuery(function(){

    $('#home-image-container').cycle('fade');
    $('#retail-image-container').cycle('fade');

});
//hide selects on page - copy code below
function hideSelects(action) {
    //documentation for this script at http://www.shawnolson.net/a/1198/hide-select-menus-javascript.html
    //possible values for action are 'hidden' and 'visible'
    if (action != 'visible') { action = 'hidden'; }

    var ua = navigator.userAgent;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
        rv = parseFloat(RegExp.$1);

    if ((navigator.appName == "Microsoft Internet Explorer") && (rv == 6.0)) {

        for (var S = 0; S < document.forms.length; S++) {
            for (var R = 0; R < document.forms[S].length; R++) {
                if (document.forms[S].elements[R].options) {
                    if ((document.forms[S].elements[R].options.id != "squadlist") && (document.forms[S].elements[R].options.id != "ctl00_ctrQuickLoginIn1_ddlLoginType")) {
                        document.forms[S].elements[R].style.visibility = action;
                    }
                }
            }
        }
    }
}
//end code 
function showLoginContainer()
{
    jQuery("#login-form").show(600);
}

function hideLoginContainer()
{
    jQuery("#login-form").hide(600);
}

function clearSearchText()
{
    jQuery("#tbxSearch").attr("value","");
}

function ToggleBasketView()
{
    if ($("#basket-contents-container").css("display") == "none") {
        hideSelects("hidden");
    }
    else {
        hideSelects("visible");
    }
    $("#basket-contents-container").slideToggle(600);
}

function ToggleLegendView()
{
    $("#legend-content").slideToggle(600);
}

function ShowLoginForm(){
    $.nyroModalManual({
        url: 'Login.aspx'
    });
    return false;
}

function ShowLogoutForm() {
    $.nyroModalManual({
        url: 'Logout.aspx',
        selIndicator: 'nyroModalSel',
        formIndicator: 'nyroModal',
        height: 400
    });
    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("headeractive").addClass("headerinactive");
    }
    else
    {
        $('.ulcats_' + mVar).hide(400);
        $('#link_' + mVar).removeClass("headerinactive").addClass("headeractive");
    }
}

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 OpenEventMessage() {
   
    //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;
     
    var mElementWidth = $("#divEventMessage").css("width");
    var mElementHeight = $("#divEventMessage").css("height");
    var mElementPadding = $("#divEventMessage").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);
    
    //Replace the px dim
    var mXpos = parseFloat(mBodyWidth / 2) - parseFloat((mElementWidth / 2));
    var mYpos = parseFloat(mBodyHeight / 2) - parseFloat((mElementHeight / 2)) + parseFloat(mBodyScroll);
  
    $("#divEventMessage").css("margin-left", mXpos + "px")
    $("#divEventMessage").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegEventMessage").fadeIn(600);

}

function ClosePostcode()
{
    jQuery(".BlanketRegPostcode").fadeOut(600);
}

function OpenFoundUsers() {
    hideSelects("hidden");
    //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var mBodyHeight = window.innerHeight;
    //mBodyHeight = mBodyHeight.innerHeight;
    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 = 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));
    
    $("#divFoundUsers").css("margin-left", mXpos + "px")
    $("#divFoundUsers").css("margin-top", mYpos + "px")

    jQuery(".BlanketRegUsers").fadeIn(600);
}

function CloseFoundUsers() {
    hideSelects("visible");
    jQuery(".BlanketRegUsers").fadeOut(600);
}



function OpenReminder()
{
   
    jQuery(".Blanket").fadeIn(600);
}

function CloseReminder()
{
    jQuery(".Blanket").fadeOut(600);
}

function OpenNewReg() {
    hideSelects("hidden");
    jQuery(".Blanket2").fadeIn(600);
}


function OpenAddReg()
{
    jQuery(".Blanket2").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() {
    hideSelects("hidden");
    //$(".dropdownfield").css("display","none");
    
       //Set Margin / Width etc..
    var mBodyWidth = $("body").width();
    var 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","");
    
    //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));

    //$("#reminder-form").css("margin-left",mXpos + "px")
    $("#reminder-form").css("margin-top", mYpos +80+ "px") 
    
   jQuery(".BlanketReg1").fadeIn(600);
   
   //reminder-form
}

function CloseReg1() {
    hideSelects("visible");
    //$(".dropdownfield").css("display","inline");
    jQuery(".BlanketReg1").fadeOut(600);
}

function OpenReg2()
{
    hideSelects("hidden");
    jQuery(".BlanketReg2").fadeIn(600);
    
    //$(".dropdownfield").css("display","none");
}

function CloseReg2()
{
    hideSelects("visible");
    jQuery(".BlanketReg2").fadeOut(600);
}

function OpenReg3()
{   
    //$("#ctl00_ContentPlaceHolder1_salu").css("display","none");
    $(".dropdownfield").css("display","none");
    //setInterval(function(){
        jQuery(".BlanketReg3").fadeIn(100);
    //}, 100);
   
}
function OpenReg4()
{
    $(".dropdownfield").css("display","none");
    jQuery(".BlanketReg4").fadeIn(100);
}

function OpenReg5()
{
   jQuery(".BlanketReg5").fadeIn(600);
}

function CloseReg5()
{
    jQuery(".BlanketReg5").fadeOut(600);
}

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);

}

