/*

dhtml_263e5cc8_b6f2_4b6d_aa1d_22532bb23f6d.js / v0.94  -- 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?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;

//uncomment the following line if you want to use the debug window.
//showDebug() 

var SETTINGS = {
	delay_show : 700,
	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 = {
	
	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
	),	
	
	InfoPopupNeighborhoodDetail : new InfoPopupAbsolutelyPositioned(
		"InfoPopupNeighborhoodDetail",
		"NEIGHBORHOOD_DETAIL",
		"NeighborhoodMapWrapper",
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),
	
	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 - obj.parentNode.parentNode.offsetWidth + 250);" +
			"}" + 
		""),
		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
	),
	
	InfoPopupShowLogin : new InfoPopup(
		"InfoPopupShowLogin",
		"SHOW_LOGIN",
		"ShowLogin",
		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
	),
	
	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
	),

	InfoPopupProductDetailRight : new InfoPopup(
		"InfoPopupProductDetailRight",
		"PRODUCT_DETAIL",
		"MenuListingRight",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 90);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth - 90);" +
			"}" +
		""),
		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]) - 270;" +
				"}" +
			"}" +
		""),
		// 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
	),
	
	InfoPopupProductDetailLeft : new InfoPopup(
		"InfoPopupProductDetailLeft",
		"PRODUCT_DETAIL",
		"MenuListingLeft",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 50);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth - 50);" +
			"}" +
		""),
		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]) - 270;" +
				"}" +
			"}" +
		""),
		// 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
	),
	
	InfoPopupFavoriteRestaurantDetail : new InfoPopup(
		"InfoPopupFavoriteRestaurantDetail",
		"RESTAURANT_DETAIL",
		"FavoriteRestaurants",
		new Function("obj", "" +
			"return (obj.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.offsetLeft + obj.parentNode.parentNode.parentNode.offsetLeft + obj.parentNode.parentNode.offsetWidth);" +
		""),
		new Function("obj", "" +
			"return (obj.offsetTop + 302);" +
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),

	InfoPopupRestaurantDetail : new InfoPopup(
		"InfoPopupRestaurantDetail",
		"RESTAURANT_DETAIL",
		"RestaurantListing",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"}" +
		""),
		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 ;" +				
			"}" +
		""),
		// 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", "" +
			"" +
		""),
		new Function("node", "" +
			"" +
		""),
		true,
		false,
		600
	),
	
	InfoPopupRestaurantDetailPickup : new InfoPopup(
		"InfoPopupRestaurantDetail",
		"RESTAURANT_DETAIL_PICKUP",
		"RestaurantListing",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"}" +
		""),
		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 ;" +				
			"}" +
		""),
		// 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", "" +
			"" +
		""),
		new Function("node", "" +
			"" +
		""),
		true,
		false,
		600
	),
	
	
	InfoPopupPromotionDescription : new InfoPopup(
		"InfoPopupPromotionDescription",
		"PROMOTION_DESCRIPTION",
		"RestaurantListing",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 460);" +
			"}" +
		""),
		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 - 10) ;" +				
			"}" +
		""),
		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,
		600
	),
	
	InfoPopupRestaurantDescription : new InfoPopup(
		"InfoPopupRestaurantDescription",
		"RESTAURANT_DESCRIPTION",
		"RestaurantListing",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 40);" +
			"} else {" + 
				"return (obj.parentNode.offsetWidth + 320);" +
			"}" +
		""),
		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 + 10) ;" +				
			"}" +
		""),
		// 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("return true;"),
		new Function("return true;"),
		true,
		false,
		600
	),
	
	
	InfoPopupRestaurantUserRatingVendorList : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"RestaurantListing",
		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 - 10);" + 
			"}" + 
		""),
		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.parentNode.offsetTop + obj.offsetParent.offsetTop - 20);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),
	
	

	/*InfoPopupRestaurantReview : new InfoPopup (
		"InfoPopupRestaurantUserRating",
		"RESTAURANT_REVIEW",
		"RestaurantMenu",
		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("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
	),

	InfoPopupDescrPolicies : new InfoPopup(
		"InfoPopupDescrPolicies",
		"DESCR_POLICIES",
		"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",
		"RestaurantInfoRight",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetLeft - obj.parentNode.parentNode.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 2);" +
			"} else {" +
				"return (obj.offsetLeft - DOM_OBJECTS[this.dom_id].offsetWidth - 0);"+
			"}" +
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.parentNode.offsetTop - 18);" +
			"} else {" +
				"return (obj.offsetTop - 20);" + 
			"}" +
		""),
		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(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"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 + 14);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupRestaurantUserRatingLast : new InfoPopup(
		"InfoPopupRestaurantUserRating",
		"USER_RATING",
		"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("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 - 10);" + 
			"}" + 
		""),
		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 - 10) : obj.offsetTop - 24);" +
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		true
	),

	InfoPopupCateringFavoriteDetail : new InfoPopup(
		"InfoPopupCateringFavoriteDetail",
		"CATERING_FAVORITE_DETAIL",
		"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
	),

	InfoPopupSaveCateringFavorite : new InfoPopup(
		"InfoPopupSaveFavorite",
		"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 - 22 - 120);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop - 22 - 120);" + 
			"}" + 
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupUpdateCateringFavorite : new InfoPopup(
		"InfoPopupUpdateFavorite",
		"UPDATE_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 - 22 - 120);" +
			"} else {" +
				"return (obj.offsetTop - obj.parentNode.parentNode.offsetTop - 22 - 120);" + 
			"}" + 
		""), 
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupItemDetail : new InfoPopup(
		"InfoPopupItemDetail",
		"ITEM_DETAIL",
		"MainColumn",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.parentNode.parentNode.offsetLeft + obj.offsetWidth + 10);" + 
			"} else if (browser.isNS6()) {" +
				"return (obj.parentNode.offsetLeft + obj.offsetWidth + 10);" + 
			"} else {" +
				"return (obj.offsetParent.offsetLeft + obj.offsetWidth + 50);" + 
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return ( (obj.parentNode.parentNode.offsetTop - 160) + (obj.offsetTop - obj.parentNode.parentNode.offsetTop) - 16 );" + 
			"} else if (browser.isNS6()) {" +
				"return (obj.parentNode.parentNode.offsetTop + (obj.offsetTop - obj.parentNode.parentNode.offsetTop) - 20);" + 
			"} else {" +
				"return (obj.offsetParent.offsetParent.offsetTop + obj.offsetTop - 20);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),

	InfoPopupItemDetailMenu : new InfoPopup(
		"InfoPopupItemDetailMenu",
		"ITEM_DETAIL",
		"RestaurantMenu",
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return (obj.parentNode.parentNode.offsetLeft + obj.offsetWidth + 10);" + 
			"} else if (browser.isNS6()) {" +
				"return (obj.parentNode.offsetLeft + obj.offsetWidth + 10);" + 
			"} else {" +
				"return (obj.offsetParent.offsetParent.offsetParent.offsetLeft + obj.offsetParent.offsetLeft + obj.offsetWidth + 50);" + 
			"}" + 
		""),
		new Function("obj", "" + 
			"if (browser.isNS60()) {" +
				"return ( (obj.parentNode.parentNode.parentNode.offsetTop - 160) + (obj.offsetTop - obj.parentNode.parentNode.offsetTop) - 16 );" + 
			"} else if (browser.isNS6()) {" +
				"return (obj.parentNode.parentNode.offsetTop + (obj.offsetTop - obj.parentNode.parentNode.offsetTop) - 20);" + 
			"} else {" +
				"return (obj.offsetParent.offsetParent.offsetParent.offsetParent.offsetTop + obj.parentNode.offsetTop + obj.parentNode.parentNode.parentNode.parentNode.offsetTop - 20);" + 
			"}" + 
		""),
		new Function("return true;"),
		new Function("return true;"),
		new Function("return true;"),
		false
	),
	
	InfoPopupProductDetail : new InfoPopup(
		"InfoPopupProductDetail",
		"PRODUCT_DETAIL", 
		"MenuListingRight",
		new Function("obj", "" +
			"if (browser.isNS6()) {" + 
				"return (obj.parentNode.offsetWidth - 90);" +
			"} else {" + 
			    "alert (obj.parentNode.name);" +
			    "return (obj.parentNode.offsetWidth - 500);" + //+ 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
	),
	
	InfoPopupSaveFavoriteOrderHistory : new InfoPopup(
		"InfoPopupSaveFavoriteOrderHistory",
		"SAVE_FAVORITE_TWO",
		"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
	),
	
	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
	),
	
	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
	)	
	

};


var INFO_POPUP_VARIANTS = {

	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
	),

	NEIGHBORHOOD_DETAIL : new InfoPopupVariant(
		"<h6><span id=\"InfoPopupNeighborhoodName\"></span></h6>" +
		"<p id=\"InfoPopupNeighborhoodDescription\"></p>" + 
		"<p>Total Restaurants: &nbsp;&nbsp; <span id=\"InfoPopupNeighborhoodTotalRestaurants\"></span></p>",
		['InfoPopupNeighborhoodName','InfoPopupNeighborhoodDescription','InfoPopupNeighborhoodTotalRestaurants'],
		false
	),

	
	
	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=\"InfoPopup_saveType\" id=\"InfoPopup_saveType\" value=\"\"  />" + 
			    "<input type=\"hidden\" name=\"InfoPopup_orderId\" id=\"InfoPopup_orderId\" value=\"\"  />" + 
			    "<input type=\"text\" name=\"InfoPopup_name\" id=\"InfoPopup_name\" value=\"\" size=\"14\" /><br />" + 
			    "<input type=\"button\" name=\"save_continue\" id=\"save_continue\" value=\"Save\" class=\"CustomButton\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" />" + 
		    "<p><a href=\"#\" onclick=\"ShowAllSelects();hideInfoPopup2(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></p>" +
	    "</form>",
	    ['InfoPopupfavorite_oderId','InfoPopupfavorite_name'],
	    true
	 ),
	
	SHOW_LOGIN : new InfoPopupVariant(
	    "<form name=\"show_login\" method=\"post\" >" +
		    "<p>Please enter an e-mail address and password:</p>" +
			    "<input type=\"text\" name=\"InfoPopupusername\" id=\"InfoPopupusername\" value=\"\"  />" + 
			    "<input type=\"text\" name=\"InfoPopuppassword\" id=\"InfoPopuppassword\" value=\"\"  />" + 
			    "<input type=\"button\" name=\"submit\" id=\"submit\" value=\"submit\" class=\"CustomButton\" onclick=\"submitloginlogin();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
	),
	
	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=\"RateRecentConsumerVendor.m\" method=\"post\" target=\"\">" +
		    "<input type=\"hidden\" name=\"user_rating_popup_restaurant\" value=\"\" />" + 
		    "<input type=\"hidden\" name=\"user_rating_popup_food\" value=\"5\" />" + 
		    "<input type=\"hidden\" name=\"user_rating_popup_delivery\" value=\"5\" />" + 
		    "<input type=\"hidden\" name=\"user_rating_popup_vendorLocationId\" value=\"\" />" + 
		    "<input type=\"hidden\" name=\"whichStep_popup\" value=\"\" />" +
		    "<input type=\"hidden\" name=\"whichType_popup\" value=\"\" />" +
		    "<input type=\"hidden\" name=\"popup_neighborhoodId\" 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>Speed</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.</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=\"popup_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
	),
	
	PRODUCT_DETAIL : new InfoPopupVariant(
		"<h6><span id=\"InfoPopupProductName\"></span></h6>" + 
		"<p id=\"InfoPopupProductDescription\"></p>" +
		"<p id=\"InfoPopupProductOptions\"></p>",
		['InfoPopupProductName', 'InfoPopupProductDescription', 'InfoPopupProductOptions'],
		false
	),
	
	RESTAURANT_DETAIL : new InfoPopupVariant(
		"<h6><small>DETAILS FOR:</small><br /><span id=\"InfoPopupRestaurantDetailsName\"></span></h6>" +
		"<p id=\"InfoPopupRestaurantDetailsDescription\"></p>" + 
		"<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" class=\"DataTable\">" +
			"<tr align=left><th></th><th></th></tr><tr><th>Food</th><th>Speed</th><th>Price</th></tr>" +
			"<tr><td id=\"InfoPopupRestaurantDetailsRatingFood\"></td><td id=\"InfoPopupRestaurantDetailsRatingDelivery\"></td><td id=\"InfoPopupRestaurantDetailsRatingPrice\"></td></tr>" +
		"</table>" + 
		"<p><strong>Estimated Delivery Time:</strong><br /><span id=\"InfoPopupRestaurantDetailsDelivTime\"></span></p>" + 
		"<p><strong>Minimum Order:</strong> <span id=\"InfoPopupRestaurantDetailsMinOrder\"></span></p>" + 
		"<p><strong>Hours:</strong> <span id=\"InfoPopupRestaurantDetailsHours\"></span></p>",
		['InfoPopupRestaurantDetailsName','InfoPopupRestaurantDetailsDescription','InfoPopupRestaurantDetailsRatingFood','InfoPopupRestaurantDetailsRatingDelivery','InfoPopupRestaurantDetailsDelivTime','InfoPopupRestaurantDetailsMinOrder','InfoPopupRestaurantDetailsHours',"InfoPopupRestaurantDetailsRatingPrice"],
		false
	),
	
	RESTAURANT_DETAIL_PICKUP : new InfoPopupVariant(
		"<h6><small>DETAILS FOR:</small><br /><span id=\"InfoPopupRestaurantDetailsName\"></span></h6>" +
		"<p id=\"InfoPopupRestaurantDetailsDescription\"></p>" + 
		"<table border=\"0\" cellspacing=\"5\" cellpadding=\"0\" class=\"DataTable\">" +
			"<tr align=left><th></th><th></th></tr><tr><th>Food</th><th>Speed</th><th>Price</th></tr>" +
			"<tr><td id=\"InfoPopupRestaurantDetailsRatingFood\"></td><td id=\"InfoPopupRestaurantDetailsRatingDelivery\"></td><td id=\"InfoPopupRestaurantDetailsRatingPrice\"></td></tr>" +
		"</table>" + 
		"<p><strong>Estimated Delivery Time:</strong><br /><span id=\"InfoPopupRestaurantDetailsDelivTime\"></span></p>" + 
		//"<p><strong>Minimum Order:</strong> <span id=\"InfoPopupRestaurantDetailsMinOrder\"></span></p>" + 
		"<p><strong>Hours:</strong> <span id=\"InfoPopupRestaurantDetailsHours\"></span></p>",
		['InfoPopupRestaurantDetailsName','InfoPopupRestaurantDetailsDescription','InfoPopupRestaurantDetailsRatingFood','InfoPopupRestaurantDetailsRatingDelivery','InfoPopupRestaurantDetailsDelivTime','InfoPopupRestaurantDetailsHours',"InfoPopupRestaurantDetailsRatingPrice"],
		false
	),
	
	
	RESTAURANT_DESCRIPTION : new InfoPopupVariant(
		"<h6><small>DETAILS FOR:</small><br /><span id=\"InfoPopupRestaurantDescriptionName\"></span></h6>" +
		"<p id=\"InfoPopupRestaurantDescriptionDescription\"></p>",
		['InfoPopupRestaurantDescriptionName','InfoPopupRestaurantDescriptionDescription'],
		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> " + 
		"<tr><td colspan=3 align=\"center\" ><center><small><small><a href=\"#\" onclick=\"hideInfoPopup('InfoPopupMenuCategory', this.parentNode.parentNode, true);\">close this window</a></small></small></center></td></tr></table>",
		['InfoPopupMenuCategoryColumn1','InfoPopupMenuCategoryColumn2','InfoPopupMenuCategoryColumn3'],
		true
	),

	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\">" +
			"Ordered: <span id=\"InfoPopupCateringDateOrdered\"></span><br />" +
			"Order Total: <span id=\"InfoPopupCateringOrderTotal\"></span><br />" +
		"</div>",
		['InfoPopupRestaurantRatingName', 'InfoPopupCateringFavoriteTitle', 'InfoPopupCateringDateOrdered', 'InfoPopupCateringOrderTotal', 'InfoPopupCateringFavoriteDesc', 'InfoPopupCateringFavoriteList'],
		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
	),
	
	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=\"hideInfoPopup2(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\" value=\"Cancel\">" +
		"</div></form>",
		['InfoPopupConfirmMessage', 'InfoPopupOrderIdToReorder', 'InfoPopupVendorTypeForReorder'],
		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=\"test\" method=\"post\" target=\"\" >" +
			"<div>" +
			"<input type=\"hidden\" name=\"user_rating_popup_restaurant\" value=\"\" />" + 
			"<input type=\"hidden\" name=\"user_rating_popup_food\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_popup_delivery\" value=\"5\" />" + 
			"<input type=\"hidden\" name=\"user_rating_popup_vendorLocationId\" value=\"\" />" + 
			"<input type=\"hidden\" name=\"whichStep_popup\" value=\"\" />" +
			"<input type=\"hidden\" name=\"whichType_popup\" value=\"\" />" +
			"<input type=\"hidden\" name=\"popup_neighborhoodId\" 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>Speed</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.</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=\"popup_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();hideInfoPopup2(this.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Cancel</a></div>" +
		"</form>",
		['InfoPopupUserRatingRestaurantName'],
		true
	),

	/*RESTAURANT_REVIEW: new InfoPopupVariant (
	    "<h6><small>SEAMLESS RESTAURANT REVIEWS FOR:</small><br /><span id=\"InfoPopupUserReviewRestaurantName\"></span></h6>" +
	    "<div style=\"font-size: 60%; width:50px; margin: 0 auto; z-index: 1000; position: static;\"><a href=\"#\" onclick=\"hideInfoPopup('InfoPopupRestaurantReview', this.parentNode);\">Close</a></div>" ,
	    ['InfoPopupUserReviewRestaurantName'],  
	    true
	
	),*/

	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
	
	),
	
	SAVE_FAVORITE : new InfoPopupVariant(
		"<form>" +
			"<h6>Save to Favorites</h6>" +
			"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\"><tr valign=\"top\">" +
				"<td width=\"45%\">" + 
					"<div>" +
						"<label for=\"favorite_name\" class=\"Text\">Please enter a name for this<br />Favorite Order:</label><br />" +
						"<input type=\"text\" name=\"favorite_name\" id=\"favorite_name\" value=\"\" size=\"20\" />" +
					"</div>" +
					"<div>" +
						"<label for=\"favorite_category\" class=\"Text\">Please select a category:</label><br />" +
						"<select name=\"favorite_category\" id=\"favorite_category\" size=\"1\">" +
							"<option value=\"1\">Breakfast</option>" +
							"<option value=\"2\">Lunch</option>" +
							"<option value=\"3\">Dinner</option>" +
						"</select>" +
					"</div>" +
					"<div>" +
						"<span class=\"Text\">Please select favorite type:</span><br />" +
						"<input type=\"radio\" name=\"favorite_type\" id=\"favorite_type_firm\" value=\"firm\" /> <label for=\"favorite_type_firm\" class=\"Text\">Firm Favorite</label><br />" +
						"<input type=\"radio\" name=\"favorite_type\" id=\"favorite_type_personal\" value=\"personal\" /> <label for=\"favorite_type_personal\" class=\"Text\">Personal Favorite</label>" +
					"</div>" +
				"</td>" + 
				"<td width=\"55%\">" + 
					"<div>" +
						"<label for=\"favorite_description\" class=\"Text\">Optional Description:</label>" +
						"<textarea name=\"favorite_description\" id=\"favorite_description\" rols=\"20\" rows=\"4\"></textarea>" +
					"</div>" +
					"<div>" +
						"<input type=\"submit\" name=\"favorite_save\" id=\"favorite_save\" value=\"Save &amp; Continue\" class=\"CustomButton\" />" +
						"<span class=\"Text\"><a href=\"#\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Save &amp; Start Over</a></span>" +
					"</div>" +
				"</td>" + 
			"</tr></table>" +
		"</form>",
		[''],
		true
	),

	UPDATE_FAVORITE : new InfoPopupVariant(
		"<form name=\"update_favorite_form\" id=\"update_favorite_form\">" +
			"<h6>Update this Favorite</h6>" +
			"<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"LayoutTable\"><tr valign=\"top\">" +
				"<td width=\"45%\">" + 
					"<div>" +
						"<label for=\"favorite_name\" class=\"Text\">Please update the name</label><br />" + 
						"<input type=\"text\" name=\"favorite_name\" id=\"favorite_name\" value=\"\" />" + 
					"</div>" +
					"<div>" +
						"<label for=\"favorite_category\" class=\"Text\">Please select a category:</label><br />" +
						"<select name=\"favorite_category\" id=\"favorite_category\" size=\"1\">" +
							"<option value=\"1\">Breakfast</option>" +
							"<option value=\"2\">Lunch</option>" +
							"<option value=\"3\">Dinner</option>" +
						"</select>" +
					"</div>" +
				"</td>" + 
				"<td width=\"55%\">" + 
					"<div>" +
						"<label for=\"favorite_description\" class=\"Text\">Please update description (optional):</label>" +
						"<textarea name=\"favorite_description\" id=\"favorite_description\" rols=\"20\" rows=\"4\"></textarea>" +
					"</div>" +
					"<div>" +
						"<input type=\"submit\" name=\"favorite_save\" id=\"favorite_save\" value=\"Save &amp; Continue\" class=\"CustomButton\" />" +
						"<span class=\"Text\"><a href=\"#\" onclick=\"saveFavorite();hideInfoPopup(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.instanceName, this, true);return false;\">Save &amp; Start Over</a></span>" +
					"</div>" +
				"</td>" + 
			"</tr></table>" +
		"</form>",
		['favorite_name', 'favorite_category', 'favorite_description'],
		true
	),

	ITEM_DETAIL : new InfoPopupVariant(
		"<h6><small>SEAMLESS DETAIL FOR:</small><br /><span id=\"InfoPopupItemName\"></span></h6>" + 
		"<p id=\"InfoPopupItemDescription\"></p>",
		['InfoPopupItemName', 'InfoPopupItemDescription'],
		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
	),
	
	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
	),

	DESCR_POLICIES : new InfoPopupVariant(
	    "<h5 class=\"TextSeparator\"><strong>Description</strong></h5>" +
	    "<div id=\"DescrPolicies\">" +
		    "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"DataTable\">" +
			    "<td id=\"InfoPopupDescrPoliciesItems\"></td>" +
		    "</table>" +
	    "</div>",
	    ['InfoPopupDescrPoliciesItems'],
	    false
	)
};


