function ShowCateringPopup(ProductID) {
	var myWidth = 0, myHeight = 0, myVertScroll = 0;
	if (typeof (window.innerWidth) == 'number') {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myVertScroll = window.pageYOffset;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		if (document.documentElement.scrollTop) { myVertScroll = document.documentElement.scrollTop; }
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		if (document.body.scrollTop) { myVertScroll = document.body.scrollTop };
	}
	//window.alert('Width = ' + myWidth);
	//window.alert('Height = ' + myHeight);

	var popupWidth=651;
	var leftOffset = (myWidth/2)-(popupWidth/2);
	var topOffset = (myHeight/3) + myVertScroll;
	

	jQuery('#productPopup'+ProductID).css({'left':leftOffset,'top':topOffset});
	jQuery('#productPopup'+ProductID).fadeIn();
	jQuery('#FullWindowShade').show();
}

function HideCateringPopup(ProductID) {
	jQuery('#productPopup'+ProductID).fadeOut();
	jQuery('#FullWindowShade').hide();
}

function CateringAddToCart(product_id, subproduct_id, url) {
	var qty = jQuery('#qty'+subproduct_id).val();
	var request = encodeURIComponent(jQuery('#special_request_'+subproduct_id).val());
	var requestOptionId = jQuery('#special_request_option_id_'+subproduct_id).val();
	var option_str = '';
	var params = "product_id=" + product_id + "&subproduct_id=" + subproduct_id + "&qty=" + qty + "&request=" + request + "&requestoptionid=" + requestOptionId;
	jQuery('[name=options_'+subproduct_id+']').each(function(){
		if (jQuery(this).is(':checked')){
			params += '&custom_option[]='+jQuery(this).attr('option_id')+':'+jQuery(this).attr('value');
		}
	});
	
	var result = jQuery.getJSON(url + 'scripts/ajaxAddToCart.php', params, function(data, textStatus){
	   if (textStatus == "error"){
			alert("There was an error adding this item to your cart.  Please call customer service for assistance.", "Error");
			return;
	   }
	   if (data.result == "error"){
			alert("Sorry, an error occurred while adding the item to your cart.  The error was: '" + data.message + "'");
			return;
	   }
	   //alert("Thanks!  The item has been added to your cart!")
	   HideCateringPopup(subproduct_id);
	   ReloadCartSidebar(url);
	});
}

function ReloadCartSidebar(url) {
	jQuery.get(url + 'skin/frontend/default/butterfield/cart-sidebar.php', '',function(result){document.getElementById('catering-order-sidebar').innerHTML=result;})	
}


