﻿$(document).ready(function () {
    $("body").removeClass("noscript");
});

function changeToGapTab() {
    $("#btnLeadGenTab").removeClass("Selected");
    $("#btnGapTab").addClass("Selected");
    $(".OpeningTimesContainer").stop().animate({ marginLeft: '0px' }, 1000);
    $("#LeadGenContactFormSurround").slideToggle(1000); //.css("display", "none");
    $("#ContactFormSurround").slideToggle(1000); //.css("display","block");
    
}

function changeToLeadTab() {
    $("#btnLeadGenTab").addClass("Selected");
    $("#btnGapTab").removeClass("Selected");
    $(".OpeningTimesContainer").stop().animate({ marginLeft: '-210px' }, 1000);
    $("#LeadGenContactFormSurround").slideToggle(1000); //css("display", "block");
    $("#ContactFormSurround").slideToggle(1000); //.css("display", "none"); 
   
}


function ShowElement(classname) {
    $(classname).css("display", "block");
}

function HideElement(classname) {
    $(classname).css("display", "none");
}

function ShowCallBackForm() {
    ShowElement('.opaqueBackground');
    ShowElement('.callbackFormOverlay');
}

function HideCallBackForm() {
    HideElement('.opaqueBackground');
    HideElement('.callbackFormOverlay');
    /* Clear the fields and hide success or fail panels */    
    var ErrorPanel = document.getElementById('ErrorPanel');
    if (ErrorPanel == null) {
    } else {
        ErrorPanel.style.display = "none";
        var callbackpanel = document.getElementById('pnlCallBackForm');
        callbackpanel.style.display = "block";
    }
    var ThankYouPanel = document.getElementById('ThankYouPanel');
    if (ThankYouPanel == null) {
    } else {
        ThankYouPanel.style.display = "none";
    }
    clearCallBackFields()
}
function clearCallBackFields() {

    if (document.getElementById('txtCompanyName') == null) {
    } else {
        $('#txtCompanyName').val('');
    }
 
    $('#txtFirstName').val('');
    $('#txtLastName').val('');
    $('#txtEmail').val('');
    $('#txtEmailConfirm').val('');
    $('#txtPhone').val('');


}

function ShowWeAreHiringForm() {
    ShowElement('.opaqueBackground');
    ShowElement('.weAreHiringFormOverlay');
}

function HideWeAreHiringForm() {
    HideElement('.opaqueBackground');
    HideElement('.weAreHiringFormOverlay');
    var ErrorPanel = document.getElementById('ErrorPanelHF');
    if (ErrorPanel == null) {
    } else {
        ErrorPanel.style.display = "none";
        var pnlWeAreHiringForm = document.getElementById('pnlWeAreHiringForm');
        pnlWeAreHiringForm.style.display = "block";
    }
    var ThankYouPanel = document.getElementById('ThankYouPanelHF');
    if (ThankYouPanel == null) {
    } else {
        ThankYouPanel.style.display = "none";
    }
    clearHiringFields()
}

function clearHiringFields() {
    var Name = document.getElementById('txtName');  
    var email = document.getElementById('txtEmailHF');
    var confirmEmail = document.getElementById('txtEmailConfirm');
    var phone = document.getElementById('txtPhoneHF');
    var message = document.getElementById('txtMessage');
    if (document.getElementById('txtCompanyName') == null) {
    } else {
        var companyName = document.getElementById('txtCompanyName');
        companyName.value = "";
    }
    Name.value = "";    
    email.value = "";    
    phone.value = "";
    message.value = "";
}
function ShowLargeMap() {
    ShowElement('.opaqueBackground');
    ShowElement('.largeMap');
    initializeMap();
}

function HideLargeMap() {
    HideElement('.opaqueBackground');
    HideElement('.largeMap');
}

function HideContactForm() {
    HideElement('.opaqueBackground');
    HideElement('.contactFormOverlay');
}

function ShowContactForm() {
    ShowElement('.opaqueBackground');
    ShowElement('.contactFormOverlay');
}

function IncludeJavaScript(jsFile) {
    document.write('<script type="text/javascript" src="' + jsFile + '"></script>');
}

function LoadJsFile(filename) {
    var fileref = document.createElement('script')
    fileref.setAttribute("type", "text/javascript")
    fileref.setAttribute("src", filename)

    document.getElementsByTagName("head")[0].appendChild(fileref)
}
