﻿
function openCareers(careersDropDown) 
{
    openCareersByCity(careersDropDown[careersDropDown.selectedIndex].text.toUpperCase());
}

function openCareersByCity(cityName)
{
    switch (cityName.toUpperCase())
    {
        case "BOSTON":
        case "SAN FRANCISCO":
        case "TALLAHASSEE":
            var windowFeatures = "toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";
            var url = "http://jobs-isofamily.icims.com/jobs/search?ss=1&searchCategory=&searchKeyword=&searchPostedDate=&searchLocation=&searchCompany=85";
            openWindow(url, screen.width, screen.height, "careers", "1", 0, 0, windowFeatures);
            return false;
            break;
        default:
            return true;
            break;
    }
}

function searchSubmit(controlID, target)
{
    var searchKeyword = document.getElementById(controlID);

    var searchRedirect = '/Search-Results.aspx?search=' + escape(searchKeyword.value);

    if (target == "_blank") {
        window.open(searchRedirect);
    }
    else {
        location.href = searchRedirect;
    }
}

function openWindow(strURL, intWidth, intHeight, strWindowName, strScrollBars, intOffsetLeft, intOffsetTop, strFeatures)
{
    if (typeof (strWindowName) == 'undefined') strWindowName = "PopUpWin";
    if (typeof (strScrollBars) == 'undefined') strScrollBars = "1";

    var intLeft = 0;
    var intTop = 0;


    if (typeof (intOffsetLeft) != 'undefined') intLeft += intOffsetLeft;
    if (typeof (intOffsetTop) != 'undefined') intTop += intOffsetTop;

    // Added to allow override of window features/options
    if (typeof (strFeatures) == 'undefined') {
        strFeatures = "toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=" + strScrollBars + ",resizable=1";
    }

    strFeatures += ",left=" + intLeft + ",top=" + intTop;
    strFeatures += ",width=" + intWidth + ",height=" + intHeight;

    winPopUp = window.open(strURL, strWindowName, strFeatures);
    setTimeout("winPopUp.focus()", 50);

    return winPopUp;
}

function centerProgressModal(updateProgressControlID, updateProgressDiv) {

    var updateProgressControl = $get(updateProgressControlID);
    var updateProgressDiv = $get(updateProgressDiv);

    //Change the display stype of both the progress div as well as the UpdateProgress control, otherwise
    //the offsetWidth/Height will both be 0, and the progress indicator will not center on the page
    updateProgressControl.style.display = '';
    updateProgressDiv.style.display = '';

    //Find the page dimensions
    var scrollX = window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft;
    var scrollY = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;

    var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
    var windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;

    var x = Math.round(windowWidth / 2 - updateProgressDiv.offsetWidth / 2) + scrollX;
    var y = Math.round(windowHeight / 2 - updateProgressDiv.offsetHeight / 2) + scrollY;

    //position the progress indicator element
    Sys.UI.DomElement.setLocation(updateProgressDiv, x, y);
}

function showPopup(currentControl, targetDiv, position) {

    var popupDiv = $get(targetDiv);

    popupDiv.style.display = '';

    var boundsTarget = Sys.UI.DomElement.getBounds(currentControl);
    var boundsPopup = Sys.UI.DomElement.getBounds(popupDiv);
    
    var x = boundsTarget.x;
    var y = boundsTarget.y + boundsTarget.height;

    if (position == 'above') {
        x = boundsTarget.x;
        y = boundsTarget.y - boundsPopup.height;
    }

    Sys.UI.DomElement.setLocation(popupDiv, x, y);
}

function hidePopup(targetDiv) {

    var popupDiv = $get(targetDiv);
    popupDiv.style.display = 'none';
}