﻿var caseStudyNum = 0;
var passNum = 2;
var currentTimerId;
var strSite = "";

currentTimerId = setTimeout('caseStudyMove();', 3000);


function caseStudyMove() {

    if (caseStudyNum == 0) { updateCs(0); }
    else if (caseStudyNum == 1) { updateCs(1); }
    else if (caseStudyNum == 2) { updateCs(2); }
    else if (caseStudyNum == 3) { updateCs(3); }
    else if (caseStudyNum == 4) { updateCs(4); }
    else if (caseStudyNum == 5) { updateCs(5); }
    else { caseStudyNum = 0; }

    currentTimerId = setTimeout('caseStudyMove();', 3000);

}

function updateCs(csNum) {

    strSite = $("#ctl00_MainBodyPlaceHolder1_strSite").val();
    strFolder = "";
    if (strSite == "atlas") { strFolder = "atlas/"; }
    if (strSite == "sanders") { strFolder = "sanders/"; }

    strTitle = $(".cs_" + csNum + "_title").html();
    strText = $(".cs_" + csNum + "_text").html();
    strImg = $(".cs_" + csNum + "_image").html();

    $(".csTitle").html(strTitle);
    $(".csText").html(strText);
    $(".csImage").attr("src", "images/caseStudies/" + strFolder + "mainPic_cs" + csNum + ".gif");
    $(".csLogo").attr("src", "images/caseStudies/" + strFolder + "logoPic_cs" + csNum + ".gif");

    resetCsImages();

    imgNum = csNum;
    imgNum++;

    $(".csNum" + imgNum).attr("src", "images/caseStudies/" + strFolder + "picNum" + imgNum + "_on.gif");

    if (passNum == 0) { caseStudyNum++; }
    else { passNum--; }

}

function csHighlight(theNum) {

    clearTimeout(currentTimerId);
    caseStudyNum--;
    if (caseStudyNum < 0) { caseStudyNum = 0; }
    updateCs(theNum, strSite);
}

function csOut() {

    currentTimerId = setTimeout('caseStudyMove();', 3000);
}

function resetCsImages() {

    $(".csNum1").attr("src", "images/caseStudies/picNum1_off.gif");
    $(".csNum2").attr("src", "images/caseStudies/picNum2_off.gif");
    $(".csNum3").attr("src", "images/caseStudies/picNum3_off.gif");
    $(".csNum4").attr("src", "images/caseStudies/picNum4_off.gif");
    $(".csNum5").attr("src", "images/caseStudies/picNum5_off.gif");
    $(".csNum6").attr("src", "images/caseStudies/picNum6_off.gif");
    $(".csNum7").attr("src", "images/caseStudies/picNum7_off.gif");
    $(".csNum8").attr("src", "images/caseStudies/picNum8_off.gif");
    $(".csNum9").attr("src", "images/caseStudies/picNum9_off.gif");

}

function openCaseStudy() {

    if (caseStudyNum == 0) { varLinkCsNum = 0 }
    else { varLinkCsNum = caseStudyNum; varLinkCsNum--; }

    window.location = 'redcliffeCaseStudies.aspx?id=' + varLinkCsNum;

}

function openCaseStudyAtlas() {

    if (caseStudyNum == 0) { varLinkCsNum = 0 }
    else { varLinkCsNum = caseStudyNum; varLinkCsNum--; }

    window.location = 'atlasCaseStudies.aspx?id=' + varLinkCsNum;

}

function openCaseStudySanders() {

    if (caseStudyNum == 0) { varLinkCsNum = 0 }
    else { varLinkCsNum = caseStudyNum; varLinkCsNum--; }

    window.location = 'sandersCaseStudies.aspx?id=' + varLinkCsNum;

}

function openCaseStudyWithNum(theNum) {

    window.location = 'redcliffeCaseStudies.aspx?id=' + theNum;

}

function openCaseStudyWithNumAtlas(theNum) {

    window.location = 'atlasCaseStudies.aspx?id=' + theNum;

}

function openCaseStudyWithNumSanders(theNum) {

    window.location = 'sandersCaseStudies.aspx?id=' + theNum;

}

