/*
dhtml.js / v0.93  -- seamless web javascript dhtml functionality
*/

var isDOM=document.getElementById?1:0,
 isIE=document.all?1:0,
 isIE6=(navigator.userAgent.toLowerCase().indexOf("msie 6.0")!=-1 || navigator.userAgent.toLowerCase().indexOf("msie 7.0")!=-1) ?1:0,
 isNS4=navigator.appName=='Netscape'&&!isDOM?1:0,
 isOp=self.opera?1:0,
 isDyn=isDOM||isIE||isNS4;
 
if (!self.page) var page = { win:self, minW:0, minH:0, MS:isIE&&!isOp };
page.db = function(p) { with (this.win.document) return ( isDOM ? (isIE6?documentElement[p]:body[p]):0 ) };
page.winW=function() { with (this) return Math.max(minW, MS ? db('clientWidth') : win.innerWidth) };
page.winH=function() { with (this) return Math.max(minH, MS ? db('clientHeight') : win.innerHeight) };

page.scrollX=function() { with (this) return MS ? db('scrollLeft') : win.pageXOffset };
page.scrollY=function() { with (this) return MS ? db('scrollTop') : win.pageYOffset };
var isDOM=document.getElementById?1:0, isIE=document.all?1:0, isNS4=navigator.appName=='Netscape'&&!isDOM?1:0, isOp=self.opera?1:0, isDyn=isDOM||isIE||isNS4;

var SETTINGS = {
	delay_show : 600,
	delay_hide : 100,
	debug : false
};


// some of the following position expressions may not be very intuitive, due to positioning bugs in the browsers

var INFO_POPUP_INSTANCES = {
	InfoPopupRestaurantDetail : new InfoPopup(
		"InfoPopupRestaurantDetail",
		"RESTAURANT_DETAIL",
		"RestaurantListing",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth + 100);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 100);" +
			"}" +
		""),
		new Function("obj, popUp", "" +
			"if (browser.isNS6()) {" + 
				"return ( obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6 );" +
			"} else {" + 
				"popupOffset = RecurseTopOffset(obj.parentNode.parentNode.parentNode.parentNode, \"PageWrapper\" ) ;" + 
				"return fixBottomEdge( popUp, RecurseTopOffset(obj, \"PageWrapper\" )) - popupOffset ;" +
			"}" +
		""),
		// I have to make this function better at some point
		new Function("" +
			"var do_it = false;" +
			"var all_divs = DOM_OBJECTS['RestaurantListing'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].style.display != 'block') ) {" +
					"do_it = true;" +
					"break;" +
				"}" +
			"}" +
			"return do_it;" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#EEE';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true,
		false,
		600
	),
	
	InfoPopupSurveyResults : new InfoPopup(
		"InfoPopupSurveyResults",
		"SURVEY_RESULTS", 
		"SurveyList",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 40);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop );" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop +20);" + 
			"}" + 
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),	
	
	
	InfoPopupMenuCategory : new InfoPopup(
		"InfoPopupMenuCategory",
		"MENU_CATEGORY",
		"RestaurantMenu",
		new Function("obj", "return (obj.offsetLeft);"),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (40);" + 
			"} else {" +
				"return (obj.offsetTop + 20);" + 
			"}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true,
		false,
		600
	),
	
	InfoPopupRestaurantUserRatingInfo : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"RestaurantRatingBox",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetLeft - obj.parentNode.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 8);"+
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop - 24);" +
			"} else {" +
				"return (obj.offsetTop - 22);" +
			"}" + 
		""), 
		new Function("return true;"),
		new Function("" +
		"if (browser.isIEwin()) {" +
			"for (var i=0; i < DOM_OBJECTS['RestaurantTabs'].childNodes.length; i++) {" +
				"DOM_OBJECTS['RestaurantTabs'].childNodes[i].style.visibility = 'hidden';" +
			"}" + 
		"}" +
		""),
		new Function("" +
		"if (browser.isIEwin()) {" +
			"for (var i=0; i < DOM_OBJECTS['RestaurantTabs'].childNodes.length; i++) {" +
				"DOM_OBJECTS['RestaurantTabs'].childNodes[i].style.visibility = 'visible';" +
			"}" + 
		"}" +
		""),
		false
	),
	
	InfoPopupRestaurantUserRatingRecent : new InfoPopup(
		"InfoPopupRestaurantUserRatingRecent",
		"USER_RATING_RECENT",
		"BoxRecentRestaurants",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetLeft - obj.parentNode.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth);" +
			"} else {" +
				"return (obj.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 4);" + 
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 12);" +
			"} else if (browser.isNS6()) {" +
				"return (obj.parentNode.offsetTop - 22);" + 
			"} else {" +
				"return (obj.parentNode.offsetTop -345);" + 
			"}" + 
		""), 
		new Function("if(DOM_OBJECTS[INFO_POPUP_INSTANCES['InfoPopupRestaurantUserRatingLast'].dom_id]!=null){hide_immediately=true; hideInfoPopup('InfoPopupRestaurantUserRatingLast',null, true)};return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),
	
	InfoPopupRestaurantUserRatingLast : new InfoPopup(
		"InfoPopupRestaurantUserRatingLast",
		"USER_RATING_LAST",
		"BoxLastOrder",
		new Function("obj", "" +
			"if (browser.isIEwin55()) {" +
				"return (20 - DOM_OBJECTS[this.dom_id].offsetWidth);" +
			"} else if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth + (obj.offsetLeft - obj.parentNode.offsetLeft) );" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 14);" +
			"}" + 
		""),
		new Function("obj", "return (obj.parentNode.parentNode.offsetHeight - 44);"),
		new Function("if(DOM_OBJECTS[INFO_POPUP_INSTANCES['InfoPopupRestaurantUserRatingRecent'].dom_id]!=null){hide_immediately=true; hideInfoPopup('InfoPopupRestaurantUserRatingRecent',null, true)};return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupRestaurantUserRatingFirm : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"BoxFirmRecommended",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
				"return ( (obj.offsetLeft - obj.parentNode.parentNode.offsetLeft) - DOM_OBJECTS[this.dom_id].offsetWidth );" +
			"} else {" + 
				"return (obj.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 10);" + 
			"}" +
		""),
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6);" + 
			"} else {" + 
				"return (obj.parentNode.offsetTop + 6);" + 
			    "}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupRestaurantUserRatingRush : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"BoxRushOrder",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
				"return ( (obj.offsetLeft - obj.parentNode.parentNode.offsetLeft) - DOM_OBJECTS[this.dom_id].offsetWidth );" +
			"} else {" + 
				"return (obj.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 10);" + 
			"}" +
		""),
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6);" +
			"} else {" + 
				"return (obj.parentNode.offsetTop + 6);" + 
			"}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),
	
	InfoPopupRestaurantUserRatingUtility : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"UtilityTab",
		new Function("obj", "" + 
			"if (browser.isNS6()) {" +
				"return (obj.parentNode.offsetLeft - obj.parentNode.parentNode.offsetLeft + obj.parentNode.offsetWidth);" + 
			"} else {" +
				"return (obj.parentNode.offsetLeft + obj.parentNode.offsetWidth - 25);" + 
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isIEwin50()) {" +
				"return (obj.offsetParent.offsetParent.offsetParent.offsetTop + obj.offsetParent.offsetTop - 16);" + 
			"} else if (browser.isNS6()) {" +
				"return ( 34 + (obj.parentNode.parentNode.parentNode.parentNode.offsetTop - obj.parentNode.parentNode.parentNode.parentNode.offsetTop) + (obj.offsetTop - obj.parentNode.parentNode.parentNode.parentNode.offsetTop));" + 
			"} else {" +
				"return (obj.parentNode.parentNode.parentNode.parentNode.offsetTop + obj.offsetParent.offsetTop - 20);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),
	
	
	InfoPopupCateringFavorite : new InfoPopup(
		"InfoPopupCateringFavorite",
		"CATERING_FAVORITE",
		"BoxCateringReorder",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth + 6)" + 
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 14);" + 
			"}" +
		""),
		new Function("obj", "" + 
			"if (browser.isIEwin50()) {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop - 16);" +
			"} else if (browser.isNS60()) {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop - 22);" + 
			"} else {" +
				"return ((obj.offsetTop > obj.offsetParent.offsetTop) ? (obj.offsetTop - obj.offsetParent.offsetTop - 30) : obj.offsetTop - 24);" +
			"}" +
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"), 
		true
	),
		 
	InfoPopupCateringFavoriteAll : new InfoPopup(
	    "InfoPopupCateringFavoriteAll",
	    "CATERING_FAVORITE_ALL",
	    "MainColumn",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
			    "return (obj.offsetLeft + obj.offsetWidth + 12);" + 
			"} else {" +
			    "return (obj.parentNode.parentNode.parentNode.offsetLeft + obj.offsetLeft + obj.offsetWidth + 12);" + 
			"}" +
		""),
		new Function("obj", "" + 
		    "if (browser.isIEwin50()) {" +
			    "return (obj.parentNode.offsetTop + obj.offsetParent.offsetParent.offsetTop - 22);" + 
		    "} else if (browser.isNS60()) {" +
			    "return ( 46 + (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop) - 22);" + 
			"} else {" +
			    "return (obj.parentNode.offsetTop - 22);" + 
			"}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
	    true
	),

	
	
	InfoPopupCateringFavoriteDetail : new InfoPopup(
		"InfoPopupCateringFavoriteDetail",
		"CATERING_FAVORITE_DETAIL",
		"FavoriteColumn",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetLeft + obj.offsetWidth + 12);" + 
			"} else {" +
				"return (obj.parentNode.parentNode.parentNode.offsetLeft + obj.offsetLeft + obj.offsetWidth + 12);" + 
			"}" +
		""),
		new Function("obj", "" + 
			"if (browser.isIEwin50()) {" +
				"return (obj.parentNode.offsetTop + obj.offsetParent.offsetParent.offsetTop - 22);" + 
			"} else if (browser.isNS60()) {" +
				"return ( 46 + (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop) - 22);" + 
			"} else {" +
				"return (obj.parentNode.offsetTop - 22);" + 
			"}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),
	InfoPopupSaveMealsFavorite : new InfoPopup(
		"InfoPopupSaveMealsFavorite",
		"SAVE_FAVORITE",
		"OrderActions",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 10);" +
			"}" + 
		""),
		new Function("obj", "" +
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop + 400);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop + 400);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupSaveMealsFavoriteTwo : new InfoPopup(
		"InfoPopupSaveMealsFavoriteTwo",
		"SAVE_FAVORITE_TWO",
		"BoxLastOrder",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 10);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop - 16);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop - 22);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupShowAddress : new InfoPopup(
		"InfoPopupShowAddress",
		"SHOW_ADDRESS",
		"ShowAddress",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth + 270);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth + 270);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop + 200);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop + 200);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupShowPromotionCode : new InfoPopup(
		"InfoPopupShowPromotionCode",
		"SHOW_PROMOTIONCODE",
		"ShowPromotionCode",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth + 270);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth + 270);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop + 15);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop + 15);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupCCVDescriptions : new InfoPopup(
		"InfoPopupCCVDescriptions",
		"CCV_DESCRIPTION",
		"CCVDescriptionList",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth + 270);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth + 340);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop + 15);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop + 70);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupSaveFavoriteOrderHistory : new InfoPopup(
		"InfoPopupSaveFavoriteOrderHistory",
		"SAVE_FAVORITE_ORDERHIST",
		"SaveMealsOrderHistory",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft + DOM_OBJECTS[this.dom_id].offsetWidth - 340);" +
			"}" + 
		""),
		new Function("obj", "" +
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop - 22);" +
			"} else {" +
				"return (obj.offsetTop + obj.parentNode.parentNode.offsetTop - 52);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	
	InfoPopupSaveCateringFavoriteOrderHistory : new InfoPopup(
	"InfoPopupSaveCateringFavoriteOrderHistory",
	"SAVE_CATERING_FAVORITE_ORDERHIST",
	"SaveCateringOrderHistory",
		new Function("obj", "" +
			"if (browser.isNS60()) {" +
			"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
			"return (obj.offsetLeft + DOM_OBJECTS[this.dom_id].offsetWidth - 750);" +
			"}" + 
		""),
		new Function("obj", "" +
		"if (browser.isNS6() && !browser.isNS60()) {" +
			"return (obj.offsetTop - 44);" +
			"} else {" +
			"return (obj.offsetTop + obj.parentNode.parentNode.offsetTop - 120);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
	false
	),

	InfoPopupSaveCateringFavorite : new InfoPopup(
		"InfoPopupSaveCateringFavorite",
		"SAVE_FAVORITE0", //SAVE_FAVORITE0 is the popup for saving the favorite on the catering page
		"OrderActions",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 30);" +
			"}" + 
		""),
		new Function("obj", "" +
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop );" +
			"} else if (browser.isIE7()) {" + 
				"return (obj.offsetTop - (obj.parentNode.parentNode.offsetTop + 100));" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop + 400);" +
			"}" +
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupSaveCateringFavoriteTwo : new InfoPopup(
	"InfoPopupSaveCateringFavoriteTwo",
	"SAVE_FAVORITE_TWO",
		"OrderActions",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth - 6);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 10);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
			"return (obj.offsetTop - 22);" +
			"} else {" +
			"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop - 22);" + 
			"}" + 
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupItemDetail : new InfoPopup(
		"InfoPopupItemDetail",
		"ITEM_DETAIL",
		"ItemList",
		new Function("obj", "" + 
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth + 90);" +
			"} else {" +
				"return (obj.parentNode.offsetWidth + 80);" +
			"}" + 
		""),
		new Function("obj, popUp", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6);" +
			"} else {" +
				"popupOffset = RecurseTopOffset(obj.parentNode.parentNode.parentNode.parentNode.parentNode, \"PageWrapper\" ) ;" + 
				"return fixBottomEdge( popUp, RecurseTopOffset(obj, \"PageWrapper\" )) - popupOffset ;" +
			"}" + 
		""),
		new Function("return true;"),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true
	),

	
	InfoPopupItemDetailTwo : new InfoPopup(
	    "InfoPopupItemDetailTwo",
	    "ITEM_DETAILTWO",
	    "ItemList",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetLeft + obj.parentNode.parentNode.offsetLeft + 150);" +
			"} else {" +
				"return (obj.offsetLeft + obj.parentNode.parentNode.offsetLeft + 150);" +
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS6() && !browser.isNS60()) {" +
				"return (obj.offsetTop + obj.parentNode.parentNode.offsetTop + 8);" + 
			"} else {" +
				"return (obj.offsetTop + obj.parentNode.parentNode.offsetTop + 8);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#EEE';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true
	),
	
	InfoPopupProductDetailLeft : new InfoPopup(
		"InfoPopupProductDetailLeft",
		"PRODUCT_DETAIL",
		"MenuListingLeft",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 50);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 38);" +
			"}" +
		""),
		new Function("obj", "" +
			"var tmpOffset;" +
			"var all_divs = DOM_OBJECTS['MenuListingLeft'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].id == obj.id)) {" +
				"return GetTotalTopOffset(all_divs[i]) - 290;" +
				"}" +
			"}" +
		""),
		// i have to make this function better at some point
		new Function("" +
			"var do_it = false;" +
			"var all_divs = DOM_OBJECTS['MenuListingLeft'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].style.display != 'block') ) {" +
					"do_it = true;" +
					"break;" +
				"}" +
			"}" +
			"return do_it;" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#EEE';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true,
		true
	),
	
	InfoPopupProductDetail : new InfoPopup(
		"InfoPopupProductDetail",
		"PRODUCT_DETAIL", 
		"MenuListingRight",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 90);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 38);" +
			"}" +
		""),
		new Function("obj", "" +
			"var tmpOffset;" +
			"var all_divs = DOM_OBJECTS['MenuListingRight'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].id == obj.id)) {" +
				"return GetTotalTopOffset(all_divs[i]) - 290;" +
				"}" +
			"}" +
		""),
		// i have to make this function better at some point
		new Function("" +
			"var do_it = false;" +
			"var all_divs = DOM_OBJECTS['MenuListingRight'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].style.display != 'block') ) {" +
					"do_it = true;" +
					"break;" +
				"}" +
			"}" +
			"return do_it;" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#EEE';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true,
		true
	),	
	
	InfoPopupProductFoundItem : new InfoPopup(
		"InfoPopupProductFoundItem",
		"PRODUCT_DETAIL",
		"SearchResults",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.parentNode.parentNode.offsetWidth - 60);" +
			"} else {" + 
				"return (obj.parentNode.parentNode.parentNode.offsetWidth - 60);" +
			"}" +
		""),
		new Function("obj", "" +
			"var tmpOffset;" +	
			"return obj.offsetTop + obj.parentNode.offsetTop + obj.parentNode.parentNode.offsetTop + obj.parentNode.parentNode.parentNode.offsetTop + obj.parentNode.parentNode.parentNode.parentNode.offsetTop;" +
		""),
		// i have to make this function better at some point
		new Function("" +
			"var do_it = false;" +
			"var all_divs = DOM_OBJECTS['SearchResults'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].style.display != 'block') ) {" +
					"do_it = true;" +
					"break;" +
				"}" +
			"}" +
			"return do_it;" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#EEE';" +
		""),
		new Function("node", "" +
			"node.parentNode.parentNode.style.backgroundColor = '#FFF';" +
		""),
		true,
		true
	),	
	
	InfoPopupOrderDetail : new InfoPopup(
		"InfoPopupOrderDetail",
		"ORDER_DETAIL",
		"MyCurrentOrder",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (0 - DOM_OBJECTS[this.dom_id].offsetWidth);" + 
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth);" + 
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetTop - obj.parentNode.offsetTop - 20);" + 
			"} else {" +
				"return (obj.offsetTop - 20);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),
	
	InfoPopupReorderConfirm : new InfoPopup(
		"InfoPopupReorderConfirm",
		"REORDER_CONFIRM",
		"UtilityTab",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth + 90);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 90);" +
			"}" +
		""),
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6);" +
			"} else {" + 
				"return (obj.parentNode.offsetTop + 61);" +
			"}" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),
	
	InfoPopupPromotionDescription : new InfoPopup(
		"InfoPopupPromotionDescription",
		"PROMOTION_DESCRIPTION",
		"RestaurantListing",
		new Function("obj", "" + 
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"} else {" +
				"return (obj.parentNode.offsetWidth + 360);" +
			"}" + 
		""),
		new Function("obj, popUp", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop + 6);" +
			"} else {" +
				"popupOffset = RecurseTopOffset(obj.parentNode.parentNode.parentNode.parentNode, \"PageWrapper\" ) ;" + 
				"return fixTopBottom( popUp, RecurseTopOffset(obj, \"PageWrapper\" )) - (popupOffset - 20) ;" +				
			"}" + 
		""), 
		new Function("" +
			"var do_it = false;" +
			"var all_divs = DOM_OBJECTS['RestaurantListing'].getElementsByTagName('DIV');" +
			"for (var i=0; i < all_divs.length; i++) {" +
				"if ( (all_divs[i].className == 'ExtendedInfo') && (all_divs[i].style.display != 'block') ) {" +
					"do_it = true;" +
					"break;" +
			"}" +
			"}" +
			"return do_it;" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		true,
		false
	)	
	

};


