//Browser Select
// CSS Browser Selector   v0.2.5
// Documentation:         http://rafael.adm.br/css_browser_selector
// License:               http://creativecommons.org/licenses/by/2.5/
// Author:                Rafael Lima (http://rafael.adm.br)
// Contributors:          http://rafael.adm.br/css_browser_selector#contributors
var css_browser_selector = function() {
	var 
		ua=navigator.userAgent.toLowerCase(),
		is=function(t){ return ua.indexOf(t) != -1; },
		h=document.getElementsByTagName('html')[0],
		b=(!(/opera|webtv/i.test(ua))&&/msie (\d)/.test(ua))?('ie ie'+RegExp.$1):is('gecko/')? 'gecko':is('opera/9')?'opera opera9':/opera (\d)/.test(ua)?'opera opera'+RegExp.$1:is('konqueror')?'konqueror':is('applewebkit/')?'webkit safari':is('mozilla/')?'gecko':'',
		os=(is('x11')||is('linux'))?' linux':is('mac')?' mac':is('win')?' win':'';
	var c=b+os+' js';
	h.className += h.className?' '+c:c;
}();

//IE png background tile
document.write('<script type="text/javascript" src="/scripts/iepngfix/iepngfix_tilebg.js"></script>');

//clear form boxes
function clearBox(box)
{
    if(box.value==box.defaultValue)
    {
        box.value = "";
    }
}
function fillBox(box)
{
    if(box.value=="")
    {
        box.value = box.defaultValue;
    }
}

//brands menu code
function goTo(page){

    if (page != "") {
        if (page == "0") {
            resetMenu();
        }
        else {
            document.location.href = "/products.php?cat=" + page;
        }
    }
    return false;
}


function resetMenu(){
    /* Resets the menu to the specified menu item           */
    document.gmenu.page.options[0].selected = true;
}

function checkCurrentStock() {
	if (document.getElementById("quant")) {
		var userQuant = parseInt(document.getElementById("quant").value);
		var storeQuant = parseInt(document.getElementById("currentInStock").value);
		
		//alert("User quatity: " + userQuant + "\nstore quant: " + storeQuant);
		
		if (userQuant <= storeQuant) { // we have in stock the amount of products the user wants to buy
			return true;
		} else {
			alert("You have requested more of this product than we currently have in stock.\nYour requested quantity will be updated to match the available stock");
			document.getElementById("quant").value = storeQuant;
			return false;
		}
	}
}
