function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}
function ToggleImage() { //v1.0
    var nci = 0, i, j = 0, a = ToggleImage.arguments;
    // Check to see if the county is in the list.
    counties = document.forms['SearchForm'].Counties.value;
    var myCounties = new Array();
    if (counties.indexOf(a[0]) > -1) {
        // Remove the item from the list
        myCounties = counties.split(',');
        var newCounties = new Array();
        for (i = 0; i < (myCounties.length); i += 1) {
            if (myCounties[i] != a[0]) {
                newCounties[nci] = myCounties[i];
                nci++;
            }
        }
        document.forms['SearchForm'].Counties.value = newCounties.toString();
    }
    else {
        // Add the item to the list
        counties = document.forms['SearchForm'].Counties.value;
        if (counties.length > 0) {
            myCounties = counties.split(',');
        }
        myCounties[myCounties.length] = a[0];
        document.forms['SearchForm'].Counties.value = myCounties.toString();
    }
    // Now update the Search List
    UpdateSearchList('SearchForm', 'countyList');
    ResetMap();  // This is defined dynamically in the Map.xslt
    
}
function UpdateSearchList(FormId,ElementId) {
    if (document.forms[FormId].Area.value!='')
    {if (document.forms[FormId].Counties.value == '') {
            document.getElementById(ElementId).innerHTML = 'All'
        }
    else {
        var newCountyList = document.forms[FormId].Counties.value;
        document.getElementById(ElementId).innerHTML = newCountyList.replace(/,/g, ' , ').replace('_', ' ');
    }
    }
}

function changeJobType(NewType) {
    redirecturl = '/jobs/' + NewType;

    if (document.forms['SearchForm'].Area.value != '')
        redirecturl += '/' + document.forms['SearchForm'].Area.value;
        
    if (document.forms['SearchForm'].Counties.value != '')
        redirecturl += '/' + document.forms['SearchForm'].Counties.value;

    location.href = redirecturl;
}

function niceSearchUrl() {
    redirecturl = '/jobs';

    if (document.forms['SearchForm'].JobType.value != '')
        redirecturl += '/' + document.forms['SearchForm'].JobType.value;
    else
        redirecturl += '/Temp';

    redirecturl += '/list';        

    selectedIndex = document.forms['SearchForm'].Qualifications.selectedIndex;
    if ((document.forms['SearchForm'].Qualifications.options[selectedIndex].value != '') && (document.forms['SearchForm'].Qualifications.options[selectedIndex].value != 'none'))
    redirecturl += '/' + document.forms['SearchForm'].Qualifications.options[selectedIndex].value;

    selectedIndex = document.forms['SearchForm'].Speciality.selectedIndex;
    if ((document.forms['SearchForm'].Speciality.options[selectedIndex].value != '') && (document.forms['SearchForm'].Speciality.options[selectedIndex].value != 'none'))
    redirecturl += '/' + document.forms['SearchForm'].Speciality.options[selectedIndex].value;

    if (document.forms['SearchForm'].Area.value !='')
    redirecturl += '/' + document.forms['SearchForm'].Area.value;
    
    if (document.forms['SearchForm'].Counties.value !='')
    redirecturl += '/' + document.forms['SearchForm'].Counties.value;
    document.forms['SearchForm'].action = redirecturl;
    return true;
}

function mapsearch(area) {
    redirecturl = '/jobs';

    if (document.forms['SearchForm'].JobType.value != '')
        redirecturl += '/' + document.forms['SearchForm'].JobType.value;
    else
        redirecturl += '/temp';

    selectedIndex = document.forms['SearchForm'].Qualifications.selectedIndex;
    if ((document.forms['SearchForm'].Qualifications.options[selectedIndex].value != '') && (document.forms['SearchForm'].Qualifications.options[selectedIndex].value != 'none'))
        redirecturl += '/' + document.forms['SearchForm'].Qualifications.options[selectedIndex].value;

    selectedIndex = document.forms['SearchForm'].Speciality.selectedIndex;
    if ((document.forms['SearchForm'].Speciality.options[selectedIndex].value != '') && (document.forms['SearchForm'].Speciality.options[selectedIndex].value != 'none'))
        redirecturl += '/' + document.forms['SearchForm'].Speciality.options[selectedIndex].value;

    if (area != '')
        redirecturl += '/' + area;

    location.href = redirecturl;
}