var INFO_POPUP_VARIANTS = {
	RESTAURANT_DETAIL : new InfoPopupVariant(
		"<h6><small>SEAMLESSWEB DETAILS FOR:</small><br /><span id=\"InfoPopupRestaurantDetailsName\"></span></h6>" +
		"<p id=\"InfoPopupRestaurantDetailsDescription\"></p>" + 
		"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"DataTable\" style=\"display: none;\">" +
			"<tr><th style=\"text-align:left;\">Rating:</th><th>Food</th><th>Delivery</th></tr>" +
			"<tr><td></td><td id=\"InfoPopupRestaurantDetailsRatingFood\"></td><td id=\"InfoPopupRestaurantDetailsRatingDelivery\"></td></tr>" +
		"</table>" + 
		"<p><strong><p id=\"InfoPopupDeliveryMethod\" style=\"font-weight:bold;\"><\p></strong> <span id=\"InfoPopupRestaurantDetailsDelivTime\"></span></p>" + 
		"<p><strong>Min. Order:</strong> <span id=\"InfoPopupRestaurantDetailsMinOrder\"></span></p>" + 
		"<p><strong>Hours:</strong> <span id=\"InfoPopupRestaurantDetailsHours\"></span></p>",
		['InfoPopupRestaurantDetailsName','InfoPopupRestaurantDetailsDescription','InfoPopupRestaurantDetailsRatingFood','InfoPopupRestaurantDetailsRatingDelivery','InfoPopupRestaurantDetailsDelivTime','InfoPopupRestaurantDetailsMinOrder','InfoPopupRestaurantDetailsHours','InfoPopupDeliveryMethod'],
		false
	),
	
	SURVEY_RESULTS : new InfoPopupVariant(
		"<form name=\"survey_result_form\">" +
		    "<h6><small>SURVEY RESULTS (%):</small><br /></h6>" + 
		    "<Table><TBODY id=\"survey_result_list\" name=\"survey_result_list\"><TBODY></Table>" +
		    "</form>",
		['survey_result_list'],
		false
	),

	RATINGS_DETAIL : new InfoPopupVariant(
		"<h6><small>RATINGS DETAIL FOR:</small><br /><span id=\"InfoPopupRestaurantRatingName\"></span></h6>" + 
		"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" + 
			"<tr><th width=\"40%\">Food</th><th width=\"60%\">Delivery</th></tr>" + 
			"<tr><td id=\"InfoPopupRestaurantRatingFood\"></td><td id=\"InfoPopupRestaurantRatingDelivery\"></td></tr>" + 
		"</table>",
		['InfoPopupRestaurantRatingName','InfoPopupRestaurantRatingFood','InfoPopupRestaurantRatingDelivery'],
		false
	),

	MENU_CATEGORY : new InfoPopupVariant(
		"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\" ><tr valign=\"top\">" +   
			"<td width=\"33%\" id=\"InfoPopupMenuCategoryColumn1\"></td>" +
			"<td width=\"34%\" id=\"InfoPopupMenuCategoryColumn2\"></td>" +
			"<td width=\"33%\" id=\"InfoPopupMenuCategoryColumn3\"></td>" +
		"</tr></table>",
		['InfoPopupMenuCategoryColumn1','InfoPopupMenuCategoryColumn2','InfoPopupMenuCategoryColumn3'],
		false
	),

	CATERING_FAVORITE : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupRestaurantRatingName\"></span></h6>" + 
		"<div id=\"InfoPopupCateringFavoriteTitle\"></div>" +
		"<p id=\"InfoPopupCateringFavoriteDesc\"></p>" +
		"<ul id=\"InfoPopupCateringFavoriteList\" class=\"DotBullet\"></ul>" +
		"<div class=\"Text\">" +
		"</div>",
		['InfoPopupRestaurantRatingName', 'InfoPopupCateringFavoriteTitle', 'InfoPopupCateringFavoriteDesc', 'InfoPopupCateringFavoriteList'],
		false
	),

	
	CATERING_FAVORITE_ALL : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupRestaurantRatingName\"></span></h6>" + 
		"<div id=\"InfoPopupCateringFavoriteTitle\"></div>" +
		"<p id=\"InfoPopupCateringFavoriteDesc\"></p>" +
		"<ul id=\"InfoPopupCateringFavoriteList\" class=\"DotBullet\"></ul>" +
		"<div class=\"Text\">" +
		"</div>",
		['InfoPopupRestaurantRatingName', 'InfoPopupCateringFavoriteTitle', 'InfoPopupCateringFavoriteDesc', 'InfoPopupCateringFavoriteList'],
		false
	),
	
	REORDER_CONFIRM : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupRestaurantRatingName\"></span></h6>" + 
		"<p><div class=\"Text\" id=\"InfoPopupConfirmMessage\"></div></p>" +
		"<form name=\"reorder_form\" action=\"AddReorderOrderHistory.m\" method=\"post\" target=\"\">" +
		"<input type=\"hidden\" name=\"OrderIdToReorder\" value=\"\" />" + 
		"<input type=\"hidden\" name=\"VendorTypeForReorder\" value=\"\" />" + 
		"<div style=\"width:150px; margin: 0 auto;\">" + 
		" &nbsp;&nbsp;<input type=\"submit\" name=\"accept_submitY\" class=\"CustomSubmitButton\"  value=\"OK\" >" +
		" &nbsp;<input type=\"submit\" name=\"accept_submitN\" class=\"CustomSubmitButton\" onclick=\"hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" value=\"Cancel\">" +
		"</div></form>",
		['InfoPopupConfirmMessage', 'InfoPopupOrderIdToReorder', 'InfoPopupVendorTypeForReorder'],
		false
	),
	CATERING_FAVORITE_DETAIL : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupRestaurantRatingName\"></span></h6>" + 
		"<div id=\"InfoPopupCateringFavoriteTitle\"></div>" +
		"<p id=\"InfoPopupCateringFavoriteDesc\"></p>" +
		"<ul id=\"InfoPopupCateringFavoriteList\" class=\"DotBullet\"></ul>",
		['InfoPopupRestaurantRatingName', 'InfoPopupCateringFavoriteTitle', 'InfoPopupCateringFavoriteDesc', 'InfoPopupCateringFavoriteList'],
		false
	),

	USER_RATING : new InfoPopupVariant(
		"<h6><small>PROVIDE A SEAMLESS RATING FOR:</small><br /><span id=\"InfoPopupUserRatingRestaurantName\"></span></h6>" +
		"<p><strong>Ratings:</strong> Click to rate this vendor.</p>" +
		"<form name=\"user_rating_form\" action=\"RateRecentMealsVendorStep2.m\" method=\"post\" target=\"\" >" +
			"<div>" +
			"<input type=\"hidden\" name=\"user_rating_restaurant\" value=\"\" />" + 
			"<input type=\"hidden\" name=\"user_rating_food\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_delivery\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_vendorLocationId\" value=\"-1\" />" + 
			"<input type=\"hidden\" name=\"whichStep\" value=\"\" />" +
			"<input type=\"hidden\" name=\"whichType\" value=\"\" />" +
			"</div>" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Food</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('food', this);\">1</td><td onclick=\"setUserRating('food', this);\">2</td><td onclick=\"setUserRating('food', this);\">3</td><td onclick=\"setUserRating('food', this);\">4</td><td onclick=\"setUserRating('food', this);\">5</td><td onclick=\"setUserRating('food', this);\">6</td><td onclick=\"setUserRating('food', this);\">7</td><td onclick=\"setUserRating('food', this);\">8</td><td onclick=\"setUserRating('food', this);\">9</td><td onclick=\"setUserRating('food', this);\">10</td></tr></table>" +
			"</div>" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Delivery</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('delivery', this);\">1</td><td onclick=\"setUserRating('delivery', this);\">2</td><td onclick=\"setUserRating('delivery', this);\">3</td><td onclick=\"setUserRating('delivery', this);\">4</td><td onclick=\"setUserRating('delivery', this);\">5</td><td onclick=\"setUserRating('delivery', this);\">6</td><td onclick=\"setUserRating('delivery', this);\">7</td><td onclick=\"setUserRating('delivery', this);\">8</td><td onclick=\"setUserRating('delivery', this);\">9</td><td onclick=\"setUserRating('delivery', this);\">10</td></tr></table>" +
			"</div>" +
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">Add a review for this restaurant (optional):</p>" + 
			"<div style=\"margin: 5px;\">" +
			"<textarea name=\"ReviewText\" rows=\3\" cols=\"28\" ></textarea>" +
			"</div>" +
			"<div style=\"width:150px; margin: 0 auto;\"><button name=\"rating_submit\" class=\"CustomButton\" onclick=\"submitUserRating();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Save and Close</button></div>" +
			"<div style=\"font-size: 60%; width:50px; margin: 0 auto;\"><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></div>" +
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">NOTE: Your new rating will replace your previous ratings for this vendor. All food ratings submitted by our users are averaged; delivery ratings submitted by all users at your company are averaged.</p>" + 

		"</form>",
		['InfoPopupUserRatingRestaurantName'],
		true
	),

	
	USER_RATING_LAST : new InfoPopupVariant(
		"<h6><small>PROVIDE A SEAMLESS RATING FOR:</small><br /><span id=\"InfoPopupUserRatingRestaurantLast\"></span></h6>" +
		"<p><strong>Ratings:</strong> Click to rate this vendor.</p>" +
		"<form name=\"user_rating_form\" action=\"RateRecentMealsVendorStep2.m\" method=\"post\" target=\"\">" +
			"<input type=\"hidden\" name=\"user_rating_restaurant\" value=\"\" />" + 
			"<input type=\"hidden\" name=\"user_rating_food\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_delivery\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_vendorLocationId\" value=\"-1\" />" + 
			"<input type=\"hidden\" name=\"whichStep\" value=\"\" />" +
			"<input type=\"hidden\" name=\"whichType\" value=\"\" />" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Food</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('food', this);\">1</td><td onclick=\"setUserRating('food', this);\">2</td><td onclick=\"setUserRating('food', this);\">3</td><td onclick=\"setUserRating('food', this);\">4</td><td onclick=\"setUserRating('food', this);\">5</td><td onclick=\"setUserRating('food', this);\">6</td><td onclick=\"setUserRating('food', this);\">7</td><td onclick=\"setUserRating('food', this);\">8</td><td onclick=\"setUserRating('food', this);\">9</td><td onclick=\"setUserRating('food', this);\">10</td></tr></table>" +
			"</div>" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Delivery</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('delivery', this);\">1</td><td onclick=\"setUserRating('delivery', this);\">2</td><td onclick=\"setUserRating('delivery', this);\">3</td><td onclick=\"setUserRating('delivery', this);\">4</td><td onclick=\"setUserRating('delivery', this);\">5</td><td onclick=\"setUserRating('delivery', this);\">6</td><td onclick=\"setUserRating('delivery', this);\">7</td><td onclick=\"setUserRating('delivery', this);\">8</td><td onclick=\"setUserRating('delivery', this);\">9</td><td onclick=\"setUserRating('delivery', this);\">10</td></tr></table>" +
			"</div>" +
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">Your new rating will replace your previous ratings for this vendor. All food ratings submitted by our users are averaged; delivery ratings submitted by all users at your company are averaged.</p>" + 
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">Add a review for this restaurant (optional):</p>" + 
			"<div style=\"margin: 5px;\">" +
			"<textarea name=\"ReviewText\" cols=\"28\" rows=\"3\" ></textarea>" +
			"</div>" +
			"<div style=\"width:150px; margin: 0 auto;\"><button name=\"rating_submit\" class=\"CustomButton\" onclick=\"submitUserRating();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Save and Close</button></div>" +
			"<div style=\"font-size: 60%; width:50px; margin: 0 auto;\"><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></div>" +
		"</form>",
		['InfoPopupUserRatingRestaurantLast'],
		true
	),
	
	USER_RATING_RECENT : new InfoPopupVariant(
		"<h6><small>PROVIDE A SEAMLESS RATING FOR:</small><br /><span id=\"InfoPopupUserRatingRestaurantRecent\"></span></h6>" +
		"<p><strong>Ratings:</strong> Click to rate this vendor.</p>" +
		"<form name=\"user_rating_form\" action=\"RateRecentMealsVendorStep2.m\" method=\"post\" target=\"\">" +
			"<input type=\"hidden\" name=\"user_rating_restaurant\" value=\"\" />" + 
			"<input type=\"hidden\" name=\"user_rating_food\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_delivery\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_vendorLocationId\" value=\"-1\" />" + 
			"<input type=\"hidden\" name=\"whichStep\" value=\"\" />" +
			"<input type=\"hidden\" name=\"whichType\" value=\"\" />" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Food</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('food', this);\">1</td><td onclick=\"setUserRating('food', this);\">2</td><td onclick=\"setUserRating('food', this);\">3</td><td onclick=\"setUserRating('food', this);\">4</td><td onclick=\"setUserRating('food', this);\">5</td><td onclick=\"setUserRating('food', this);\">6</td><td onclick=\"setUserRating('food', this);\">7</td><td onclick=\"setUserRating('food', this);\">8</td><td onclick=\"setUserRating('food', this);\">9</td><td onclick=\"setUserRating('food', this);\">10</td></tr></table>" +
			"</div>" +
			"<div style=\"margin: 5px;\">" +
				"<div class=\"Text\"><strong>Delivery</strong> 1=worst 10=best</div>" +
				"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"RatingTable\"><tr><td onclick=\"setUserRating('delivery', this);\">1</td><td onclick=\"setUserRating('delivery', this);\">2</td><td onclick=\"setUserRating('delivery', this);\">3</td><td onclick=\"setUserRating('delivery', this);\">4</td><td onclick=\"setUserRating('delivery', this);\">5</td><td onclick=\"setUserRating('delivery', this);\">6</td><td onclick=\"setUserRating('delivery', this);\">7</td><td onclick=\"setUserRating('delivery', this);\">8</td><td onclick=\"setUserRating('delivery', this);\">9</td><td onclick=\"setUserRating('delivery', this);\">10</td></tr></table>" +
			"</div>" +
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">Your new rating will replace your previous ratings for this vendor. All food ratings submitted by our users are averaged; delivery ratings submitted by all users at your company are averaged.</p>" + 
			"<p style=\"margin-top: 1em; padding-top: 3px; border-top: 1px solid #CCC;\">Add a review for this restaurant (optional):</p>" + 
			"<div style=\"margin: 5px;\">" +
			"<textarea name=\"ReviewText\" cols=\"28\" rows=\"3\" ></textarea>" +
			"</div>" +
			"<div style=\"width:150px; margin: 0 auto;\"><button name=\"rating_submit\" class=\"CustomButton\" onclick=\"submitUserRating();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Save and Close</button></div>" +
			"<div style=\"font-size: 60%; width:50px; margin: 0 auto;\"><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></div>" +
		"</form>",
		['InfoPopupUserRatingRestaurantRecent'],
	    true
	),
	

	SAVE_FAVORITE : new InfoPopupVariant(
		"<form name=\"save_favorite_form\" method=\"post\" >" +
			"<p>Please enter a name for this Favorite Order:</p>" +
				"<input type=\"hidden\" name=\"InfoPopupfavorite_saveType\" id=\"InfoPopupfavorite_saveType\" value=\"\"  />" + 
				"<input type=\"hidden\" name=\"InfoPopupfavorite_orderId\" id=\"InfoPopupfavorite_orderId\" value=\"\"  />" + 
				"<input type=\"text\" name=\"InfoPopupfavorite_name\" id=\"InfoPopupfavorite_name\" value=\"\" size=\"14\" /><br />" + 
				"<input type=\"button\" name=\"save_continue\" id=\"save_continue\" value=\"Save and Continue\" class=\"CustomButton\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" />" + 
				"<input type=\"button\" name=\"save_continue\" id=\"save_continue\" value=\"Save and Start Over\" class=\"CustomButton\" onclick=\"saveFavoriteAndStartOver();hideInfoPopup(this.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" />" + 
			"<p><a href=\"#\" onclick=\"hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
		"</form>",
		['InfoPopupfavorite_oderId','InfoPopupfavorite_name'],
	    true
	),
	
	//SAVE_FAVORITE0 is the popup for saving the favorite on the catering page
	SAVE_FAVORITE0 : new InfoPopupVariant(
		"<form name=\"save_catering_favorite_form\" id=\"save_catering_favorite_form\">" +
			"<h6>Save to Favorites</h6>" +
			"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\"><tr valign=\"top\">" +
				"<td width=\"45%\">" + 
					"<div>" +
						
						"<input type=\"hidden\" name=\"InfoPopupcateringSaveType\" id=\"InfoPopupcateringSaveType\" value=\"catering\"  />" + 
						"<input type=\"hidden\" name=\"InfoPopupfavoriteOrderId\" id=\"InfoPopupfavoriteOrderId\" value=\"\"  />" + 
						"<label for=\"favorite_name\" class=\"Text\">Please enter a name for this<br />Favorite Order:</label><br />" +
						"<input type=\"text\" onchange=\"enableFields();\" name=\"InfoPopupfavoriteName\" id=\"InfoPopupfavoriteName\" value=\"\" size=\"20\" />" +
					"</div>" +
					"<div class=\"Text\">" +
						
					"</div>" +
					"<div>" +
						"<label for=\"favorite_category\" class=\"Text\">Please select a category:</label><br />" +
						"<select name=\"InfoPopupCateringFavoriteList\" id=\"InfoPopupCateringFavoriteList\" width=\"15\" class=\"Text\"></select>" +
						
					"</div>" +
					"<div>" +
						"<span class=\"Text\">Please select favorite type:</span><br />" +
						"<input type=\"radio\" name=\"favorite_type\" onclick= firmFavorite(); checked id=\"favorite_type_firm\" value=\"F\" /> <label for=\"favorite_type_firm\" class=\"Text\">Firm Favorite</label><br />" +
						"<input type=\"radio\" name=\"favorite_type\" onclick= personalFavorite(); id=\"favorite_type_personal\" value=\"C\" /> <label for=\"favorite_type_personal\" class=\"Text\">Personal Favorite</label>" +
					"</div>" +
				"</td>" + 
				"<td width=\"55%\">" + 
					"<div>" +
						"<br><br><label for=\"favorite_description\" class=\"Text\">Optional&nbsp;Description:</label><br>" +
						"<textarea name=\"favorite_description\" id=\"favorite_description\" cols=\"20\" rows=\"4\"></textarea>" +
					"</div>" +
					"<div>" +
						"<input type=\"submit\" name=\"favorite_save\" id=\"favorite_save\" disabled=\"true\" value=\"Save &amp; Continue\" class=\"CustomButton\" onclick=\"saveCateringFavoriteAndContinue();return false;\" />" +
						"<span id=\"save_catering_favorite_link\" name=\"save_catering_favorite_link\" style=\"visibility:hidden\"><a href=\"#\" onclick=\"saveCateringFavoriteAndStartOver();return false;\">Save &amp; Start Over</a></p></span>" +
						"<p><a href=\"#\" onclick=\"hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
					"</div>" +
				"</td>" + 
			"</tr></table>" +
		"</form>",
		['InfoPopupfavoriteOrderId','InfoPopupfavoriteName','InfoPopupCateringFavoriteList','favorite_type','favorite_description','InfoPopupCateringFavoriteList'],
		true
	),

	SAVE_FAVORITE_TWO : new InfoPopupVariant(
	"<form name=\"save_favorite_form\" method=\"post\" >" +
		"<p>Please enter a name for this Favorite Order:</p>" +
			"<input type=\"hidden\" name=\"InfoPopupfavorite_saveType\" id=\"InfoPopupfavorite_saveType\" value=\"\"  />" + 
			"<input type=\"hidden\" name=\"InfoPopupfavorite_orderId\" id=\"InfoPopupfavorite_orderId\" value=\"\"  />" + 
			"<input type=\"text\" name=\"InfoPopupfavorite_name\" id=\"InfoPopupfavorite_name\" value=\"\" size=\"14\" /><br />" + 
			"<input type=\"button\" name=\"save_continue\" id=\"save_continue\" value=\"Save\" class=\"CustomButton1\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" />" + 
		"<p><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
		"</form>",
	['InfoPopupfavorite_oderId','InfoPopupfavorite_name'],
		true
	),


	SHOW_ADDRESS : new InfoPopupVariant(
	"<form name=\"show_address\" method=\"post\" >" +
		"<p>Please enter a Street Address and Zipcode:</p>" +
			"<input type=\"text\" name=\"InfoPopupStreetAddress\" id=\"InfoPopupStreetAddress\" value=\"\"  />" + 
			"<input type=\"text\" name=\"InfoPopupZipCode\" id=\"InfoPopupZipCode\" value=\"\"  />" + 
			"<input type=\"button\" name=\"submit\" id=\"submit\" value=\"submit\" class=\"CustomButton\" onclick=\"submitlogin();hideInfoPopup(this.parentNode.instanceName, this, true);return false;\" />" + 
		"<p><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
	"</form>",
	true
	),

	SHOW_PROMOTIONCODE : new InfoPopupVariant(
	"<form name=\"show_promotioncode\" method=\"post\" >" +
		"<p>Please enter a PromotionCode:</p>" +
			"<input type=\"text\" name=\"InfoPopupPromotionCode\" id=\"InfoPopupPromotionCode\" value=\"\"  />" + 
			"<p>Multiple Codes? Separate with commas: CODE1,CODE2,CODE3</p>" +
			"<input type=\"button\" name=\"submit\" id=\"submit\" value=\"submit\" class=\"CustomButton\" onclick=\"submitpromotioncode();hideInfoPopup(this.parentNode.instanceName, this, true);return false;\" />" + 
		"<p><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
	"</form>",
	true
	),
	
	CCV_DESCRIPTION : new InfoPopupVariant(
	    "<form name=\"ccv_description_form\" style=\"width:280px;\" >" +
		"<p style=\"font-size:9px;\" id=\"InfoPopupccvdescription\"></p>"+
		"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\">" + 
		    "<tr valign=\"top\">" +
			"<td width=\"45%\">" + 
			    "<p style=\"font-size:10px;\" id=\"InfoPopupvisaname\"><B>Visa/Mastercard</B></p>"+
			"</td>" + 
			"<td width=\"55%\">" + 
			    "<p style=\"font-size:10px;\" id=\"InfoPopupamxname\"><B><B>American Express</B></B></p>"+
			"</td>" + 
		    "</tr>" + 
		    "<tr valign=\"top\">" +
			"<td width=\"45%\">" + 
			    "<img id=\"InfoPopupimgvisa\" name=\"InfoPopupimgvisa\" width=\"140\" height=\"61\" border=\"0\" />" +
			"</td>" + 
			"<td width=\"55%\">" + 
			    "<img id=\"InfoPopupimgamx\" name=\"InfoPopupimgamx\" width=\"140\" height=\"61\" border=\"0\" />" +
			"</td>" + 
		    "</tr>" + 
		    "<tr valign=\"top\">" +
			"<td width=\"45%\">" + 
			    "<p style=\"font-size:8px;\" id=\"InfoPopupvisadescription\"></p>"+
			"</td>" + 
			"<td width=\"55%\">" + 
			    "<p style=\"font-size:8px;\" id=\"InfoPopupamxdescription\"></p>"+
			"</td>" + 
		    "</tr>" + 
		"</table>" +
	    "<p><br><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Close</a></p>" +
	    "</form>",
	    ['InfoPopupccvdescription','InfoPopupimgvisa','InfoPopupimgamx','InfoPopupvisadescription','InfoPopupamxdescription'],
	    true
	),

	SAVE_FAVORITE_ORDERHIST : new InfoPopupVariant(
		"<form name=\"save_favorite_form\" method=\"post\" >" +
			"<p>Please enter a name for this Favorite Order:</p>" +
				"<input type=\"hidden\" name=\"InfoPopupfavorite_orderId\" id=\"InfoPopupfavorite_orderId\" value=\"\"  />" + 
				"<input type=\"text\" name=\"InfoPopupfavorite_name\" id=\"InfoPopupfavorite_name\" value=\"\" size=\"14\" /><br />" + 
				"<input type=\"button\" name=\"save\" id=\"save\" value=\"Save\" class=\"CustomButton\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" />" + 
			"<p><a href=\"#\" onclick=\"hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
		"</form>",
		['InfoPopupfavorite_orderId','InfoPopupfavorite_name'],
		true
	),
	
	    SAVE_CATERING_FAVORITE_ORDERHIST : new InfoPopupVariant(
		"<form name=\"save_catering_favorite_form\" id=\"save_catering_favorite_form\">" +
			"<h6>Save to Favorites</h6>" +
			"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\"><tr valign=\"top\">" +
				"<td width=\"45%\">" + 
					"<div>" +
						
						"<input type=\"hidden\" name=\"InfoPopupcateringSaveType\" id=\"InfoPopupcateringSaveType\" value=\"catering\"  />" + 
						"<input type=\"hidden\" name=\"InfoPopupfavoriteOrderId\" id=\"InfoPopupfavoriteOrderId\" value=\"\"  />" + 
						"<label for=\"favorite_name\" class=\"Text\">Please enter a name for this<br />Favorite Order:</label><br />" +
						"<input type=\"text\" name=\"InfoPopupfavoriteName\" id=\"InfoPopupfavoriteName\" value=\"\" size=\"20\" />" +
					"</div>" +
					"<div class=\"Text\">" +
						
					"</div>" +
					"<div>" +
						"<label for=\"favorite_category\" class=\"Text\">Please select a category:</label><br />" +
						"<select name=\"InfoPopupCateringFavoriteList\" id=\"InfoPopupCateringFavoriteList\" width=\"15\" class=\"Text\"></select>" +
						
					"</div>" +
					"<div>" +
						"<span class=\"Text\">Please select favorite type:</span><br />" +
						"<input type=\"radio\" name=\"favorite_type\" onclick= firmFavorite(); checked id=\"favorite_type_firm\" value=\"F\" /> <label for=\"favorite_type_firm\" class=\"Text\">Firm Favorite</label><br />" +
						"<input type=\"radio\" name=\"favorite_type\" onclick= personalFavorite(); id=\"favorite_type_personal\" value=\"C\" /> <label for=\"favorite_type_personal\" class=\"Text\">Personal Favorite</label>" +
					"</div>" +
				"</td>" + 
				"<td width=\"55%\">" + 
					"<div>" +
						"<br><br><label for=\"favorite_description\" class=\"Text\">Optional&nbsp;Description:</label><br>" +
						"<textarea name=\"favorite_description\" id=\"favorite_description\" cols=\"20\" rows=\"4\"></textarea>" +
					"</div>" +
					"<div>" +
						"<input type=\"submit\" name=\"favorite_save\" id=\"favorite_save\" value=\"Save\" class=\"CustomButton\" onclick=\"saveCateringFavoriteAndContinue();return false;\" />" + 						
						"<p><a href=\"#\" onclick=\"hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
					"</div>" +
				"</td>" + 
			"</tr></table>" +
		"</form>",
		['InfoPopupfavoriteOrderId','InfoPopupfavoriteName','InfoPopupCateringFavoriteList','favorite_type','favorite_description','InfoPopupCateringFavoriteList'],
		true
	),

	ITEM_DETAIL : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupItemName\"></span></h6>" + 
		"<p id=\"InfoPopupItemDescription\"></p>",
		['InfoPopupItemName', 'InfoPopupItemDescription'],
		false
	),
	
	ITEM_DETAILTWO : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupItemNameTwo\"></span></h6>" + 
		"<p id=\"InfoPopupItemDescriptionTwo\"></p>",
		['InfoPopupItemNameTwo', 'InfoPopupItemDescriptionTwo'],
		false
	),
	
	PRODUCT_DETAIL : new InfoPopupVariant(
		"<h6><span id=\"InfoPopupProductName\"></span></h6>" + 
		"<p style=\"font-size: 11px;\" id=\"InfoPopupProductDescription\"></p>" +
		"<p style=\"font-size: 11px;\" id=\"InfoPopupProductOptions\"></p>",
		['InfoPopupProductName', 'InfoPopupProductDescription', 'InfoPopupProductOptions'],
		false
	),
	
	ORDER_DETAIL : new InfoPopupVariant(
		"<h5 class=\"TextSeparator\"><strong>ORDER DETAILS</strong></h5>" +
		"<div id=\"OrderDetails\">" +
		    "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"DataTable\">" +
				"<col width=\"15\" />" + 
				"<tbody id=\"InfoPopupOrderDetailItems\"></tbody>" +
		    "</table>" +
	    "</div>",
		['InfoPopupOrderDetailItems'],
	    false
	),
	
	PROMOTION_DESCRIPTION: new InfoPopupVariant (
	    "<h6><small>CURRENT PROMOTIONS:</small><br /></h6>" +
	    "<p><div style=\"font-size: 100%; width:150px; margin: 0 auto; z-index: 1000; position: static;\" id=\"InfoPopupPromotionDescriptionName\"></div></p>",
	    ['InfoPopupPromotionDescriptionName'],  
	    true
	
	)
};


