﻿function aarce_getHost() {
    if(location.hostname=="localhost") {
        var p = location.pathname;
        var i = p.indexOf("/", 1);
        return "http://" + location.host + p.substring(0, i+1);
    }
    else
        return _site;
}
function aarce_addToCart(objId, attributeName, productId) {
    var dObj = document.getElementById(objId);
    if (dObj) {
        if (dObj.selectedIndex > 0) {
            var opt = dObj.options[dObj.selectedIndex];
            window.location.href = aarce_getHost() + "ShoppingCart/AddToCart.aspx?productId=" + productId.toString() + "&padid=" + opt.value;
        }
        else
            alert("Please select a " + attributeName + " before adding the product to your shopping cart");
    }
    else
        window.location.href = aarce_getHost() + "ShoppingCart/AddToCart.aspx?productId=" + productId.toString() + "&padid=0";
}
function aarce_tellAFriend(productId) {
    window.location.href = aarce_getHost() + "Products/tell-a-friend.aspx?productId=" + productId.toString();
}
function aarce_recalculateTotal(obj, hObj, tlObj, slObj) {
    var nt = parseFloat(document.getElementById(hObj).value)+parseFloat(obj.options[obj.selectedIndex].value);
    var nt2=nt+"";
    document.getElementById(tlObj).innerHTML = "$" + nt2.substring(0,nt2.indexOf('.')+3);
    var s = parseFloat(obj.options[obj.selectedIndex].value) + "";
    document.getElementById(slObj).innerHTML = "$" + s.substring(0,s.indexOf('.')+3);
}
function aarce_checkout(l,sObj) {
    var r = document.getElementById(sObj);
    window.location.href = aarce_getHost()+l+"&sr="+r.options[r.selectedIndex].value;
}
function aarce_processOrder(objId) {
    document.getElementById(objId).style.visibility="visible";
}
function aarce_productCategoryDescription(objId) {
    if (objId != null)
        document.getElementById(objId).style.display = "none";
}
function aarce_searchSite(tb_id, df_txt) {
	var val = document.getElementById(tb_id).value;
	if((val!=df_txt)&&(val!=""))
		window.location.href = aarce_getHost() + "products/search.aspx?_q=" + val;
}
