﻿var bustcachevar = 1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects = "";
var rootdomain = "http://" + window.location.hostname
var bustcacheparameter = "";

function initSlider() {
    featuredcontentslider.init({
        id: "slider1",
        //id of main slider DIV
        contentsource: ["inline", ""],
        //Valid values: ["inline", ""] or ["ajax", "path_to_file"]
        toc: "#increment",
        //Valid values: "#increment", "markup", ["label1", "label2", etc]
        nextprev: ["Previous", "Next"],
        //labels for "prev" and "next" links. Set to "" to hide.
        revealtype: "click",
        //Behavior of pagination links to reveal the slides: "click" or "mouseover"
        enablefade: [false, 0.2],
        //[true/false, fadedegree]
        autorotate: [true, 3000],
        //[true/false, pausetime]
        onChange: function (previndex, curindex) { //event handler fired whenever script changes slide
            //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
            //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
        }
    })
}

function sendEmail(formName) {
    if (!ValidatePage()) return;

    if (formName == 'form1') {
        var emailUrl = 'SendEmail.aspx?name=' + $('#ctl00_CenterContent_PostInfoRFI1_Company').val() + '&email=' + $('#ctl00_CenterContent_PostInfoRFI1_Email').val() + '&city=' + $('#ctl00_CenterContent_PostInfoRFI1_City').val() + '&phoneno=' + $('#ctl00_CenterContent_PostInfoRFI1_Phone').val() + '&jobtitle=' + $('#ctl00_CenterContent_PostInfoRFI1_JobTitle').val() + '&jobtype=' + $('#ctl00_CenterContent_PostInfoRFI1_JobType').val() + '&country=' + $('#ctl00_CenterContent_PostInfoRFI1_Country').val() + '&TimeFrameProjectStart=' + $('#ctl00_CenterContent_PostInfoRFI1_TimeFrame').val() + '&Technologies=' + $('#ctl00_CenterContent_PostInfoRFI1_Technology').val() + '&Databases=' + $('#ctl00_CenterContent_PostInfoRFI1_DBType').val() + '&Comments=' + $('#ctl00_CenterContent_PostInfoRFI1_Comments').val() + '&FilePath=' + document.getElementById('ctl00_CenterContent_PostInfoRFI1_FileUpload1').value; + '&FormName=' + formName;
    }

    if (formName == 'form2') {

        var emailUrl = 'SendEmail.aspx?name=' + $('#ctl00_CenterContent_PostInfoRFI1_Company').val() + '&Question=' + $('#ctl00_CenterContent_GetInfo1_FQuestion').val() + '&Firstname=' + $('#ctl00_CenterContent_GetInfo1_FFirstName').val() + '&Lastname=' + $('#ctl00_CenterContent_GetInfo1_FLastName').val() + '&Email=' + $('#ctl00_CenterContent_GetInfo1_FMail').val() + '&Phoneno=' + $('#ctl00_CenterContent_GetInfo1_FPhone').val() + '&Company=' + $('#ctl00_CenterContent_GetInfo1_FCompany').val() + '&FormName=' + formName;

    }

    $.post(emailUrl, '', function (result) {

        alert(result);
    });
}

function ValidatePage() {
    var errorMessages = [];
    var isValid = true;

    var inputBoxes = $('input[type=text].required');
    var dropDowns = $('select.required');

    inputBoxes.each(function (e) {
        if ($.trim($(this).val()) == '') {
            isValid = false;
        }
    });

    dropDowns.each(function (e) {
        if ($.trim($(this).val()) == '') {
            isValid = false;
        }
    });

    if (!isValid) {
        alert('Please enter all the mandatory fields which are marked with asterisk.');
    }

    return isValid;
}

function changeLocation(menuObj) {
    var i = menuObj.selectedIndex;
    if (i > 0) {
        window.location = menuObj.options[i].value;
    }
}

function showimages(ThisObj, obj) {

    document.getElementById('a1').style.background = '';
    document.getElementById('a2').style.background = '';
    document.getElementById('a3').style.background = '';
    document.getElementById('a4').style.background = '';
    document.getElementById('a5').style.background = '';
    document.getElementById('a6').style.background = '';
    document.getElementById('a7').style.background = '';
    document.getElementById('a8').style.background = '';
    document.getElementById('a9').style.background = '';
    document.getElementById('a10').style.background = '';
    document.getElementById('a11').style.background = '';
    document.getElementById('a12').style.background = '';
    document.getElementById('a13').style.background = '';
    document.getElementById('a14').style.background = '';
    document.getElementById('a15').style.background = '';
    document.getElementById('a16').style.background = '';
    document.getElementById('a17').style.background = '';
    document.getElementById('a18').style.background = '';

    // Hide all tabs
    document.getElementById('div1').style.display = 'none';
    document.getElementById('div2').style.display = 'none';
    document.getElementById('div3').style.display = 'none';
    document.getElementById('div4').style.display = 'none';
    document.getElementById('div5').style.display = 'none';
    document.getElementById('div6').style.display = 'none';
    document.getElementById('div7').style.display = 'none';
    document.getElementById('div8').style.display = 'none';
    document.getElementById('div9').style.display = 'none';
    document.getElementById('div10').style.display = 'none';
    document.getElementById('div11').style.display = 'none';
    document.getElementById('div12').style.display = 'none';
    document.getElementById('div13').style.display = 'none';
    document.getElementById('div14').style.display = 'none';
    document.getElementById('div15').style.display = 'none';
    document.getElementById('div16').style.display = 'none';
    document.getElementById('div17').style.display = 'none';
    document.getElementById('div18').style.display = 'none';

    //Show click tab
    nav = document.getElementById(ThisObj).style
    if (nav.display == "none") {
        nav.display = 'block';
    }
}

function initSite() {
    var currentURL = window.location.href;
    var pageName = currentURL.substr(currentURL.lastIndexOf("/"));
    currentURL = currentURL.substr(0, currentURL.lastIndexOf("/"));
    currentURL = currentURL.substr(currentURL.lastIndexOf("/")) + "/";
    
    $("#topmenu li a").removeClass("selectedtop");
    if ($("#topmenu li a[href*='" + currentURL + "']").length > 0) {
        $("#topmenu li a[href*='" + currentURL + "']").addClass("selectedtop");
    }

    if ($("div.vertmenu li a[href*='" + pageName + "']").length > 0) {

        $("div.vertmenu li a[href*='" + pageName + "']").parent().addClass("sel");
    }
}



if(window.addEventListener){ // Mozilla, Netscape, Firefox
	window.addEventListener('load', initSite, true);
} else { // IE
	window.onload = initSite;	
}