// =============================================================================

var DOM_OBJECTS = [];

function getDomObj(object_name) {
	if (DOM_OBJECTS[object_name]) {
		debug('[WARNING : getDomObj] '+ 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 : getDHTMLObjects] 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 InfoPopupAbsolutelyPositioned(dom_id, variant, attachment_node_id, decide_to_show_function, on_show_function, on_hide_function, hide_on_mouseout) {
	this.inheritFrom = InfoPopup;
	this.inheritFrom(dom_id, variant, attachment_node_id, 0, 0, decide_to_show_function, on_show_function, on_hide_function, hide_on_mouseout);
	this.absolutely_positioned = true;

	this.calcLeftPosition = function(obj) { return this.left_position };
	this.calcTopPosition = function(obj) { return this.top_position };

	this.left_position = 0;
	this.top_position = 0;
 
} // END: InfoPopupAbsolutelyPositioned


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 : InfoPopup:this.attach : attaching ' + this.dom_id + ' to ' + this.attachment_node_id);
		if (!getDomObj(this.attachment_node_id)) {
			debug('ERROR : InfoPopup:this.attach : couldn\'t get ' + attachment_node_id + ' from DOM_OBJECTS');
			return false;
		}

		//if (document.readyState=='complete') {
			debug(DOM_OBJECTS[attachment_node_id].childNodes.length);
			for(i=0;i<DOM_OBJECTS[attachment_node_id].childNodes.length;i++){
				debug(DOM_OBJECTS[attachment_node_id].childNodes[i].id)
			}
			if( DOM_OBJECTS[attachment_node_id].lastChild.id != "" && this.dom_node.id != "" && DOM_OBJECTS[attachment_node_id].lastChild.id != this.dom_node.id ){
				debug(DOM_OBJECTS[attachment_node_id].lastChild.parentNode.id)
				if(DOM_OBJECTS[DOM_OBJECTS[attachment_node_id].lastChild.parentNode.id]) clearTimeout(DOM_OBJECTS[DOM_OBJECTS[attachment_node_id].lastChild.parentNode.id].timeout_hide);
				if(DOM_OBJECTS[DOM_OBJECTS[attachment_node_id].lastChild.id]) clearTimeout(DOM_OBJECTS[DOM_OBJECTS[attachment_node_id].lastChild.id].timeout_hide);
				if(INFO_POPUP_INSTANCES[DOM_OBJECTS[attachment_node_id].lastChild.id] ) hideInfoPopup(DOM_OBJECTS[attachment_node_id].lastChild.id , this, true);
			}
			debug(DOM_OBJECTS[attachment_node_id].childNodes.length);
			DOM_OBJECTS[attachment_node_id].appendChild(this.dom_node);
				
			if (!getDomObj(this.dom_node.id)) {
				debug('ERROR : InfoPopup:this.attach : ' + 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 : InfoPopup:this.create : 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); debug(this.parentNode.id) };
		    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;
	}

	debug("[INFO] dom_object_list: " + INFO_POPUP_INSTANCES[info_popup_id].dom_object_list);

	// fill in the data
	switch (INFO_POPUP_INSTANCES[info_popup_id].variant) {
		
		case "SURVEY_RESULTS" : 
			//DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].innerHTML = data[0];
			if (!isIE) {
			    DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].innerHTML = ""; 
			}
			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 "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 "CCV_DESCRIPTION":
			
			if (!isIE) {
			    DOM_OBJECTS["InfoPopupccvdescription"].innerHTML = data[0];
			}
			DOM_OBJECTS["InfoPopupccvdescription"].innerText = data[0];
			DOM_OBJECTS["InfoPopupimgvisa"].src = data[1];
			DOM_OBJECTS["InfoPopupimgamx"].src = data[2];
			if (!isIE) {
			    DOM_OBJECTS["InfoPopupvisadescription"].innerHTML = data[3];
			}
			DOM_OBJECTS["InfoPopupvisadescription"].innerText = data[3];
			if (!isIE) {
			    DOM_OBJECTS["InfoPopupamxdescription"].innerHTML = data[4];
			}
			DOM_OBJECTS["InfoPopupamxdescription"].innerText = data[4];
			break;		
		
		case "NEIGHBORHOOD_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];
			}

			var coords = data_array[data_array.length -1].split(',');
			INFO_POPUP_INSTANCES[info_popup_id].left_position = coords[0];
			INFO_POPUP_INSTANCES[info_popup_id].top_position = coords[1];
			break;
		
		case "SAVE_FAVORITE_TWO" :
			document.forms['save_favorite_form'].elements['InfoPopup_name'].value = data[0];
			document.forms['save_favorite_form'].elements['InfoPopup_orderId'].value = data[1];
			break;	
		
		case "SHOW_LOGIN" :
			document.forms['show_login'].elements['InfoPopup_username'].value = data[0];
			document.forms['show_login'].elements['InfoPopup_password'].value = data[1];
			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_popup_restaurant'].value = data[0];
			document.forms['user_rating_form'].elements['user_rating_popup_food'].value = data[1];
			document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value = data[2];
			document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value = data[3];
			document.forms['user_rating_form'].elements['whichStep_popup'].value = data[4];
			document.forms['user_rating_form'].elements['whichType_popup'].value = data[5];
			document.forms['user_rating_form'].elements['popup_neighborhoodId'].value = data[6];
			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 "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 "RESTAURANT_DETAIL" :
		case "RESTAURANT_DETAIL_PICKUP" :
		case "RESTAURANT_DESCRIPTION" :
		case "RATINGS_DETAIL" :
		case "ITEM_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 "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_popup_restaurant'].value = data[0];
			document.forms['user_rating_form'].elements['user_rating_popup_food'].value = data[1];
			document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value = data[2];
			document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value = data[3];
			document.forms['user_rating_form'].elements['whichStep_popup'].value = data[4];
			document.forms['user_rating_form'].elements['whichType_popup'].value = data[5];
			document.forms['user_rating_form'].elements['popup_neighborhoodId'].value = data[6];
			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 "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;
		    
		/*case "RESTAURANT_REVIEW" :
		    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 = "";
		    }
		    DOM_OBJECTS['InfoPopupUserReviewRestaurantName'].innerHTML = data[0];
		    //The restaurant name is in the first index so we'll ignore it here.
		    for (var i = 1; i < data.length; ) { 
			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[i]));
			    temp_ul.appendChild(temp_li);
			    i++;
			    if ((i == data.length)) {  
				break;
			    }
			} // end while
			DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].dom_object_list[0]].appendChild(temp_ul);
		    } // end for()
		    break;
		*/
		case "DESCR_POLICIES" :
		    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 = "";
		    }

		    DOM_OBJECTS['InfoPopupDescrPoliciesItems'].innerHTML = data;
		    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" :
			// 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 < 5; 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[5].length; i++) {
			    var temp_li = document.createElement('LI');
			    temp_li.appendChild(document.createTextNode(data[5][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 "SAVE_FAVORITE" :
		case "UPDATE_FAVORITE" :
			var f = document.forms['update_favorite_form'];
			f.elements['favorite_name'].value = data[0];
			f.elements['favorite_description'].value = data[2];

			for (var i=0; i < f.elements['favorite_category'].options.length; i++ ) {
				if (f.elements['favorite_category'].options[i].value == data[1]) {
					f.elements['favorite_category'].options[i].selected = true;
				}
			}

			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=\"test\" onclick=\"return false;\">Edit</a> &nbsp; <a href=\"test\" onclick=\"return false;\">Delete</a>";
				temp_tr.appendChild(temp_td);

				DOM_OBJECTS['InfoPopupOrderDetailItems'].appendChild(temp_tr);
			}

			break;
			
			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].default_style_position = (DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].attachment_node_id].style.position == "") ? "static" : DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].attachment_node_id].style.position;
	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) {
		//debug("STATUS(hide_immediately): " + this_popup + " is being hidden and " + INFO_POPUP_INSTANCES[info_popup_id] + " is being detached");
		this_popup.hide();
		DOM_OBJECTS[INFO_POPUP_INSTANCES[info_popup_id].attachment_node_id].style.position = 'static';
		// detach the node from the document (to avoid ID/name conflicts)
		INFO_POPUP_INSTANCES[info_popup_id].detach();
	} else {
		debug('"' + info_popup_id + '" : "' + INFO_POPUP_INSTANCES[info_popup_id].dom_id + '"');
		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 hideInfoPopup2(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 {
		debug("STATUS(hideInfoPopup2): 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();")
		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 = 'relative';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



// hide menus on click of document

document.onclick = function(e) {
	this_event = (e) ? e : ((event) ? event : null);
	if (this_event) {
//	alert(this_event);
/*
		for (i in active_info_popups) {
			hideInfoPopup(i, null, true);
		}
*/
	}
};

function GetTotalTopOffset(obj) {
    var top = 0;
    top = obj.offsetTop + RecurseTopOffset(obj.offsetParent);
    return top;
}

function RecurseTopOffset(obj) {
    var top = 0;
	if ((obj.id != "BodyWrapper") && (typeof obj == "object")) {
	    top = obj.offsetTop + RecurseTopOffset(obj.offsetParent);
	}
    return top;
}

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_popup_' + which].value = rating_el.firstChild.nodeValue;
} // END: setUserRating



function saveFavorite(){
    parent.document.forms['pageForm'].InfoPopupfavorite_orderId.value = document.forms['pageForm'].elements['InfoPopup_orderId'].value
    parent.document.forms['pageForm'].InfoPopupfavorite_name.value = document.forms['pageForm'].elements['InfoPopup_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 submitLoginlogin(){
    document.forms['show_login'].action = 'MenuLogin.m';
    document.forms['show_login'].submit();
}

function submitUserRating() {
	if(document.forms['user_rating_form'].elements['whichStep_popup'].value == '1'){
	    parent.document.forms['pageForm'].user_rating_food.value = document.forms['user_rating_form'].elements['user_rating_popup_food'].value;
	    parent.document.forms['pageForm'].user_rating_delivery.value = document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value;
	    parent.document.forms['pageForm'].user_rating_vendorLocationId.value = document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value;
	    parent.document.forms['pageForm'].user_review.value = document.forms['user_rating_form'].elements['popup_ReviewText'].value;
	    parent.document.forms['pageForm'].action = 'RateRecentConsumer.m'
	    parent.document.forms['pageForm'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep_popup'].value == '2') {
	    parent.document.forms['pageForm'].searchCuisineId.value = document.forms['user_rating_form'].elements['whichType_popup'].value;
	    parent.document.forms['pageForm'].user_rating_food.value = document.forms['user_rating_form'].elements['user_rating_popup_food'].value;
	    parent.document.forms['pageForm'].user_rating_delivery.value = document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value;
	    parent.document.forms['pageForm'].user_rating_vendorLocationId.value = document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value;
	    parent.document.forms['pageForm'].user_review.value = document.forms['user_rating_form'].elements['popup_ReviewText'].value;
	    parent.document.forms['pageForm'].action = 'RateRecentConsumerStep2.m'
	    parent.document.forms['pageForm'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep_popup'].value == '3'){
	    parent.document.forms['pageForm'].user_rating_vendorLocationId.value = document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value;
	    parent.document.forms['pageForm'].user_rating_food.value = document.forms['user_rating_form'].elements['user_rating_popup_food'].value;
	    parent.document.forms['pageForm'].user_rating_delivery.value = document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value;
	    parent.document.forms['pageForm'].action = 'RateRecentConsumerStep3.m'
	    parent.document.forms['pageForm'].submit();
	} else if(document.forms['user_rating_form'].elements['whichStep_popup'].value == 'orderHistory'){
	    parent.document.forms['pageForm'].user_rating_food.value = document.forms['user_rating_form'].elements['user_rating_popup_food'].value;
	    parent.document.forms['pageForm'].user_rating_delivery.value = document.forms['user_rating_form'].elements['user_rating_popup_delivery'].value;
	    parent.document.forms['pageForm'].user_rating_vendorLocationId.value = document.forms['user_rating_form'].elements['user_rating_popup_vendorLocationId'].value;
	    parent.document.forms['pageForm'].reviewText.value = document.forms['user_rating_form'].elements['popup_ReviewText'].value;
	    document.forms['pageForm'].action = 'RateVendorOrderHistory.m'
	    document.forms['pageForm'].submit();
	} else {
	    alert('Not implemented yet. Rating not saved.');
	}
}

	
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 ((typeof obj == "object") && (obj != null)) {
		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") && (obj != null)){
		if (obj.id != idToRecurseTo)
		    left = obj.offsetLeft + RecurseLeftOffset(obj.offsetParent);
		else
			left = obj.offsetLeft
	}
    return left;
}
function ShowElement(show) {
    var elem = document.getElementById(show);                    
    elem.style.display = '';
}        
function HideElement(hide) {
    var elem = document.getElementById(hide);                          
    elem.style.display = 'none';
}

function setPopUp( popUp ){
	if ( this.popUp ) popUp = this.popUp;
}

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 = (fixTopBottom( popUp, mY ) - RecurseTopOffset( popUp.parentNode, "PageWrapper" )) + offSetY + "px";
		popUp.style.left = (fixRightLeft( popUp, mX )  - RecurseLeftOffset( popUp.parentNode, "PageWrapper" )) + offSetX + "px";
		return;
	}
	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;
	}
};

function fixRightLeft( 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 = 50;
		// Check the tip is not within 5px of the screen boundaries.
		if (tipX + tipW + 50 > sX + wW) tipX = sX + wW - (tipW + adjX);
		if (tipX < sX + 50){ tipX = sX + adjX;}
		return tipX;
	}
	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();
};