// =============================================================================

var DOM_OBJECTS = [];

function getDomObj(object_name) {
	if (DOM_OBJECTS[object_name]) {
		debug('[WARNING] '+ object_name + ' already exists in DOM_OBJECTS. this is OK. we\'ll ingore it.');
		return true;
	}
	return (DOM_OBJECTS[object_name] = document.getElementById(object_name)) ? true : false;
} // END: getDomObj


var dhtml_objects = ["PageWrapper", "RestaurantTabs"];

function getDHTMLObjects() {
	for (var i in dhtml_objects) {
		if (!getDomObj(dhtml_objects[i]) ) debug('[WARNING] problem getting ' + dhtml_objects[i]);
	}
} // END: getDHTMLObjects


function findSpecificAncestor(node, test_regex, property_to_test) {
	var possible_match = node.parentNode;

	while (!test_regex.test(eval("possible_match." + property_to_test))) {
		possible_match = possible_match.parentNode;
	}

	return possible_match;
} // END: findSpecificAncestor


// =============================================================================

function InfoPopupVariant(html_code, dom_object_list, onclick) {
	this.html_code = html_code;
	this.dom_object_list = dom_object_list;
	this.onclick = onclick;	
} // END: InfoPopupVariant


function InfoPopup(dom_id, variant, attachment_node_id, left_position_function, top_position_function, decide_to_show_function, on_show_function, on_hide_function, hide_on_mouseout, followMouse, hideTimeout) {
    this.dom_id = dom_id;
    this.variant = variant;
    this.followMouse = followMouse;
    if ( !hideTimeout ) hideTimeout = SETTINGS['delay_hide'];
    this.hideTimeout = hideTimeout;
    this.calcLeftPosition = left_position_function;
    this.calcTopPosition = top_position_function;
    this.decide_to_show_function = decide_to_show_function;
    this.on_show_function = on_show_function;
    this.on_hide_function = on_hide_function;
    this.hide_on_mouseout = hide_on_mouseout;
    this.attachment_node_id = attachment_node_id;
    this.dom_node = null;
    this.dom_object_list = [];

    this.attach = function() {
        debug('STATUS: attaching ' + this.dom_id + ' to ' + this.attachment_node_id);

	if (!getDomObj(this.attachment_node_id)) {
	    debug('ERROR: couldn\'t get ' + attachment_node_id + ' from DOM_OBJECTS');
	    return false;
	}

	DOM_OBJECTS[attachment_node_id].appendChild(this.dom_node);

	if (!getDomObj(this.dom_node.id)) {
	    debug('ERROR: ' + info_box_wrapper + ' does not exist in DOM. attachment must have failed.');
	    return false;
	}

	// extract IDs from html_code
	// this.dom_object_list = this.extract_ids();
	this.extract_ids();
    };

    this.detach = function() {
	debug('STATUS: deleting ' + this.dom_id + ' from DOM_OBJECTS');
	delete DOM_OBJECTS[this.dom_id];

	debug('STATUS: removing ' + DOM_OBJECTS[this.attachment_node_id].lastChild.id + ' from the DOM');
	DOM_OBJECTS[this.attachment_node_id].removeChild(DOM_OBJECTS[this.attachment_node_id].lastChild); // assuming nothing else has changed the DOM
        
	// destroy previous content just to be sure
	for (var i=0; i < this.dom_object_list.length; i++) {
	// debug('STATUS: deleting ' + this.dom_object_list[i] + ' from DOM_OBJECTS');
		delete DOM_OBJECTS[this.dom_object_list[i]];
	}
    };

    this.create = function(instance_name) {
	debug('STATUS: attempting to create ' + instance_name + ' of ' + this.variant);

	this.html_code = INFO_POPUP_VARIANTS[this.variant].html_code;
	this.dom_object_list = INFO_POPUP_VARIANTS[this.variant].dom_object_list;
	// the wrapper
	var info_box_wrapper = document.createElement('div');
	info_box_wrapper.id = this.dom_id;
	info_box_wrapper.className = "InfoPopup";
	info_box_wrapper.instanceName = instance_name;

	info_box_wrapper.style.display = 'none';
	info_box_wrapper.style.visibility = 'hidden';
	info_box_wrapper.style.opacity = 0.99;
	//		info_box_wrapper.style.left = 0 + "px";

	info_box_wrapper.timeout_hide = null;
	info_box_wrapper.hide = hide;
	info_box_wrapper.show = show;

	// the box's shadow
	var info_box_shadow = document.createElement('div');
	info_box_shadow.className = "InfoPopupShadow";
	if (browser.isIEwin50()) {
	    info_box_shadow.style.background = "";
	}
	info_box_wrapper.appendChild(info_box_shadow);

	// the actual box and its content
	var info_box = document.createElement('div');
	info_box.className = "InfoPopupBox";
	info_box.innerHTML = this.html_code;

	if (this.hide_on_mouseout) {
	    info_box.onmouseover = function() { clearTimeout(DOM_OBJECTS[this.parentNode.id].timeout_hide); };
    	    info_box.onmouseout = function() { hideInfoPopup(this.parentNode.id , this, false); };

	    //		    info_box.onmouseout = this.onmouseout_function;
	    //		    info_box.onmouseover = this.onmouseover_function;
	}

	info_box_wrapper.appendChild(info_box);

	if( !followMouse ){
	    // the callout shadow
	    var info_box_callout_shadow = document.createElement('div');
	    info_box_callout_shadow.className = "InfoPopupCalloutShadow";
	    if (browser.isIEwin50()) {
		info_box_callout_shadow.style.background = "";
	    }
	    info_box_wrapper.appendChild(info_box_callout_shadow);

	    // the callout
	    var info_box_callout = document.createElement('div');
	    info_box_callout.className = "InfoPopupCallout";
	    info_box_wrapper.appendChild(info_box_callout);
	}
	// save it so we can attach it later
	this.dom_node = info_box_wrapper;

    }; // END: create() method

    this.extract_ids = function() {
// NOTE: abandoning use of regexes as IE 5.0 mac AND win use an older JScript engine in which RegExp.lastIndex does not appear to be implemented
/* 
	    var result = null;
	    var id_regex = /id="([^"]+)"/g;
	    var dom_object_list = [];

	    while ( (result = id_regex.exec(this.html_code)) != null ) {
		    dom_object_list[dom_object_list.length] = result[1];
	    }
*/

	    for (var i = 0; i < this.dom_object_list.length; i++) {
		    if (!getDomObj(this.dom_object_list[i])) {
			    debug('ERROR: ' + this.dom_object_list[i] + ' does not exist in DOM.');
		    }
	    }

	    return;
    }; // END: extract_ids

    this.placeByMouse = function( popUp ) { if( followMouse ) setMousePosition( popUp ); }
	
} // END: InfoPopup constructor


