﻿
var otherSolutionsNumber = 1;
var otherSolutionsOpen = false;
var pageName = "redcliffeLanding.aspx";
var pageNameAtlas = "atlasLanding.aspx";
var pageNameSanders = "sandersLanding.aspx";
var pageNameC2i = "c2iLanding.aspx";


function navHighlight(theCtrl) {

    if (theCtrl == 'linq0') {
        $("." + theCtrl).removeClass("nav_link_top");
        $("." + theCtrl).addClass("nav_link_over " + theCtrl);       
    }
    else {
        $("." + theCtrl).removeClass("nav_link");
        $("." + theCtrl).addClass("nav_link_over " + theCtrl);
    }
}

function navNormal(theCtrl) {

    if (theCtrl == 'linq0') {
        $("." + theCtrl).removeClass("nav_link_over");
        $("." + theCtrl).addClass("nav_link_top " + theCtrl);
    }
    else {
        $("." + theCtrl).removeClass("nav_link_over");
        $("." + theCtrl).addClass("nav_link " + theCtrl);
    }
}

function openLink(thePage) {

    window.location = thePage;
}

function optHighlight(theCtrl) {

    $("." + theCtrl).removeClass("dropdown_item_off");
    $("." + theCtrl).addClass("dropdown_item_on " + theCtrl);
}

function optNormal(theCtrl) {

    $("." + theCtrl).removeClass("dropdown_item_on");
    $("." + theCtrl).addClass("dropdown_item_off " + theCtrl);

}

function openOtherSolutions() {

    if (otherSolutionsOpen) {

        $(".osDdown").hide();
        $(".dropdown_item_off").hide();
        otherSolutionsOpen = false;
    }
    else {

        $(".osDdown").show();
        $(".dropdown_item_off").show();
        otherSolutionsOpen = true;
    }
}

function optSelect(theCtrl) {

    if (theCtrl == 'opt0') {

        strTitle = $(".os_0_title").html();
        strText = $(".os_0_text").html();
        otherSolutionsNumber = 1;
    }

    if (theCtrl == 'opt1') {

        strTitle = $(".os_1_title").html();
        strText = $(".os_1_text").html();
        otherSolutionsNumber = 2;
    }

    if (theCtrl == 'opt2') {

        strTitle = $(".os_2_title").html();
        strText = $(".os_2_text").html();
        otherSolutionsNumber = 3;
    }

    if (theCtrl == 'opt3') {

        strTitle = $(".os_3_title").html();
        strText = $(".os_3_text").html();
        otherSolutionsNumber = 4;
    }

    if (theCtrl == 'opt4') {

        strTitle = $(".os_4_title").html();
        strText = $(".os_4_text").html();
        otherSolutionsNumber = 5;
    }

    if (theCtrl == 'opt5') {

        strTitle = $(".os_5_title").html();
        strText = $(".os_5_text").html();
        otherSolutionsNumber = 6;
    }

    if (theCtrl == 'opt6') {

        strTitle = $(".os_6_title").html();
        strText = $(".os_6_text").html();
        otherSolutionsNumber = 7;
    }

    if (theCtrl == 'opt7') {

        strTitle = $(".os_7_title").html();
        strText = $(".os_7_text").html();
        otherSolutionsNumber = 8;
    }

    if (theCtrl == 'opt8') {

        strTitle = $(".os_8_title").html();
        strText = $(".os_8_text").html();
        otherSolutionsNumber = 9;
    }

    if (theCtrl == 'opt9') {

        strTitle = $(".os_9_title").html();
        strText = $(".os_9_text").html();
        otherSolutionsNumber = 10;
    }

    if (theCtrl == 'opt10') {

        strTitle = $(".os_10_title").html();
        strText = $(".os_10_text").html();
        otherSolutionsNumber = 11;
    }                         

    $(".osTitle").html(strTitle);
    $(".osText").html(strText);

    openOtherSolutions()

}

function ClearNavHighlights() {

    $(".linq0").removeClass("nav_link_over");
    $(".linq0").addClass("nav_link linq0");

    $(".linq1").removeClass("nav_link_over");
    $(".linq1").addClass("nav_link linq1");

}

function emptySearchBox() {

    $(".searchInput").removeClass("searchInput");
    $(".searchInput").addClass("searchInputActive");
}

function checkSearchBox() {

    theValue = $("#q").val();

    if (theValue == '') {

        $("#q").removeClass("searchInputActive");
        $("#q").addClass("searchInput");
    }
    else {

        $("#q").removeClass("searchInput");
        $("#q").addClass("searchInputActive");
    }
    
}

function searchOn() {

    $(".searchButton").attr("src", "images/searchButtonRedcliffeOn.gif");

}

function searchOff() {

    $(".searchButton").attr("src", "images/searchButtonRedcliffe.gif");

}

function swapImg(theCrtl, theImage) {

    $(theCrtl).attr("src", "images/caseStudies/" + theImage);

}

function swapNormalImg(theCrtl, theImage) {

    $(theCrtl).attr("src", "images/" + theImage);

}