function registerInterest() {

    strName = $("#ctl00_MainBodyPlaceHolder1_txtWcName").val();
    strCompany = $("#ctl00_MainBodyPlaceHolder1_txtCompany").val();
    strTelephone = $("#ctl00_MainBodyPlaceHolder1_txtTelephone").val();
    strEmail = $("#ctl00_MainBodyPlaceHolder1_txtEmail").val();

    if ((!strName) || (strName == '') || (strName == 'Your Name')) {

        alert('Please enter a name!');
        return;
    }

    if ((!strCompany) || (strCompany == '') || (strCompany == 'Company')) {

        alert('Please enter a Company Name!');
        return;
    }

    if ((!strTelephone) || (strTelephone == '') || (strTelephone == 'Telephone')) {

        alert('Please enter a Telephone!');
        return;
    }

    if ((strEmail == 'Email')) {
        alert('Please enter a Email!');
        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("registerInterest");

    document.forms[0].action = pageName;
    document.forms[0].submit();

}


function registerInterestAtlas() {

    strName = $("#ctl00_MainBodyPlaceHolder1_txtWcName").val();
    strCompany = $("#ctl00_MainBodyPlaceHolder1_txtCompany").val();
    strTelephone = $("#ctl00_MainBodyPlaceHolder1_txtTelephone").val();
    strEmail = $("#ctl00_MainBodyPlaceHolder1_txtEmail").val();

    if ((!strName) || (strName == '') || (strName == 'Your Name')) {

        alert('Please enter a name!');
        return;
    }

    if ((!strCompany) || (strCompany == '') || (strCompany == 'Company')) {

        alert('Please enter a Company Name!');
        return;
    }

    if ((!strTelephone) || (strTelephone == '') || (strTelephone == 'Telephone')) {

        alert('Please enter a Telephone!');
        return;
    }

    if ((strEmail == 'Email')) {

        alert('Please enter a Email!');
        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("registerInterest");

    document.forms[0].action = pageNameAtlas;
    document.forms[0].submit();

}


function registerInterestSanders() {

    strName = $("#ctl00_MainBodyPlaceHolder1_txtWcName").val();
    strCompany = $("#ctl00_MainBodyPlaceHolder1_txtCompany").val();
    strTelephone = $("#ctl00_MainBodyPlaceHolder1_txtTelephone").val();
    strEmail = $("#ctl00_MainBodyPlaceHolder1_txtEmail").val();

    if ((!strName) || (strName == '') || (strName == 'Your Name')) {

        alert('Please enter a name!');
        return;
    }

    if ((!strCompany) || (strCompany == '') || (strCompany == 'Company')) {

        alert('Please enter a Company Name!');
        return;
    }

    if ((!strTelephone) || (strTelephone == '') || (strTelephone == 'Telephone')) {

//        alert('Please enter a Telephone!');
//        return;
    }

    if ((strEmail == 'Email')) {

        alert('Please enter a Email!');
        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("registerInterest");

    document.forms[0].action = pageNameSanders;
    document.forms[0].submit();

}


function clearText(theControl) {

    if ((theControl.value == 'Your Name')
        || (theControl.value == 'Company')
        || (theControl.value == 'Telephone')
        || (theControl.value == 'Email')) {

        theControl.value = '';
        $('#' + theControl.id).removeClass('why_choose_textbox');
        $('#' + theControl.id).addClass('why_choose_textbox_light');  
    }

}

function resetName(theControl) {

    if (theControl.value == '') {
        theControl.value = 'Your Name';
        $('#' + theControl.id).removeClass('why_choose_textbox_light');
        $('#' + theControl.id).addClass('why_choose_textbox'); 
    }
}

function resetCompany(theControl) {

    if (theControl.value == '') {
        theControl.value = 'Company';
        $('#' + theControl.id).removeClass('why_choose_textbox_light');
        $('#' + theControl.id).addClass('why_choose_textbox'); 
    }
}

function resetTelephone(theControl) {

    if (theControl.value == '') {
        theControl.value = 'Telephone';
        $('#' + theControl.id).removeClass('why_choose_textbox_light');
        $('#' + theControl.id).addClass('why_choose_textbox'); 
    }
}

function resetEmail(theControl) {

    if (theControl.value == '') {
        theControl.value = 'Email';
        $('#' + theControl.id).removeClass('why_choose_textbox_light');
        $('#' + theControl.id).addClass('why_choose_textbox'); 
    }
}

function openC2i() {

    window.location = 'http://www.c2internet.net';

}


function focusNameBox() {

    $('#ctl00_MainBodyPlaceHolder1_txtWcName').focus();
    //$('#ctl00_MainBodyPlaceHolder1_txtWcName').val('');
    $('#ctl00_MainBodyPlaceHolder1_txtWcName').removeClass('why_choose_textbox');
    $('#ctl00_MainBodyPlaceHolder1_txtWcName').addClass('why_choose_textbox_light');
    window.scroll(0, 400);

}

$(document).ready(function() {

    $(".osDdown").hide();
    $(".dropdown_item_off").hide();

    ClearNavHighlights();
    navHighlight('linq3');

    $(".linq3").removeAttr("onmouseout");

    if ($("#ctl00_MainBodyPlaceHolder1_strOnReg").val() == "yes") { focusNameBox() }

});