// =============================================================================
function showInfoPopup(info_popup_id, object_position_reference, data) {
	info_popup_id = (/^InfoPopup\w+$/.test(info_popup_id)) ? info_popup_id : "InfoPopup" + info_popup_id;

	// do a bit of creating, attaching, and checking
	if (INFO_POPUP_INSTANCES[info_popup_id].dom_node === null) INFO_POPUP_INSTANCES[info_popup_id].create(info_popup_id);
	INFO_POPUP_INSTANCES[info_popup_id].attach();

	var this_popup = DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_id];
	if (!this_popup) {
		debug('WARNING: trying to show an non-existent popup: ' + info_popup_id);
		return false;
	}

	// clear any previous timeouts for this popup
	if (this_popup.timeout_show) clearTimeout(this_popup.timeout_show);
	if (this_popup.timeout_hide) clearTimeout(this_popup.timeout_hide);

	// test to see if we should show the popup
	if (!INFO_POPUP_INSTANCES[info_popup_id].decide_to_show_function()) {
		return false;
	}

	// fill in the data
	switch (INFO_POPUP_INSTANCES[info_popup_id].variant) {
		case "RESTAURANT_DETAIL" :
		case "RATINGS_DETAIL" :
		case "ITEM_DETAIL" :
		case "ITEM_DETAILTWO" :
			// data passed as string: 'item1|item2|item3|item4 ... itemX'
			var data_array = data.split('|');
			for (var i=0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = data_array[i];
			}
			break;
		case "CCV_DESCRIPTION":
			DOM_OBJECTS["InfoPopupccvdescription"].innerText = data[0];
			DOM_OBJECTS["InfoPopupimgvisa"].src = data[1];
			DOM_OBJECTS["InfoPopupimgamx"].src = data[2];
			DOM_OBJECTS["InfoPopupvisadescription"].innerText = data[3];
			DOM_OBJECTS["InfoPopupamxdescription"].innerText = data[4];
			break;
		case "PRODUCT_DETAIL" :
			// data passed as string: 'item1|item2|item3|item4 ... itemX'
			var data_array = data.split('|');
			for (var i=0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = data_array[i];
			}
			break;		
		case "REORDER_CONFIRM" :
			// data passed as a mixed array: ['restaurant name',previous food rating,previous delivery rating]
			DOM_OBJECTS['InfoPopupConfirmMessage'].innerHTML = data[0];

			document.forms['reorder_form'].elements['OrderIdToReorder'].value = data[1];
			document.forms['reorder_form'].elements['VendorTypeForReorder'].value = data[2];

			break;
		case "USER_RATING" :
			// data passed as a mixed array: ['restaurant name',previous food rating,previous delivery rating]
			DOM_OBJECTS['InfoPopupUserRatingRestaurantName'].innerHTML = data[0];
			
			document.forms['user_rating_form'].elements['user_rating_restaurant'].value = data[0];
			document.forms['user_rating_form'].elements['user_rating_food'].value = data[1];
			document.forms['user_rating_form'].elements['user_rating_delivery'].value = data[2];
			document.forms['user_rating_form'].elements['user_rating_vendorLocationId'].value = data[3];
			document.forms['user_rating_form'].elements['whichStep'].value = data[4];
			document.forms['user_rating_form'].elements['whichType'].value = data[5];

			var all_tables = this_popup.getElementsByTagName('TABLE');
			var all_tds = null;
			
			for (var i=0; i < all_tables.length; i++) {
				if (all_tables[i].className == 'RatingTable') {
					all_tds = all_tables[i].getElementsByTagName('TD');
					for (var j=0; j < all_tds.length; j++) {
						all_tds[j].className = (all_tds[j].firstChild.nodeValue == data[i+1]) ? "Active" : ""; // we're assuming here that there's only 2 tables and the food one is first
			}
					all_tds = null;
			}
			}

			break;	
				
		case "USER_RATING_LAST" :
			// data passed as a mixed array: ['restaurant name',previous food rating,previous delivery rating]
			DOM_OBJECTS['InfoPopupUserRatingRestaurantLast'].innerHTML = data[0];

			document.forms['user_rating_form'].elements['user_rating_restaurant'].value = data[0];
			document.forms['user_rating_form'].elements['user_rating_food'].value = data[1];
			document.forms['user_rating_form'].elements['user_rating_delivery'].value = data[2];
			document.forms['user_rating_form'].elements['user_rating_vendorLocationId'].value = data[3];
			document.forms['user_rating_form'].elements['whichStep'].value = data[4];
			document.forms['user_rating_form'].elements['whichType'].value = data[5];

			var all_tables = this_popup.getElementsByTagName('TABLE');
			var all_tds = null;

			for (var i=0; i < all_tables.length; i++) {
				if (all_tables[i].className == 'RatingTable') {
					all_tds = all_tables[i].getElementsByTagName('TD');
					for (var j=0; j < all_tds.length; j++) {
						all_tds[j].className = (all_tds[j].firstChild.nodeValue == data[i+1]) ? "Active" : ""; // we're assuming here that there's only 2 tables and the food one is first
					}
					all_tds = null;
				}
			}

			break;
			
		case "USER_RATING_RECENT" :
			// data passed as a mixed array: ['restaurant name',previous food rating,previous delivery rating]
			DOM_OBJECTS['InfoPopupUserRatingRestaurantRecent'].innerHTML = data[0];
			
			document.forms['user_rating_form'].elements['user_rating_restaurant'].value = data[0];
			document.forms['user_rating_form'].elements['user_rating_food'].value = data[1];
			document.forms['user_rating_form'].elements['user_rating_delivery'].value = data[2];
			document.forms['user_rating_form'].elements['user_rating_vendorLocationId'].value = data[3];
			document.forms['user_rating_form'].elements['whichStep'].value = data[4];
			document.forms['user_rating_form'].elements['whichType'].value = data[5];

			var all_tables = this_popup.getElementsByTagName('TABLE');
			var all_tds = null;

			for (var i=0; i < all_tables.length; i++) {
			    if (all_tables[i].className == 'RatingTable') {
				all_tds = all_tables[i].getElementsByTagName('TD');
				for (var j=0; j < all_tds.length; j++) {
				    all_tds[j].className = (all_tds[j].firstChild.nodeValue == data[i+1]) ? "Active" : ""; // we're assuming here that there's only 2 tables and the food one is first
				}
				all_tds = null;
			    }
			}

			break;
			

		case "MENU_CATEGORY" :
			// destroy previous content just to be sure
			for (var i=0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = "";
			}

			// data passed as an array of strings: ['name1|anchor1','name2|anchor2','name3|anchor3' ... 'nameX|anchorX']
			var item_array = null;

			var num_of_cols = INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length;
			var items_per_col = Math.ceil(data.length / num_of_cols);

			var current_col = 0;
			for (var i=0; i < data.length; ) { // each column
				var temp_ul = document.createElement('UL');
				temp_ul.className = "NoBullet";

				while (true) { // each item
					var temp_li = document.createElement('LI');
					var temp_a = document.createElement('A');

					item_array = data[i].split('|');
					var category = item_array[1];
					
					temp_a.href = "#" + category;
					
					temp_a.onclick = function() {
						hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.instanceName, null, true);
					};
					temp_a.appendChild(document.createTextNode(item_array[0]));

					item_array = null;

					temp_li.appendChild(temp_a);
					temp_ul.appendChild(temp_li);

					i++;

					if ( ((i % items_per_col) == 0) || (i == data.length) ) {
						break;
					}
					
				} // end while

				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[current_col]].appendChild(temp_ul);

				current_col++;
				if (current_col == num_of_cols) {
					break;
				}
				
			} // end for()

			break;


		case "CATERING_FAVORITE" :
		case "CATERING_FAVORITE_ALL" :
			// destroy previous content just to be sure
			for (var i=0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
			    DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = "";
			}

			// fill in IDs with their content
			for (var i=0; i < 3; i++) {
			    DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = data[i];
			}

			// take care of the items in the favorite
			for (var i=0; i < data[6].length; i++) {
			    var temp_li = document.createElement('LI');
				temp_li.appendChild(document.createTextNode(data[6][i]));
			    DOM_OBJECTS['InfoPopupCateringFavoriteList'].appendChild(temp_li);
			}

			break;

		case "CATERING_FAVORITE_DETAIL" :
			// destroy previous content just to be sure
			for (var i=0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = "";
			}

			// fill in IDs with their content
			for (var i=0; i < 3; i++) {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = data[i];
			}

			// take care of the items in the favorite
			for (var i=0; i < data[3].length; i++) {
				var temp_li = document.createElement('LI');
				temp_li.appendChild(document.createTextNode(data[3][i][0]));

				var temp_ul = document.createElement('UL');
				temp_ul.className = "DotBullet";

				for (var j=1; j < data[3][i].length; j++) {
					var temp_ul_li = document.createElement('LI');
					temp_ul_li.appendChild(document.createTextNode(data[3][i][j]));
					temp_ul.appendChild(temp_ul_li);
				}

				temp_li.appendChild(temp_ul);
				DOM_OBJECTS['InfoPopupCateringFavoriteList'].appendChild(temp_li);
			}

			break;
		case "SURVEY_RESULTS" : 
			//DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].innerHTML = data[0];
			DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].innerText="";
			for (var i=0; i < data.length; i++) {
				var temp_tr = document.createElement('TR');
				var temp_td1 = document.createElement('TD');
				var temp_td2 = document.createElement('TD');
				temp_tr.id = "tr" + i;
				temp_td1.innerHTML = data[i][0];
				temp_td2.innerHTML = data[i][1];
				temp_td1.id = "td1" + i;
				temp_td1.width = "100";
				temp_td1.id = "td2" + i;
				temp_tr.appendChild(temp_td1);
				temp_tr.appendChild(temp_td2);
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].appendChild(temp_tr);

			}
			break;
		case "SAVE_FAVORITE0" : //SAVE_FAVORITE0 is the popup for saving the favorite on the catering page
		case "SAVE_CATERING_FAVORITE_ORDERHIST" :
			// take care of the items in the favorite
			document.forms['save_catering_favorite_form'].elements['InfoPopupfavoriteName'].value = data[0];
			document.forms['save_catering_favorite_form'].elements['InfoPopupfavoriteOrderId'].value = data[1];

			for (var i=1; i <= 5; i++) {
			    if(i==5)  {
				DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = "";
				}
			}
			// take care of the items in the favorite
			for (var i=0; i < data[5].length; i++) {
				var temp_li = document.createElement('Option');
				var arr = data[5][i];
				temp_li.innerHTML = data[5][i][1];
				temp_li.id = "option" + i;
				temp_li.value = data[5][i][0];
				DOM_OBJECTS['InfoPopupCateringFavoriteList'].appendChild(temp_li);
			}
			break;

		case "SAVE_FAVORITE" :
		case "SAVE_FAVORITE_ORDERHIST" :
			document.forms['save_favorite_form'].elements['InfoPopupfavorite_name'].value = data[0];
			document.forms['save_favorite_form'].elements['InfoPopupfavorite_orderId'].value = data[1];
			break;

		case "SAVE_FAVORITE_TWO" :
			document.forms['save_favorite_form'].elements['InfoPopupfavorite_name'].value = data[0];
			document.forms['save_favorite_form'].elements['InfoPopupfavorite_orderId'].value = data[1];
			break;	
		case "SHOW_PROMOTIONCODE" :
		case "SHOW_ADDRESS" :
			//document.forms['show_login'].elements['InfoPopuplogin_username'].value = data[0];
			//document.forms['show_login'].elements['InfoPopuplogin_password'].value = data[1];
			break;	
		case "ORDER_DETAIL" :
			// destroy previous content just to be sure

			while (DOM_OBJECTS['InfoPopupOrderDetailItems'].childNodes.length != 0) {
				DOM_OBJECTS['InfoPopupOrderDetailItems'].removeChild(DOM_OBJECTS['InfoPopupOrderDetailItems'].firstChild)
			}

			// take care of the items in the favorite
			for (var i=0; i < data.length; i++) {
				var temp_tr = document.createElement('TR');

				var temp_th = document.createElement('TH');
				temp_th.appendChild(document.createTextNode(data[i][0]));
				temp_tr.appendChild(temp_th);

				var temp_td = document.createElement('TD');
				temp_td.innerHTML = "<strong>" + data[i][1] + "</strong><br />" + data[i][2] + "<br /><a href=\"CateringMenuItem.m?lineId=" + data[i][3] + "\&productId=" + data[i][4] + "\&categoryId=" +  + data[i][5] + "\&tipAmount=" +  + data[i][6] + "\&price=" +  + data[i][7] + "\"" + ">Edit</a> &nbsp; <a href=\"DeleteCateringLineItem.m?deleteLineId=" + data[i][3] + "\"" + ">Delete</a>";
				temp_tr.appendChild(temp_td);

				DOM_OBJECTS['InfoPopupOrderDetailItems'].appendChild(temp_tr);
			}

			break;
			
		case "PROMOTION_DESCRIPTION" :
		    var data_array = data.split('|');
		    for (var i = 0; i < INFO_POPUP_INSTANCES[info_popup_id].dom_object_list.length; i++) {
			DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[i]].innerHTML = "";
		    }
		    
		    for (var i = 0; i < data_array.length;) { 
			if (data_array[i] == 'undefined') { break; }
			
			var temp_ul = document.createElement('UL');
			temp_ul.className = "NoBullet";
			while (true) { // each item
			    var temp_li = document.createElement('LI');
			    temp_li.appendChild(document.createTextNode(data_array[i]));
			    temp_ul.appendChild(temp_li);
			    i++;
			    if (i == data_array.length || data_array[i] == 'undefined') {  
				break;
			    }
			} // end while
			DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].appendChild(temp_ul);
		    } // end for()
			break;			

		default :
			debug('ERROR: missing data handler for popup variant ' + INFO_POPUP_INSTANCES[info_popup_id].variant + ' (instance of ' + info_popup_id + ')');
			break;
	}

	// set position to relative temporarily to work around z-index side-effect of "position: relative"
	DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].attachment_node_id].style.position = 'relative';

	// set top and left coordinates
	this_popup.style.display = "block"; // put it in the layout so we can grab the offsetHeight (not showing it yet)
	if ( INFO_POPUP_INSTANCES[info_popup_id].followMouse ) {
		INFO_POPUP_INSTANCES[info_popup_id].placeByMouse( this_popup );
	}
	else
	{
		this_popup.style.top = INFO_POPUP_INSTANCES[info_popup_id].calcTopPosition(object_position_reference, this_popup) + "px";  
		this_popup.style.left = INFO_POPUP_INSTANCES[info_popup_id].calcLeftPosition(object_position_reference) + "px";
	}
	
	// give us some info about the obj's position
 // debugPosition(object_position_reference);

	// set the shadow height and width
	this_popup.firstChild.style.width = this_popup.firstChild.nextSibling.offsetWidth + "px";
	this_popup.firstChild.style.height = this_popup.firstChild.nextSibling.offsetHeight + "px";

	// show the popup

		if (INFO_POPUP_VARIANTS[INFO_POPUP_INSTANCES[info_popup_id].variant].onclick) {
			this_popup.show();
		} else {
			SETTINGS['CurrentDomObject'] = DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_id];
			this_popup.timeout_show = setTimeout("SETTINGS['CurrentDomObject'].show()", SETTINGS['delay_show']);
		}

	// call the associated on_show function
	INFO_POPUP_INSTANCES[info_popup_id].on_show_function(object_position_reference);

} // END: showInfoPopup

