
function cart_qty_inc(obj,doUpdateCart) {
    var myobj		= jQuery(obj).closest('.obo_qty').find(".item_qty");
    var qty_checked	= myobj.attr('isc');
    var qty_wanted	= myobj.val();
    var qty_avail	= myobj.attr('isq');

    if (typeof doUpdateCart == undefined || typeof doUpdateCart == "undefined" || doUpdateCart == null)
    {
        doUpdateCart=true;
    }
    qty_wanted = qty_wanted.replace(/[^0-9]/g,"");
    if ( qty_wanted.length == 0 ) { qty_wanted = 0; }
    qty_wanted = parseInt(qty_wanted) + 1
	
	if ( qty_checked.length && qty_checked > 0 ) {
		//alert('wanted: '+qty_wanted+' avail:'+qty_avail);
		if ( qty_wanted > qty_avail ) {
			jQuery(this).val(qty_avail);
			alert('Your selection is higher than the in-stock value.  Auto-adjusted to '+qty_avail+'.');
			return(false);
		}
	}
    myobj.val( qty_wanted );
    if (doUpdateCart)
    {
        GlobalCartUpdate(false,350);
    }
    return false;
}
function cart_qty_dec(obj,doUpdateCart) {
    if (typeof doUpdateCart == undefined || typeof doUpdateCart == "undefined" || doUpdateCart == null)
    {
        doUpdateCart=true;
    }
    var currVal = jQuery(obj).closest('.obo_qty').find(".item_qty").val();
    currVal = currVal.replace(/[^0-9]/g,"");
    if ( currVal.length == 0 ) { currVal = 0; }
    if ( parseInt(currVal) > 1 ) {
        jQuery(obj).closest('.obo_qty').find(".item_qty").val( parseInt(currVal) - 1 );
    } else {
        jQuery(obj).closest('.obo_qty').find(".item_qty").val( 0 );
    }
    if (doUpdateCart)
    {
        GlobalCartUpdate(false,350);
    }
}
function cart_set_val(theForm, value, idx) {
	if ( theForm.elements["quantity[]"] ) {
		var the_obj = theForm.elements["quantity[]"];
		if ( the_obj.length == undefined ) {
			the_obj.value = value;
			if ( parseInt(the_obj.value) < 0 ) { the_obj.value = '0'; }
		} else {
			for (var i = 0;i < the_obj.length;i++) {
				if ( i == idx ) {
					the_obj[i].value = value;
					if ( parseInt(the_obj[i].value) < 0 ) { the_obj[i].value = '0'; }
					return;
				}
			}
		}
	}
}

function cart_qty_check(theForm, value, idx) {
	if ( theForm.elements["sqty[]"] ) {
		var the_obj = theForm.elements["sqty[]"];
		if ( the_obj.length == undefined ) {
			if ( parseInt(the_obj.value) < parseInt(value) ) {
				alert('Your selection is higher than the in-stock value.  Auto-adjusted');
				cart_set_val(theForm, the_obj.value, idx);
				return;
			}
		} else {
			for (var i = 0;i < the_obj.length;i++) {
				if ( i == idx ) {
					if ( parseInt(the_obj[i].value) < parseInt(value) ) {
						alert('Your selection is higher than the in-stock value.  Auto-adjusted');
						cart_set_val(theForm, the_obj[i].value, idx);
					}
					return;
				}
			}
		}
	}
}

function addToFavorites(address,sitename) { 
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(sitename, address,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( address,sitename); 
	} else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
	
} 

