/* OPEN SIGN IN PANEL */

$(document).ready(function(){
$(".sign_button").click(function(){
    $(".sign_in").slideDown("slow");
	$(".calculator_menu").slideUp("fast");
  });
});

/* OPEN CALC PANEL */

$(document).ready(function(){
$(".calc_button").click(function(){
    $(".calculator_menu").slideDown("slow");
	$(".sign_in").slideUp("fast");
  });
});

/* CLOSE CALC SIGN PANELS */

$(document).ready(function(){
$(".close_button").click(function(){
    $(".calculator_results").slideUp("fast");
    $(".calculator_menu").slideUp("fast");
	$(".sign_in").slideUp("fast");
  });
});

/* CONTACT SIDE BUTTON */

$(document).ready(function(){
$(".contact_open").click(function(){
	$(".contact_form").slideToggle("slow");
  });
});

/* APPEAL FORM SIDE BUTTON */

$(document).ready(function(){
$(".appeal_open").click(function(){
	$(".appeal_form").slideToggle("slow");
  });
});

/* APPEAL FORM SIDE LOADER */

$(document).ready(function(){
$(".loader_button").click(function(){
	$(".appeal_form").slideToggle("slow");
	$(".loader_appeal").slideToggle("slow");
  });
});

/* CASE STUDY SIDE PANEL */

$(document).ready(function(){
$(".case_button").click(function(){
	$(".case_study_back").slideToggle("slow");
  });
});

/* SIDE PANEL CONTACT FORM */

$(document).ready(function(){
$(".contact_loader").click(function(){
	$(".contact_form").slideToggle("slow");
	$(".loader_contact").slideToggle("slow");
  });
});

/* BUSINESS RATES CALCULATOR PAGE LOADING SCREEN */

function showLoaderPage() {

    $(document).ready(function () {
        $(".business_rates_loader_page").slideToggle("slow");
    });

}

/* BUSINESS RATES ENQUIRY LOADING SCREEN */

$(document).ready(function(){
$(".enquiry_loader").click(function(){
	$(".rates_enquiry_loader").slideToggle("slow");
  });
});

/* DROP DOWN SIGN IN */

$(document).ready(function () {
    $(".dd_sign_button").click(function () {
        $(".dd_signin").slideToggle("slow");
        $(".dd_partners").hide("slow");
        $(".dd_register").hide("slow");
    });
});

/* DROP DOWN REGISTER */

$(document).ready(function () {
    $(".dd_register_button").click(function () {
        $(".dd_register").slideToggle("slow");
        $(".dd_signin").hide("slow");
        $(".dd_partners").hide("slow");
    });
});

/* DROP DOWN PARTNERS */

$(document).ready(function () {
    $(".dd_partners_button").click(function () {
        $(".dd_partners").slideToggle("slow");
        $(".dd_signin").hide("slow");
        $(".dd_register").hide("slow");
    });
});

/* SAVINGS TABLE NAVIGATION */

$(document).ready(function () {
    $(".nextTable").click(function () {
        $(".savings_2").slideToggle("slow");
        $(".savings_1").hide("slow");
    });
});

$(document).ready(function () {
    $(".prevTable").click(function () {
        $(".savings_1").slideToggle("slow");
        $(".savings_2").hide("slow");
    });
});

/* CASE STUDIES PAGES */