function hideInfoPopup(info_popup_id, object_position_reference, hide_immediately) {
	info_popup_id = (/^InfoPopup\w+$/.test(info_popup_id)) ? info_popup_id : "InfoPopup" + info_popup_id; 
	var this_popup = DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_id];

	if (!this_popup) {
		debug(info_popup_id + ' does not exist');
		return false;
	}

	if (hide_immediately) {
		this_popup.hide();
		DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].attachment_node_id].style.position = 'static';

		// detach the node from the document (to avoice ID/name conflicts)
		INFO_POPUP_INSTANCES[info_popup_id].detach();
	} else {
		this_popup.timeout_hide = setTimeout("DOM_OBJECTS[INFO_POPUP_INSTANCES['" + info_popup_id + "'].dom_id].hide();DOM_OBJECTS[INFO_POPUP_INSTANCES['" + info_popup_id + "'].attachment_node_id].style.position = 'static';INFO_POPUP_INSTANCES['" + info_popup_id + "'].detach();", INFO_POPUP_INSTANCES[info_popup_id].hideTimeout);
	}


	// call the associated on_hide function
	INFO_POPUP_INSTANCES[info_popup_id].on_hide_function(object_position_reference);
	
} // END: hideInfoPopup


// =============================================================================


function show() {
	this.style.opacity = 0.99;
//	this.style.display = 'block';
	this.style.visibility = 'visible';
	this.style.zIndex = 20;
} // END: show


