function ClearText(textbox, text) {
    if (textbox.value == text) {
        textbox.value = "";
    }
}

function PopulateText(textbox, text) {
    if (textbox.value == "") {
        textbox.value = text;
    }
}

function isNumber() {
    if ((event.keyCode < 44 || (event.keyCode > 57 && event.keyCode < 96) || event.keyCode > 105 || event.keyCode == 45 || event.keyCode == 47) && event.keyCode != 8) event.returnValue = false;
}

function echeck(str) {
    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (str.indexOf(at) == -1) {
        // alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
        //  alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
        //  alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(at, (lat + 1)) != -1) {
        //  alert("Invalid E-mail ID")
        return false
    }

    if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
        //  alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(dot, (lat + 2)) == -1) {
        //  alert("Invalid E-mail ID")
        return false
    }

    if (str.indexOf(" ") != -1) {
        //  alert("Invalid E-mail ID")
        return false
    }

    return true
}
function SetSizeFilter(Size) {
    document.getElementById("SizeFilter").value = Size;
    document.searchcriteria.submit();
}
function SeeMoreSizes() {
    document.getElementById("MoreSizes").style.display = 'block';
    document.getElementById("LessSizes").style.display = 'none';
}
function SeeLessSizes() {
    document.getElementById("MoreSizes").style.display = 'none';
    document.getElementById("LessSizes").style.display = 'block';
}
function SeeMoreBrands() {
    document.getElementById("MoreBrands").style.display = 'block';
    document.getElementById("LessBrands").style.display = 'none';
}
function SeeLessBrands() {
    document.getElementById("MoreBrands").style.display = 'none';
    document.getElementById("LessBrands").style.display = 'block';
}
function ClearPriceFilter() {
	document.getElementByID('Price').value = ''
}
function DisplayNavAwayDiv() {
    var oDiv = document.getElementById("NavigateAwayDiv")
    oDiv.style.display = 'block';
}
function HideNavAwayDiv() {
    var oDiv = document.getElementById("NavigateAwayDiv")
    oDiv.style.display = 'none';
}
function NavigateToExternalSite(strURL, strWinName) {
    HideNavAwayDiv();
    window.open(strURL, strWinName, "status=1, toolbar=1, location=1, menubar=1, directories=1, resizable=1, scrollbars=1, height=500, width=500");
}
function clearDefault(el) {
    if (el.defaultValue == el.value) el.value = ""
}

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 correctPNG() {
    // no operation - for other browsers than old IE versions
}

function makeRequest(url) {

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        http_request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    http_request.onreadystatechange = refreshscreen;
    http_request.open('GET', url, true);
    http_request.send(null);

}

function refreshscreen() {
    //if (http_request.readyState == 4) {
    if (http_request.status == 200) {
        //window.location.href=window.location.href;
    }


}

function imgSwap(oImg) {
    var strOver = "-on"    // image to be used with mouse over
    var strOff = "-off"     // normal image
    var strImg = oImg.src
    if (strImg.indexOf(strOver) != -1) {
        oImg.src = strImg.replace(strOver, strOff)
    } else {
        oImg.src = strImg.replace(strOff, strOver)
    }
}
