﻿var ids = new Array('fewerSearchOptionsForm', 'moreSearchOptionsForm');

function switchFormHidden()
{
    var lists = document.getElementsByTagName("select");
    for (var i = 0; i < lists.length; i++)
    {
        lists[i].style.visibility = "hidden"; 
    }
    
}
function switchFormVisible()
{
    var lists = document.getElementsByTagName("select");
    for (var i = 0; i < lists.length; i++)
    {
        lists[i].style.visibility = "visible";
    }

}
function switchSearch(id)
{
    hideallids(id);
    showhide(id);
}

function switchid(id) {
    hideallids(id);
    hideallimgs(id);
    showhide(id);
    showhideimage(id);
}


function showhide(id) {
    if (document.getElementById) { // DOM3 = IE5, NS6
        if (document.getElementById(id) != null) {

            if (document.getElementById(id).style.display == 'none') {
                showdiv(id);
            } else {
                hidediv(id);
            }
        }
    }
    else {
        if (document.id != null) {
            if (document.id.display == 'none') {
                showdiv(id);
            } else {
                hidediv(id);
            }
        }
    }
}

function hideallids(id) {
    //loop through the array and hide each element by id
    for (var i = 0; i < ids.length; i++) {
        if (ids[i] != id) {
            if (document.getElementById(ids[i]) != null) {
                hidediv(ids[i]);
            }
        }
    }
}
function hideallimgs(id) {
    //loop through the array and hide each element by id
    for (var i = 0; i < ids.length; i++) {
        if (ids[i] != id) {
            if (document.getElementById(ids[i]) != null) {
                showhideimage(ids[i]);
            }
        }
    }
}

function hidediv(id) {
    //safe function to hide an element with a specified id
    if (document.getElementById) { // DOM3 = IE5, NS6
        if (document.getElementById(id) != null) {
            document.getElementById(id).style.display = 'none';
        }
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'none';
        }
        else { // IE 4
            document.all.id.style.display = 'none';
        }
    }
}

function showdiv(id) {
    //safe function to show an element with a specified id
    
    if (document.getElementById) { // DOM3 = IE5, NS6
        if (document.getElementById(id) != null) {
            document.getElementById(id).style.display = 'block';
        }
    }
    else {
        if (document.layers) { // Netscape 4
            document.id.display = 'block';
        }
        else { // IE 4
            document.all.id.style.display = 'block';
        }
    }
}


function showhideimage(id) {

    if (document.getElementById) { // DOM3 = IE5, NS6
        if (document.getElementById(id) != null) {

            if (document.getElementById(id).style.display == 'none') {
                document.getElementById(id + 'Img').src = '/act/images/plus.png';
            } else {
                document.getElementById(id + 'Img').src = '/act/images/minus.png';
            }
        }
    }
    else {
        if (document.layers) { // Netscape 4
            if (document.id != null) {

                if (document.id.display == 'none') {
                    document[id + 'Img'].src = '/act/images/plus.png';
                } else {
                    document[id + 'Img'].src = '/act/images/minus.png';
                }
            }
        }
        else { // IE 4
            if (document.all.id != null) {
                if (document.all.id.style.display == 'none') {
                    document.all[id + 'Img'].src = '/act/images/plus.png';
                }
                else {
                    document.all[id + 'Img'].src = '/act/images/minus.png';
                }
            }
        }
    }
}
function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else {
        expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";

}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}