function hide() {
	this.style.display = 'none';
	this.style.visibility = 'hidden';
	this.style.zIndex = 0;
//	fade(this);
} // END: hide


function fade(obj) {
	if (obj.style.opacity >= 0.09) {
		obj.style.opacity -= 0.09;
		setTimeout(fade, 15, obj);

	} else {
		obj.style.display = 'none';
		obj.style.zIndex = 0;
	}
} // END: fade




function recalcDHTML() {

} // END: recalcDHTML


// =============================================================================


function toggleDisplayProperty(el) {
	el.style.display = (el.style.display == "block") ? "none" : "block";
}

function toggleDetailView(element_container_id, css_selector, toggle_link_el, toggle_link_text) {
	if (!document.getElementById) return;

	var items_to_toggle, link_text;
	var results = parseCSSSelector(css_selector);

	items_to_toggle = document.getElementById(element_container_id).getElementsByTagName(results[0]);

	for (var i=0; i < items_to_toggle.length; i++) {
		if (results[1] == null) {
			toggleDisplayProperty(items_to_toggle[i]);
		} else {
			if ( eval("items_to_toggle[i]" + results[1]) == results[2] ) toggleDisplayProperty(items_to_toggle[i])
		}
	}

	link_text = toggle_link_el.firstChild;

	// apparently, an arbitrary property can't be assigned to a text node in the IE/win DOM, so we assign it to the A node
	toggle_link_el.originalText = (typeof(toggle_link_el.originalText) == 'undefined') ? link_text.nodeValue : toggle_link_el.originalText;
	link_text.nodeValue = (link_text.nodeValue == toggle_link_text) ? toggle_link_el.originalText : toggle_link_text;
}


