function popup(url, x, y)
{
    var args = "width=" + x + ",height=" + y + ",scrollbars,resizable";
    window.open(url, "_blank", args);
}

function clearField(text, target)
{
    if (target.value == text)
    {
        target.value = '';
    }
}

// Refresh city names when choosing another state (same function name in login.js)
function refreshCity(state, oldCity)
{
    var waiter = new Option("Please wait, loading cities...", "", true, true);
    document.getElementById(oldCity).options[0] = waiter;
    thisUrl = document.location.href;
    splitLoc = thisUrl.indexOf("?");

    // Strip all URL args
    if (splitLoc)
    {
        thisUrl = thisUrl.substring(0, splitLoc);
    }

    document.location.href = thisUrl + "?State=" + state.value;
}

// For broken images
function ImageReplace(target, replacement)
{
    target.src = replacement;
}

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 verify(theForm)
{
    if (
        (theForm.Zip.value == "" || theForm.Zip.value == "Zip") &&
        (theForm.Keyword.value == "" || theForm.Keyword.value == "Keyword") &&
        theForm.State.value == "")
    {
        alert("You must enter a valid zip, state, or keyword value before searching.");
        return false;
    }
    return true;
}

function autoForward(aqui, nextInput)
{
    if (aqui.value.length == aqui.maxLength)
    {
        document.getElementById(nextInput).focus();
    }
}

function activateOptions(thing)
{
    if (thing.value == 'comp')
    {
        document.getElementById('titleCharity').style.display = 'none';
        document.getElementById('titleCompany').style.display = 'block';
        document.getElementById('selectCharity').style.display = 'none';
        document.getElementById('selectCompany').style.display = 'block';
    } else {
        document.getElementById('titleCharity').style.display = 'block';
        document.getElementById('titleCompany').style.display = 'none';
        document.getElementById('selectCharity').style.display = 'block';
        document.getElementById('selectCompany').style.display = 'none';
    }
}

function setSubscribeTop()
{
    browser = navigator.appName;
    if (browser != 'Microsoft Internet Explorer')
    {
        document.getElementById('subscribeLink').style.top = "45px";
    }
}