// function: swap gif images
function swapImageGif(img) {
    thisSrc = img.src
    if (thisSrc.indexOf("Over") > 0) {
        thisSrc = thisSrc.replace("Over.gif", ".gif")
        img.src = thisSrc
    } else {
        thisSrc = thisSrc.replace(".gif", "Over.gif")
        img.src = thisSrc
    }
}

// function: swap png images
function swapImagePng(img) {
    thisSrc = img.src
    if (thisSrc.indexOf("Over") > 0) {
        thisSrc = thisSrc.replace("Over.png", ".png")
        img.src = thisSrc
    } else {
        thisSrc = thisSrc.replace(".png", "Over.png")
        img.src = thisSrc
    }
}

// function: to clear login field
function clearSearchField(e) {
    if ("Search" == e.value) {
        e.value = '';
    }
    else if (e.value == '') {
        e.value = "Search";
    }
}

// function: to check search element
function checkSearch(e) {
    var search = document.getElementById(e).value;

    if ((search != "Search") && (search != "")) {
        return true;
    }
    else {
        alert("Please submit a search");
        return false;
    }
}

// function: force enter click
function forceClick(e, elemId) {
    var elem = document.getElementById(elemId);
    var evt = (e) ? e : window.event;
    var intKey = (evt.which) ? evt.which : evt.keyCode;

    if (intKey == 13) {
        elem.click();
        return false;
    }
    return true;
}

// function: add pngfix class for all PNGs
function addPngFix() {
    //alert("images # " + document.images.length);
    for (i=0;i<document.images.length;i++){
        //if button is a png
        if (document.images[i].src.indexOf('.png') > 0) {
            //alert("src: " + document.images[i].src);
            document.images[i].className = 'pngfix';
        }
	}
}

// function: to clear message field
function clearMessageField(e) {
    if ("Enter Text" == e.value) {
        e.value = '';
    }
    else if (e.value == '') {
        e.value = "Enter Text";
    }
}