function activateTab(tab_content_id, tab_el) {
	if (!document.getElementById) return;

	var tab_to_activate = document.getElementById(tab_content_id);
	var all_elements_of_same_type = document.getElementsByTagName(tab_to_activate.nodeName);
	var all_tabs = [];

	for (var i = 0; i < all_elements_of_same_type.length; i++) {
		if (all_elements_of_same_type[i].className == tab_to_activate.className) all_tabs[all_tabs.length] = all_elements_of_same_type[i];
	}

	for (var i = 0; i < all_tabs.length; i++) {
		all_tabs[i].style.display = (tab_content_id == all_tabs[i].id) ? 'block' : 'none';
	}

	var tab_parent = findSpecificAncestor(tab_el, /.+Tabs$/, "id");
	var children = tab_parent.childNodes;

	for (var i=0; i < children.length; i++) {
		if (children[i].nodeType == 1) {
			children[i].className = (tab_el == children[i].firstChild.firstChild) ? 'Active' : '';
		}
	}

} // END: activateTab

function ShowReviews() {
    document.pageForm.showReviews.value = 'Y';
    doPost(document.pageForm, 'MealsMenuSelection.m');
}

function GoToMenu() {
    doPost(document.pageForm, 'MealsMenuSelection.m');
}

function SortReviews() {
    if (document.pageForm.sortReviewsBy != null) {
        document.pageForm.sortReviewsBy.value = document.getElementById('sortReviewsBy').value;
    }
    document.pageForm.showReviews.value = 'Y';
    doPost(document.pageForm, 'MealsMenuSelection.m');
}

function setTagType(vendorLocationReviewTagType) {
    document.getElementById('vendorLocationReviewTagType').value = vendorLocationReviewTagType;
}

// hide menus on click of document
/*
document.onclick = function(e) {
	thisEvent = (e) ? e : ((event) ? event : null);
	if (thisEvent){
		for (i in active_info_popups) {
			hideInfoPopup(i, null, true);
		}
	}
};
*/

function copyReviewText(reviewEl) {
    document.forms['user_rating_form'].elements['ReviewText'].value = reviewEl.value;
}

function setUserRating(which, rating_el) {
	for (var i=0; i < rating_el.parentNode.childNodes.length; i++) {
		rating_el.parentNode.childNodes[i].className = (rating_el.firstChild.nodeValue == rating_el.parentNode.childNodes[i].firstChild.nodeValue) ? "Active" : "";
	}
	document.forms['user_rating_form'].elements['user_rating_' + which].value = rating_el.firstChild.nodeValue;
	
} // END: setUserRating