var dropDownTimeout;
var lastVisible='';
function DdMenuShow( dDMmenu ){
    if( document.getElementById('addressId') ){
	document.getElementById('addressId').style.visibility='hidden';
    }
    if( lastVisible != '' && lastVisible != dDMmenu ){
	 document.getElementById(lastVisible).style.left = '-999em';
    }
    if( typeof(dropDownTimeout) != 'undefined' && lastVisible == dDMmenu ){
	clearTimeout(dropDownTimeout);
    }
    dmenu = document.getElementById(dDMmenu);
    dmenu.style.left = 'auto';
    lastVisible = dDMmenu;
}

function DdMenuHide( dDMmenu ){
    dmenu = document.getElementById(dDMmenu);
    dmenu.style.left = '-999em';
    if(lastVisible == dDMmenu && document.getElementById('addressId') ){ 
	document.getElementById('addressId').style.visibility='visible';
    }
}

// Show the debug window
function showDebug() {
  window.top.debugWindow =
      window.open("",
                  "Debug",
                  "left=0,top=0,width=300,height=700,scrollbars=yes,"
                  +"status=yes,resizable=yes");
  window.top.debugWindow.opener = self;
  // open the document for writing
  window.top.debugWindow.document.open();
  window.top.debugWindow.document.write(
      "<HTML><HEAD><TITLE>Debug Window</TITLE></HEAD><BODY><PRE>\n");
}

// If the debug window exists, then write to it
function debug(text) {
  if (window.top.debugWindow && ! window.top.debugWindow.closed) {
    window.top.debugWindow.document.write(text+"\n");
  }
}