$(document).ready(function () {
    $(".button_ascot").click(function () {
        $(".ascot_study").slideToggle("slow");
        $(".ascot_button").hide("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_jb").click(function () {
        $(".jb_study").slideToggle("slow");
        $(".jb_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_weatherbys").click(function () {
        $(".weatherbys_study").slideToggle("slow");
        $(".weatherbys_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_mpd").click(function () {
        $(".mpd_study").slideToggle("slow");
        $(".mpd_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_charters").click(function () {
        $(".charters_study").slideToggle("slow");
        $(".charters_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_safetykleen").click(function () {
        $(".safetykleen_study").slideToggle("slow");
        $(".safetykleen_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_unicom").click(function () {
        $(".unicom_study").slideToggle("slow");
        $(".unicom_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_inviron").click(function () {
        $(".inviron_study").slideToggle("slow");
        $(".inviron_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".spira_study").hide("slow");
        $(".spira_button").show("slow");
    });
});

$(document).ready(function () {
    $(".button_spira").click(function () {
        $(".spira_study").slideToggle("slow");
        $(".spira_button").hide("slow");
        $(".ascot_study").hide("slow");
        $(".ascot_button").show("slow");
        $(".weatherbys_study").hide("slow");
        $(".weatherbys_button").show("slow");
        $(".mpd_study").hide("slow");
        $(".mpd_button").show("slow");
        $(".jb_study").hide("slow");
        $(".jb_button").show("slow");
        $(".charters_study").hide("slow");
        $(".charters_button").show("slow");
        $(".safetykleen_study").hide("slow");
        $(".safetykleen_button").show("slow");
        $(".unicom_study").hide("slow");
        $(".unicom_button").show("slow");
        $(".inviron_study").hide("slow");
        $(".inviron_button").show("slow");
    });
});

/* QUOTE ANIMATION */

function show1() {

    $(document).ready(function () {
        $(".movingQuote1").show("slow");
        $(".movingTimer1").show("fast");
        $(".movingTimer1").fadeTo(10000, 0, function () {
            $(".movingQuote1").hide("fast");
            show2();
        });
    });

    /* alert("Hide 1"); */

}

function show2() {


    $(document).ready(function () {
        $(".movingQuote2").show("fast");
        $(".movingTimer2").show("fast");
        $(".movingTimer2").fadeTo(10000, 0, function () {
            $(".movingQuote2").hide("fast");
            show3();
        });
    });


}
function show3() {


    $(document).ready(function () {
        $(".movingQuote3").show("fast");
        $(".movingTimer3").show("fast");
        $(".movingTimer3").fadeTo(10000, 0, function () {
            $(".movingQuote3 ").hide("fast");
        show1();
        });
    });


}

/* SHOW CANCEL BUTTON */

$(document).ready(function () {
    $(".meetTeam").click(function () {
        $(".meet_the_team").show("fast");
        $(".enquiry_page").hide("fast");
    });
});

/* CHANGE PRESS RELEASE */

function changeStory(swap) {

    /* GET CURRENT STORY */

    current = "." + document.getElementById("storyID").value;
    swap = "." + swap;

    $(document).ready(function () {
        $(current).hide("fast");
        $(swap).show("fast");
    });

    document.getElementById("storyID").value = swap;

}

/* RATESINSIGHT */

$(document).ready(function () {
    $(".rates_set1_button").click(function () {
        $(".rates_set1").show("normal");
        $(".rates_set2").hide();
    });
});

$(document).ready(function () {
    $(".rates_set2_button").click(function () {
        $(".rates_set2").show("normal");
        $(".rates_set1").hide();
    });
});

/* SURVEYORS REGIONS */
$(document).ready(function () {
    closeAllRegions();
});

function showRegion(div) {

    closeAllRegions(div);

    new_div = "." + div;

    $(document).ready(function () {
        $(new_div).show("slow");
    });


}
function closeAllRegions(div) {

    $(document).ready(function () {
        var region = getQueryParamByName("Region");
        if (region != "Midlands" || div != undefined) {
            $(".surveyors_midlands").hide("fast");
        } else {
            swapImage('UKRegions-MID');
        }
        if (region != "NWest" || div != undefined) {
            $(".surveyors_northwest").hide("fast");
        } else {
            swapImage('UKRegions-NW');
        }
        if (region != "NEast" || div != undefined) {
            $(".surveyors_northeast").hide("fast");
        } else {
            swapImage('UKRegions-NE');
        }
        if (region != "SWest" || div != undefined) {
            $(".surveyors_southwest").hide("fast");
        } else {
            swapImage('UKRegions-SW');
        }
        if (region != "SEast" || div != undefined) {
            $(".surveyors_southeast").hide("fast");
        } else {
            swapImage('UKRegions-SE');
        }
    });


}


function getQueryParamByName(val) {
    var query = window.location.search;
    query = query.split('?')[1]
    if (query == undefined)
        return null;

    var pairs = query.split('&');
    var retval = {};
    var check = [];
    for (var i = 0; i < pairs.length; i++) {
        check = pairs[i].split('=');
        var param = decodeURIComponent(check[0]);
        if (param == val)
            return decodeURIComponent(check[1]);

    }
    return null;
} 