function openOtherSolution() {

    window.location = "redcliffeOurSolutions.aspx?id=" + otherSolutionsNumber;

}

function addToMailingList() {

    strName = $("#ctl00_txtMlName").val();
    strEmail = $("#ctl00_txtMlEmail").val();

    if ((!strName) || (strName == '')) {

        alert('Please enter a name for the mailing list!');
        return;
        
    }

    var emailRegEx = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

    if (!emailRegEx.test(strEmail)) {
      
        alert('The Email address entered is not valid!');
        return;
    }
     
    $("#ctl00_hdnSubmitType").val("mailingList");

    document.forms[0].action = pageName;
    document.forms[0].submit();


    //alert('You have been added to the mailing list!');

}


function addToMailingListAtlas() {

    strName = $("#ctl00_txtMlName").val();
    strEmail = $("#ctl00_txtMlEmail").val();

    if ((!strName) || (strName == '')) {

        alert('Please enter a name for the mailing list!');
        return;

    }

    var emailRegEx = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

    if (!emailRegEx.test(strEmail)) {

        alert('The Email address entered is not valid!');
        return;
    }

    $("#ctl00_hdnSubmitType").val("mailingList");

    document.forms[0].action = pageNameAtlas;
    document.forms[0].submit();


    //alert('You have been added to the mailing list!');

}


function addToMailingListSanders() {

    strName = $("#ctl00_txtMlName").val();
    strEmail = $("#ctl00_txtMlEmail").val();

    if ((!strName) || (strName == '')) {

        alert('Please enter a name for the mailing list!');
        return;

    }

    var emailRegEx = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

    if (!emailRegEx.test(strEmail)) {

        alert('The Email address entered is not valid!');
        return;
    }

    $("#ctl00_hdnSubmitType").val("mailingList");

    document.forms[0].action = pageNameSanders;
    document.forms[0].submit();


    //alert('You have been added to the mailing list!');

}

function addToMailingListC2i() {

    strName = $("#ctl00_MainBodyPlaceHolder1_txtMlName").val();
    strEmail = $("#ctl00_MainBodyPlaceHolder1_txtMlEmail").val();

    if ((!strName) || (strName == '')) {

        alert('Please enter a name for the mailing list!');
        return;

    }

    var emailRegEx = /^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;

    if (!emailRegEx.test(strEmail)) {

        alert('The Email address entered is not valid!');
        return;
    }

    $("#ctl00_hdnSubmitType").val("mailingList");

    document.forms[0].action = pageNameC2i;
    document.forms[0].submit();


    //alert('You have been added to the mailing list!');

}


function openFindOutMore() {

    window.location = "redcliffeOurSolutions.aspx?id=" + otherSolutionsNumber;

}

function openFindOutMoreAtlas() {

    window.location = "atlasOurSolutions.aspx?id=" + otherSolutionsNumber;

}

function openFindOutMoreSanders() {

    window.location = "sandersOurSolutions.aspx?id=" + otherSolutionsNumber;

}


function openContactUs() {

    window.location = "redcliffeContactUs.aspx";

}

function openContactUsAtlas() {

    window.location = "atlasContactUs.aspx";

}

function openContactUsSanders() {

    window.location = "sandersContactUs.aspx";

}

function openMoreNews() {

    window.location = "redcliffeNews.aspx";

}

function openMoreNewsAtlas() {

    window.location = "atlasNews.aspx";

}

function openMoreNewsSanders() {

    window.location = "sandersNews.aspx";

}

function openDownloads() {

    window.location = "redcliffeDownloads.aspx";

}

function openDownloadsAtlas() {

    window.location = "atlasDownloads.aspx";

}

function openDownloadsSanders() {

    window.location = "sandersDownloadsMenu.aspx";

}

function mpLink(theCtrl) {

    theCtrl.style.cursor = 'pointer';

}

function mpOut(theCtrl) {

    theCtrl.style.cursor = 'auto';

}

function setRegisterFocus() {

    document.location = 'sandersLanding.aspx?sr=on';

};





$(document).ready(function() {

    $(".osDdown").hide();
    $(".dropdown_item_off").hide();

    checkSearchBox();

    if ($("#ctl00_hdnSubmitType").val() == "mailingList") {

        alert("Your details have been added to the mailing list!");
    }

    if ($("#ctl00_hdnSubmitType").val() == "registerInterest") {

        alert("Your details have been saved!");

        $("#ctl00_MainBodyPlaceHolder1_txtWcName").val("Your Name");
        $("#ctl00_MainBodyPlaceHolder1_txtCompany").val("Company");
        $("#ctl00_MainBodyPlaceHolder1_txtTelephone").val("Telephone");
        $("#ctl00_MainBodyPlaceHolder1_txtEmail").val("Email");

    }

    $("#ctl00_hdnSubmitType").val("search");
    document.forms[0].action = "http://www.google.com/custom";

    $("#ctl00_txtMlName").val("");
    $("#ctl00_txtMlEmail").val("");
    

});