function submitUserRating() {
	if(document.forms['user_rating_form'].elements['whichStep'].value == '1'){
	    parent.document.forms['pageForm'].user_rating_food.value = document.forms['user_rating_form'].elements['user_rating_food'].value;
	    parent.document.forms['pageForm'].user_rating_delivery.value = document.forms['user_rating_form'].elements['user_rating_delivery'].value;
	    parent.document.forms['pageForm'].user_rating_vendorLocationId.value = document.forms['user_rating_form'].elements['user_rating_vendorLocationId'].value;
	    parent.document.forms['pageForm'].user_review.value = document.forms['user_rating_form'].elements['ReviewText'].value;
	    parent.document.forms['pageForm'].action = 'RateRecentMealsVendor.m'
	    parent.document.forms['pageForm'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep'].value == '2') {
	    document.forms['user_rating_form'].action = 'RateRecentMealsVendorStep2.m'
	    document.forms['user_rating_form'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep'].value == '5') {
	    document.forms['user_rating_form'].action = 'RateRecentCateringVendorStep3.m'
	    document.forms['user_rating_form'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep'].value == '3'){
	    if(document.forms['user_rating_form'].elements['whichType'].value == 'Meals'){
	    document.forms['user_rating_form'].action = 'RateRecentMealsVendorStep3.m'
	    } else {
	    document.forms['user_rating_form'].action = 'RateRecentCateringVendorStep3.m'
	    }
	    document.forms['user_rating_form'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep'].value == 'orderHistory'){
	    document.forms['user_rating_form'].action = 'RateVendorOrderHistory.m'
	    document.forms['user_rating_form'].submit();
	} else {
	    alert('Not implemented yet. Rating not saved.');
	}
}

function saveCateringFavoriteAndContinue(){
    parent.document.forms['pageForm'].InfoPopupfavorite_saveType.value = 'Continue'
    parent.document.forms['pageForm'].InfoPopupfavorite_name.value = document.forms['save_catering_favorite_form'].elements['InfoPopupfavoriteName'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_orderId.value = document.forms['save_catering_favorite_form'].elements['InfoPopupfavoriteOrderId'].value
    parent.document.forms['pageForm'].action = parent.document.forms['pageForm'].saveFavoriteCommand.value
    parent.document.forms['pageForm'].favoriteDescription.value = document.forms['save_catering_favorite_form'].elements['favorite_description'].value
    parent.document.forms['pageForm'].cateringCategory.value = document.forms['save_catering_favorite_form'].elements['InfoPopupCateringFavoriteList'].value
    parent.document.forms['pageForm'].submit();
}

function personalFavorite(){
    parent.document.forms['pageForm'].favoritePaymentType.value = "C"
}

function firmFavorite(){
    parent.document.forms['pageForm'].favoritePaymentType.value = "F"
}

function enableFields(){
    saveCateringFavoriteForm = document.getElementById('save_catering_favorite_form');
    if(saveCateringFavoriteForm.InfoPopupfavoriteName.value == ""){ 
	saveCateringFavoriteForm.favorite_save.disabled = true;
	if(document.getElementById('save_catering_favorite_link')) document.getElementById('save_catering_favorite_link').style.visibility = "hidden";
    }else{
	saveCateringFavoriteForm.favorite_save.disabled = false;
	if(document.getElementById('save_catering_favorite_link')) document.getElementById('save_catering_favorite_link').style.visibility = "visible";
    }
}

function saveCateringFavoriteAndStartOver(){
    parent.document.forms['pageForm'].InfoPopupfavorite_saveType.value = 'StartOver'
    parent.document.forms['pageForm'].InfoPopupfavorite_name.value = document.getElementById('save_catering_favorite_form').InfoPopupfavoriteName.value
    parent.document.forms['pageForm'].InfoPopupfavorite_orderId.value = document.getElementById('save_catering_favorite_form').InfoPopupfavoriteOrderId.value
    parent.document.forms['pageForm'].action = parent.document.forms['pageForm'].saveFavoriteCommand.value
    parent.document.forms['pageForm'].favoriteDescription.value = document.getElementById('save_catering_favorite_form').favorite_description.value
    parent.document.forms['pageForm'].cateringCategory.value = document.getElementById('save_catering_favorite_form').InfoPopupCateringFavoriteList.value
    parent.document.forms['pageForm'].submit();
}

function saveFavoriteAndStartOver(){
    parent.document.forms['pageForm'].InfoPopupfavorite_orderId.value = document.forms['save_favorite_form'].elements['InfoPopupfavorite_orderId'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_name.value = document.forms['save_favorite_form'].elements['InfoPopupfavorite_name'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_saveType.value = 'StartOver'
    parent.document.forms['pageForm'].action = parent.document.forms['pageForm'].saveFavoriteCommand.value
    parent.document.forms['pageForm'].submit();
}

function saveFavorite(){
    parent.document.forms['pageForm'].InfoPopupfavorite_orderId.value = document.forms['pageForm'].elements['InfoPopupfavorite_orderId'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_name.value = document.forms['pageForm'].elements['InfoPopupfavorite_name'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_saveType.value = 'Continue'
    parent.document.forms['pageForm'].action = parent.document.forms['pageForm'].saveFavoriteCommand.value
    parent.document.forms['pageForm'].submit();
}

function saveFavoriteOrderHistory(){
    document.forms['save_favorite_form'].action = document.forms['save_favorite_form'].elements['InfoPopupfavorite_orderId'].value;
    document.forms['save_favorite_form'].action = 'SaveTemplateOrderHistory.m'
    parent.document.forms['save_favorite_form'].submit();
}

function GetTotalTopOffset(obj) {
    var top = 0;
    top = obj.offsetTop + RecurseTopOffset(obj.offsetParent);
    return top;
}

function RecurseTopOffset(obj, idToRecurseTo) {
    if ( !idToRecurseTo ) idToRecurseTo = "BodyWrapper"
    var top = 0;    
    if(obj != null)
    {
	if (typeof obj == "object"){
		if (obj.id != idToRecurseTo)
		    top = obj.offsetTop + RecurseTopOffset(obj.offsetParent);
 		else
			top = obj.offsetTop
	}
    }
    return top;
}

function RecurseLeftOffset(obj, idToRecurseTo, calcToBrowser) {
	if ( !idToRecurseTo ) idToRecurseTo = "BodyWrapper"
    var left = 0;
	if (typeof obj == "object"){
		if (obj.id != idToRecurseTo)
		    left = obj.offsetLeft + RecurseLeftOffset(obj.offsetParent);
		else
			left = obj.offsetLeft
	}
    return left;
}

function submitLogin(){
    document.forms['show_address'].action = 'MenuLogin.m';
    document.forms['show_address'].submit();
}

function submitpromotioncode(){
    document.forms['show_promotioncode'].action = 'MenuLogin.m';
    document.forms['show_promotioncode'].submit();
}

function ShowElement(show) {
    var elem = document.getElementById(show);                
    elem.style.display = '';
}        
function HideElement(hide) {
    var elem = document.getElementById(hide);
    elem.style.display = 'none';
}
function setPageFormValuesForCatering(orderId) {
    document.pageForm.InfoPopupfavorite_name.value = document.getElementById("InfoPopupfavoriteName_"+ orderId).value;
    document.pageForm.favoriteDescription.value = document.getElementById("favorite_description_"+ orderId).value;   
    document.pageForm.InfoPopupfavorite_orderId.value = orderId;
    if(document.getElementById("favorite_type_firm_" + orderId).checked) {
	document.pageForm.favoritePaymentType.value  = "F";
    } else {
	document.pageForm.favoritePaymentType.value  = "C";
    }	    
    var cateringCategory = document.getElementById("InfoPopupCateringFavoriteList");
    if(cateringCategory != null)
    {
	document.pageForm.cateringCategory.value  = cateringCategory.options[cateringCategory.selectedIndex].value;
    }	    
    saveFavorite();
}

function ValidateRating() {
    var reviewText = document.forms.popupForm.reviewText.value;
    var foodRating = document.forms.popupForm.foodRating.value;
    var vendorLocationId = document.forms.popupForm.VendorLocationId.value;
    var params = vendorLocationId + "|" + reviewText + "|" + foodRating;
    CreateCommand('81', params);
}

function SetStars(numberOfStars) {
    document.forms.popupForm.foodRating.value = numberOfStars;
    var elems = getElementsByClass('current-rating', null, null);
    var elem = elems[0];
    elem.style.width = numberOfStars * 20 + '%';
}

function setPopUp( popUp ){
	if ( this.popUp ) popUp = this.popUp;
}

function spin_div(div_id) {
    var container = $(div_id);
    var positioning = 'top: ' + container.offsetTop + 'px; width: ' + container.offsetWidth + 'px; height: ' + container.offsetHeight + 'px; ';
    container.innerHTML += '<div id="spindiv" class="spin_div" style="position: absolute; ' + positioning + '"></div>';
}

function setMousePosition( popUp ) {
	try{
		if (!this.popUp && !popUp) return;
		if ( popUp ) this.popUp = popUp;
		if ( this.popUp ) popUp = this.popUp;
		
		var offSetX = 50, offSetY = 0
		popUp.style.top = (fixBottomEdge( popUp, mY ) - RecurseTopOffset( popUp.parentNode, "PageWrapper" )) + offSetY + "px";
		popUp.style.left = (fixRightEdge( popUp, mX )  - RecurseLeftOffset( popUp.parentNode, "PageWrapper" )) + offSetX + "px";
		return;
	}
	catch(e){
		return;
	}
};

function fixBottomEdge( popUp, newY ) {
	try{
		// Pull the window sizes from the page object.
		// In NS we size down the window a little as it includes scrollbars.
		var wH = page.winH();
		if (!isIE||isOp) { wH-=16; }
		
		// Pull the compulsory information out of the tip array.
		var tipY = newY, tipH=popUp.offsetHeight, adjY = 3;
		// Check the tip is not within 5px of the screen boundaries.
		if (tipY + tipH + 15 > sY + wH) tipY = sY + wH - tipH + adjY;
		if (tipY < sY + 15) tipY = sY + adjY;
	
		return tipY;
	}
	catch(e){
		return;
	}
};

function fixRightEdge( popUp, newX ) {
	try{
		// Pull the window sizes from the page object.
		// In NS we size down the window a little as it includes scrollbars.
		var wW = page.winW();
		if (!isIE||isOp) { wW-=16; }
		// Pull the compulsory information out of the tip array.
		var tipX = newX, tipW=popUp.offsetWidth, adjX = 1;
		// Check the tip is not within 5px of the screen boundaries.
		if (tipX + tipW + 15 > sX + wW) tipX = sX + wW - tipW + adjX;
		if (tipX < sX + 15) tipX = sX + adjX;
		return tipX;
	}
	catch(e){
		return;
	}
};

function fixTopBottom( popUp, newY ) {
	try{
		// Pull the window sizes from the page object.
		// In NS we size down the window a little as it includes scrollbars.
		var wH = page.winH();
		if (!isIE||isOp) { wH-=16; }
		// Pull the compulsory information out of the tip array.
		var tipY = newY, tipH=popUp.offsetHeight, adjY = 3;
		// Check the tip is not within 5px of the screen boundaries.
		if (tipY + tipH + 15 > sY + wH) tipY = sY + wH - tipH + adjY;
		if (tipY < sY + 15) tipY = sY + adjY;
		return tipY;
	}
	catch(e){
		return;
	}
};


// *** PAGE EVENTS ***

// Capture the onmousemove event so tips can follow the mouse, and pass to all tip objects.
// Back up old events first!

var tipOR=window.onresize, nsWinW=window.innerWidth, nsWinH=window.innerHeight;
var xPos = yPos = sX = sY = mX = mY = 0;
var popUp = null;
document.tipMM = document.onmousemove;

if (isNS4) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = function(evt)
{
	try{
		if (!isIE || document.body)
		{
			// Reference the correct event object.
			evt=evt||window.event;
		}
		// Figure out the mouse co-ordinates and call the position function.
		// Also set sX and sY as the scroll position of the document.
		sX = page.scrollX();
		sY = page.scrollY();
		mX = isNS4 ? evt.pageX : sX + evt.clientX;
		mY = isNS4 ? evt.pageY : sY + evt.clientY;
		setMousePosition();
	}
	catch(e)
	{}
};

// Handle NS4 resizing error, don't worry about Opera 5/6 as they can't run this anyway.
window.onresize = function()
{
	 if (tipOR) tipOR();
	 if (isNS4 && (nsWinW!=innerWidth || nsWinH!=innerHeight)) location.reload();
};




