﻿
		var firsttime = true;	
		var count = 1;
		var _globalFadeEasing = "easeInOutQuint";
		var _globalSlideEasing = "easeInOutExpo";
		jQuery.easing.def = _globalFadeEasing; 
		var originalOpenMenuID = openMenuID;
	
		function menuTransition (TabId) {
			// If the browser is IE 6, don't do the menu transition (let the hyperlink click though).
			if (navigator.appVersion.indexOf("MSIE 6.0") > 0) {
				return true;
			}
		
			//alert(count);
			var _globalFadeTime = 450;
			var _globalSlideTime = 775;
			
			if (firsttime){
				firsttime = false;
				//close the open menu
				var openTab = $("#MenuOpen");
			}
			else {
				//close the open menu
				var prevcount = count-1;
				if (prevcount == 0){
					prevcount = 2;
				};
				var openTab = $('#MenuOpen'+prevcount);
			}
			openTab.animate({opacity:0},_globalFadeTime,_globalFadeEasing,function(){
		
				var standardHTMLOpen = "<div id='menuPageSideBar"+count+"'>";
				standardHTMLOpen += "<div id='menuPageSideBarWithName"+count+"' style='background-color:#000000;'><img src='pages/images/"+menuTabs[TabId]+"/_verticalName.gif' /></div></div>";
				standardHTMLOpen += "<div id='menuPageAllContent'>";
				standardHTMLOpen += "<div id='menuPageTopBar'><img src='pages/images/"+menuTabs[TabId]+"/_title.jpg' /></div>";
				
				var heroHTML = "<div id='menuPageTopImagesAndHorizontalStroke'><img src='pages/images/"+menuTabs[TabId]+"/HeroShotOne.jpg' width='231' height='146' /><img src='pages/images/_whiteVerticalStroke.jpg' width='1' height='146' /><img src='pages/images/"+menuTabs[TabId]+"/HeroShotTwo.jpg' width='231' height='146' /><br /><img src='pages/images/_whiteHorizontalStroke.jpg' width='463' height='1' /><br />";
				
				
				var ieStyleString = "color:#ffffff;";
				var ieStyleString2 = "background-color:#000000;color:#ffffff;";
					
				
				/*if (navigator.userAgent.indexOf("MSIE 6") != -1){
					heroHTML += "<div id='HeroShotTitleOneDiv"+count+"' onmouseover='menuExpand(\"HeroImageOne\",\""+count+"\");' style='"+ieStyleString+"'>";
					heroHTML += "<div id='HeroShotTitleOneBackground"+count+"' style='"+ieStyleString2+"'></div>";
					heroHTML += "<div id='HeroShotTitleOneArrow"+count+"' class='HeroShotArrow' style='"+ieStyleString+"'></div>";
					heroHTML += "<div id='HeroShotTitleOneText"+count+"' class='HeroShotTitleText' style='"+ieStyleString+"'>"+heroOneTitles[TabId]+"</div></div>";
					heroHTML += "<div id='HeroShotDescriptionOneDiv"+count+"' onmouseout='menuCollapse(\"HeroImageOne\",\""+count+"\");' style='"+ieStyleString+"'>";
					heroHTML += "<div id='HeroShotDescriptionOneBackground"+count+"' style='"+ieStyleString2+"'></div>";
					heroHTML += "<div id='HeroShotDescriptionOneArrow"+count+"' class='HeroShotArrow' style='"+ieStyleString+"'></div>";
					heroHTML += "<div id='HeroShotDescriptionOneText"+count+"' style='"+ieStyleString+"'><span class='HeroShotTitleTextAlternate'>"+heroOneTitles[TabId]+"</span><br /><span  class='HeroShotDescriptionText'>"+heroOneDescriptions[TabId]+"</span></div></div>";
				}
				else {*/
					heroHTML += "<div id='HeroShotTitleOneDiv"+count+"' onmouseover='menuExpand(\"HeroImageOne\",\""+count+"\");'>";
					heroHTML += "<div id='HeroShotTitleOneBackground"+count+"'><img src='images/heroImageTitleBackground.png'></div>";
					heroHTML += "<div id='HeroShotTitleOneArrow"+count+"' class='HeroShotArrow'><img src='../_global/images/upArrow.png'></div>";
					heroHTML += "<div id='HeroShotTitleOneText"+count+"' class='HeroShotTitleText'>"+heroOneTitles[TabId]+"</div></div>";
					heroHTML += "<div id='HeroShotDescriptionOneDiv"+count+"' onmouseout='menuCollapse(\"HeroImageOne\",\""+count+"\");'>";
					heroHTML += "<div id='HeroShotDescriptionOneBackground"+count+"'><img src='images/heroImageDescriptionBackground.png'></div>";
					heroHTML += "<div id='HeroShotDescriptionOneArrow"+count+"' class='HeroShotArrow'><img src='../_global/images/downArrow.png'></div>";
					heroHTML += "<div id='HeroShotDescriptionOneText"+count+"'><span class='HeroShotTitleTextAlternate'>"+heroOneTitles[TabId]+"</span><br /><span  class='HeroShotDescriptionText'>"+heroOneDescriptions[TabId]+"</span></div></div>";
				//}
				
				
				/*if (navigator.userAgent.indexOf("MSIE 6") != -1){
					heroHTML += "<div id='HeroShotTitleTwoDiv"+count+"' onmouseover='menuExpand(\"HeroImageTwo\",\""+count+"\");' style='"+ieStyleString+"'>";
					heroHTML += "<div id='HeroShotTitleTwoBackground"+count+"' style='"+ieStyleString2+"'></div>";
					heroHTML += "<div id='HeroShotTitleTwoArrow"+count+"' class='HeroShotArrow' style='"+ieStyleString+"'></div>";
					heroHTML += "<div id='HeroShotTitleTwoText"+count+"' class='HeroShotTitleText' style='"+ieStyleString+"'>"+heroTwoTitles[TabId]+"</div></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoDiv"+count+"' onmouseout='menuCollapse(\"HeroImageTwo\",\""+count+"\");' style='"+ieStyleString+"'>";
					heroHTML += "<div id='HeroShotDescriptionTwoBackground"+count+"' style='"+ieStyleString2+"'></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoArrow"+count+"' class='HeroShotArrow' style='"+ieStyleString+"'></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoText"+count+"' style='"+ieStyleString+"'><span class='HeroShotTitleTextAlternate'>"+heroTwoTitles[TabId]+"</span><br /><span  class='HeroShotDescriptionText'>"+heroTwoDescriptions[TabId]+"</span></div></div>";
				}
				else {*/
					heroHTML += "<div id='HeroShotTitleTwoDiv"+count+"' onmouseover='menuExpand(\"HeroImageTwo\",\""+count+"\");'>";
					heroHTML += "<div id='HeroShotTitleTwoBackground"+count+"'><img src='images/heroImageTitleBackground.png'></div>";
					heroHTML += "<div id='HeroShotTitleTwoArrow"+count+"' class='HeroShotArrow'><img src='../_global/images/upArrow.png'></div>";
					heroHTML += "<div id='HeroShotTitleTwoText"+count+"' class='HeroShotTitleText'>"+heroTwoTitles[TabId]+"</div></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoDiv"+count+"' onmouseout='menuCollapse(\"HeroImageTwo\",\""+count+"\");'>";
					heroHTML += "<div id='HeroShotDescriptionTwoBackground"+count+"'><img src='images/heroImageDescriptionBackground.png'></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoArrow"+count+"' class='HeroShotArrow'><img src='../_global/images/downArrow.png'></div>";
					heroHTML += "<div id='HeroShotDescriptionTwoText"+count+"'><span class='HeroShotTitleTextAlternate'>"+heroTwoTitles[TabId]+"</span><br /><span  class='HeroShotDescriptionText'>"+heroTwoDescriptions[TabId]+"</span></div></div>";
				//}
				heroHTML += "</div>";
		
				var standardHTMLClose = "</div>";
			
				//alert("open: "+menuTabs[openMenuID]+" | clicked: "+menuTabs[TabId]);
				var openPageTab = $("#MenuPageOpenDiv");
				
				var tablIdLeft = $('#MenuPages'+menuTabs[TabId]);
				var newTabLeft = $(tablIdLeft).css("left");
				//alert(newTabLeft);
				
				//create a new tab via cloning
				var newTab = $(openPageTab).clone().insertAfter(openPageTab);
				var newTabName = 'MenuPageOpenDiv'+count;
				newTab.attr('id',newTabName);
				newTab.css("position","relative");
				var originalOffset = originalOpenMenuID*29-1;
				var newOffset = 29*TabId-1;
				var newLeft = (newOffset-originalOffset-2)+"px";
				//alert("newLeft: "+newLeft);
				newTab.css("left",newLeft);
				newTab.css("top","0px");
				
				var kids = newTab.children();
				var sibs = newTab.parent().children();
				//alert(sibs.length);
				var kid = $(kids[0]);
				var newMenuName = 'MenuOpen'+count;
				kid.attr('id',newMenuName);
				
				//add the standard HTML to the new kid div
				kid.empty();
				
				var uniqueDivHTML = "<div id='"+menuTabs[TabId]+"_content_holder'></div>";			
				//if ((menuScrollBarTopPos[TabId] != menuScrollBarStandardTopPos) && (menuTabs[TabId] != "RightPortionRightPrice")){
				if ((menuScrollBarTopPos[TabId] != menuScrollBarStandardTopPos) && (menuTabs[TabId].indexOf("RightPortionRightPrice")==-1)) {
					//only if we're opening Best of Friday's, RPRP, Sliders or Caipirinhas
					kid.append(standardHTMLOpen + uniqueDivHTML + standardHTMLClose);
				}
				else {
					if (menuTabs[TabId].indexOf("RightPortionRightPrice")>-1) {
						var RPRPheader = "<img src=\"pages/images/RightPortionRightPrice/header.jpg\" width=\"463\" height=\"143\" /><br />";
						heroHTML = heroHTML.replace("HeroShotTitleOneDiv", "HeroShotRPRPTitleOneDiv");
						heroHTML = heroHTML.replace("HeroShotDescriptionOneDiv", "HeroShotRPRPDescriptionOneDiv");
						heroHTML = heroHTML.replace("HeroShotTitleTwoDiv", "HeroShotRPRPTitleTwoDiv");
						heroHTML = heroHTML.replace("HeroShotDescriptionTwoDiv", "HeroShotRPRPDescriptionTwoDiv");
						heroHTML = heroHTML.replace("menuExpand(\"HeroImageOne\"", "menuExpand(\"HeroImageRPRPOne\"");
						heroHTML = heroHTML.replace("menuExpand(\"HeroImageTwo\"", "menuExpand(\"HeroImageRPRPTwo\"");
						heroHTML = heroHTML.replace("menuCollapse(\"HeroImageOne\"", "menuCollapse(\"HeroImageRPRPOne\"");
						heroHTML = heroHTML.replace("menuCollapse(\"HeroImageTwo\"", "menuCollapse(\"HeroImageRPRPTwo\"");
						kid.append(standardHTMLOpen + RPRPheader + heroHTML + uniqueDivHTML + standardHTMLClose);
					}
					else
						kid.append(standardHTMLOpen + heroHTML + uniqueDivHTML + standardHTMLClose);
				}
				var uniqueDiv = $('#'+menuTabs[TabId]+'_content_holder');
				var bgURL = "url('"+menuBackgrounds[TabId]+"')";
				uniqueDiv.css("background-image",bgURL);
				
				/*
				var HeroShotTitleOneBackground = $('#HeroShotTitleOneBackground'+count);
				var HeroShotDescriptionOneBackground = $('#HeroShotDescriptionOneBackground'+count);
				var HeroShotTitleTwoBackground = $('#HeroShotTitleTwoBackground'+count);
				var HeroShotDescriptionTwoBackground = $('#HeroShotDescriptionTwoBackground'+count);
				HeroShotTitleOneBackground.fadeTo(100,.25,function(){alert('1');});
				HeroShotDescriptionOneBackground.fadeTo(100,.25,function(){alert('2');});
				HeroShotTitleTwoBackground.fadeTo(100,0.25,function(){alert('3');});
				HeroShotDescriptionTwoBackground.fadeTo(100,.25,function(){alert('4');});
				*/
									
				kid.css({opacity:0});
				kid.show("blind", { direction: "horizontal" }, _globalSlideEasing);
				openTab.hide("blind", { direction: "horizontal" }, _globalSlideEasing);
				
				//move all the tabs
				if (TabId > openMenuID) {
					for (i=openMenuID+1;i<=TabId;i++) {
						//document.getElementById(menuTabs[i]).left = document.getElementById(menuTabs[i]).left - 462;
						//slide everything between the open menu and the clicked menu
						var tabBtwn = $('#MenuPages'+menuTabs[i]);
						tabBtwn.animate({left: "-=462px"},_globalSlideTime,_globalSlideEasing);
						var nameBtwn = $('#MenuPagesNames'+menuTabs[i]);
						nameBtwn.animate({left: "-=462px"},_globalSlideTime,_globalSlideEasing);
						var clickBtwn = $('#MenuPagesClicks'+menuTabs[i]);
						if (i==TabId){
							clickBtwn.animate({left: "-=462px"},_globalSlideTime,_globalSlideEasing,function(){
								//load the new menu
								uniqueDiv.load("./pages/"+menuTabs[TabId]+".htm",function(){
									//alert(count);
									//var tmpHTML = uniqueDiv.html();
									//tmpHTML = tmpHTML.replace("menuPageScrollHolder","menuPageScrollHolder"+count);
									//tmpHTML = tmpHTML.replace("menuPageScrollContent","menuPageScrollContent"+count);
									//alert(tmpHTML);
									//uniqueDiv.html(tmpHTML);
									//scrollBars[count] = new scrollBar("menuPageAllContent"+count, "menuPageScrollHolder"+count, "menuPageScrollContent"+count);scrollBars[count].appendScroll(menuScrollBarTopPos[TabId], 442);
									if (count<2){
										count++;
									}
									else {
										count = 1;
									}
									// Omniture Call
									$.getScript("./pages/"+menuTabs[TabId]+".js");
									$.getScript("../global/js/s_code_remote.js");

								});
								//fade it in
								kid.animate({opacity:1},_globalFadeTime,_globalFadeEasing);
							});
						}
						else {
							clickBtwn.animate({left: "-=462px"},_globalSlideTime,_globalSlideEasing);
						}
					}
					openMenuID = TabId;
				}
				else if (TabId < openMenuID) {
					for (i=openMenuID;i>TabId;i--) {
						//document.getElementById(menuTabs[i]).left = document.getElementById(menuTabs[i]).left - 462;
						//slide everything between the open menu and the clicked menu
						var tabBtwn = $('#MenuPages'+menuTabs[i]);
						tabBtwn.animate({left: "+=462px"},_globalSlideTime,_globalSlideEasing);
						var nameBtwn = $('#MenuPagesNames'+menuTabs[i]);
						nameBtwn.animate({left: "+=462px"},_globalSlideTime,_globalSlideEasing);
						var clickBtwn = $('#MenuPagesClicks'+menuTabs[i]);
						if (i-1==TabId){
							clickBtwn.animate({left: "+=462px"},_globalSlideTime,_globalSlideEasing,function(){
								//load the new menu
								uniqueDiv.load("./pages/"+menuTabs[TabId]+".htm", function(){
									//alert(count);
									//var tmpHTML = uniqueDiv.html();
									//tmpHTML = tmpHTML.replace("menuPageScrollHolder","menuPageScrollHolder"+count);
									//tmpHTML = tmpHTML.replace("menuPageScrollContent","menuPageScrollContent"+count);
									//alert(tmpHTML);
									//uniqueDiv.html(tmpHTML);
									//scrollBars[count] = new scrollBar("menuPageAllContent"+count, "menuPageScrollHolder"+count, "menuPageScrollContent"+count);scrollBars[count].appendScroll(menuScrollBarTopPos[TabId], 442);
									if (count<2){
										count++;
									}
									else {
										count = 1;
									}
									// Omniture Call
									$.getScript("./pages/"+menuTabs[TabId]+".js");
									$.getScript("http://www.tgifridays.com/global/s_code_remote.js");
								});
								//fade it in
								kid.animate({opacity:1},_globalFadeTime,_globalFadeEasing);
							});
						}
						else {
							clickBtwn.animate({left: "+=462px"},_globalSlideTime,_globalSlideEasing);
						}
					}
					openMenuID = TabId;
				}
			}); //end fadeout callback for open tab
			
			return false;
		}