

function toggle_state_visibility(country_field_name, state_field_name){
    country_ref = document.getElementById(country_field_name);
    state_ref = document.getElementById(state_field_name);
    
    if((country_ref) && (state_ref)){
        if((country_ref.value == 'US') || (country_ref.value == 'CA')){
            state_ref.style.visibility = "visible";
        }
        else{
            state_ref.value = '';
            state_ref.style.visibility = "hidden";
        }
    }
}


function highlightSelectedBrands(){
    var selectedList = document.getElementById("brands_selected");

    for(i=0; i<selectedList.length; i++){
        selectedList[i].selected=true;
    }

}

function check_add_to_cart_fields(){
    form_ref = document.getElementById('cart');
    
    size_ref = document.getElementById('size');
    quantity_ref = document.getElementById('quantity');

    if(size_ref.value == ''){
        alert('Please select a size');
    }
    else if(quantity_ref.value == ''){
        alert('Please select a quantity');
    }
    else{
        form_ref.submit();
    }
}


function buttonHoverout(){
    var file = this.src.split("1.gif");
    
    if(file[0].indexOf(".gif", 0) == -1){
        this.src = file[0] + ".gif";   
    }
    else{
        this.src = file[0];
    }
}

function initBrandNav(){
    var bn = document.getElementById("brandnav");
    var ul = bn.getElementsByTagName("ul");
    var a = bn.getElementsByTagName("a");
    ul[0].className = "js"
    bn.innerHTML = "<div class=\"top\"></div>" + bn.innerHTML + "<div class=\"bot\"></div>";
    
    for (var i = 0; i<a.length; i++){
        brand_image = a[i].getAttribute('bgimage');
        a[i].style.background = "url(img/"+brand_image+") 0 0 no-repeat";
        addAnEvent(a.item(i),'mouseover',navHover);
        addAnEvent(a.item(i),'mouseout',navHoverout);
    }   
}

/*left over from old product highlights */
function fillup(){
    
}