$(function()
	{
		///////////////////////////
		//MOBILE BROWSER DETECTION
		//////////////////////////
		
		if($("body").css("display") == "none"){
			
			location.href = "http://subwayfreshbuzz.mobi/";
			return;
		}
		
		$('#pane1').jScrollPane({showArrows:true, scrollbarWidth: 10}); // this initialises the demo scollpanes on the page.
		$('#pane2').jScrollPane({showArrows:true, scrollbarWidth: 10}); // Legal Forms
		$('#legal').hide()
		$("#legalBtn").click(function(){
			css = $("#legal").css("display")
			if(css == 'block'){
				$(this).text("View Legal")
				trackOmniClick(
					true,
					"o",
					"Footer: View Legal"
				)
			}
			else{
				$(this).text("Hide Legal")
				trackOmniClick(
					true,
					"o",
					"Footer: Hide Legal"
				)
			}
			$("#legal").slideToggle();
			
		})
		
		// Handle Z-index for IE
		if ($.browser.msie) {
			$('#primary_nav').find('a').hover(
		   		function(){
		   			fixZ(-1)
				},
				function(){
					fixZ(1)
				}
			)
			$('li.cap').hover(
		   		function(){
		   			fixZ(-1)
				},
				function(){
					fixZ(1)
				}
			)
		}
		
	});
	function toggleNutrition(type){
		if(type == 'food' || type == 'undefined'){
			$("#product_btns").show()
			$("#print_btn").hide()
		}
		else{
			$("#product_btns").hide()
			$("#nutrition_info").hide()
		}
	}
	
	function trackFlashClick(str,url,target,params){
		
		var browser_url = document.location.toString()
		
		urchinTracker(str)
		
		// NEW URCHIN TRACKING --V--
		
		//MMB_urchinTracker(str, tempURL, tempTarget)
		
		if(typeof url == 'undefined'){
			return;
		}
		
		func = openSameWindow
		var to = 300
		
		if(target == "_blank"){
			func = openNewWindow
			to = 300
		}
		
		window.setTimeout(func, to)
		
		function openSameWindow(){
			this.location.href = url
		}
		
		function openNewWindow(){
			
			var p = 'width=' + $(window).width() +',height='+$(window).height()+',scrollBars=yes, resizable=yes, toolbar=yes, location=yes, ,menubar=yes';
			
			if(params){
				p = params
			}
			
			a = window.open(url,"newWindow",p)
		}
		
	}
	
	function OpenPopup()
    {
         window.open ("http://scrabbleuat.icmodus.com/consumertesting/Main.aspx", "mainWindow","menubar=0,resizable=0,width=968,height=700, status=0,toolbar=0"); 
    }
	
	function trackClick(id,obj,type,link_name,product_id){
		
		var obj = document.getElementById('nutrition_info')
		var buttons = new Array()
		buttons[0] = 'print';
		buttons[1] = 'open';
		var whichButton = buttons[id];
		var str
		
		var params = [];
		
		params = [
			['prop14',product_id],
			['eVar16',product_id],
			['products',";"+product_id],
			['linkTrackVars','prop14,eVar16,products,events']
		]
		
		if(obj.style.display == 'none'){
			str = '/menu/nutrition_btn/interaction/'+buttons[id];
			trackFlashClick(str)
			params.push(['events','event8']);
			params.push(['linkTrackEvents','event8']);
			trackOmniClick(obj,type,link_name,params);
		}
		else{
			
			if(id == 0){
				str = '/menu/print_btn/interaction/'+buttons[id];
				params.push(['events','event15']);
				params.push(['linkTrackEvents','event15']);
				trackOmniClick(obj,type,link_name,params)
				window.setTimeout(w,300)
			}
		}
		function w(){
			trackFlashClick(str)
		}
	}
	
	function fixZ(z){
		// Product descriptions
		var a = document.getElementById('product_desc')
		if(a) a.style.zIndex = z;
		
		// Catering Page
		var b = document.getElementById('product_catering')
		if(b) b.style.zIndex = z;
		
		var c = document.getElementById('product_sandwich_platter')
		if(c) c.style.zIndex = z
		
		var d = document.getElementById('catering_desc')
		if(d) d.style.zIndex = z
		
		var e = document.getElementById('product_giant_subs')
		if(e) e.style.zIndex = z
		
		var f = document.getElementById('product_wrap_platter')
		if(f) f.style.zIndex = z
		
		var g = document.getElementById('product_cookie_platter')
		if(g) g.style.zIndex = z
		
		
	}
	
	/* SCRABBLE POP-UP */
	
	function popup(page, height, width)
	{
		var url = page;
		var h = height;
		var w = width;
		
		if(!h)
		{
			w = $(window).width();
			h = $(window).height();
		}
		
		window.open(url,'','toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=' + w + ',height=' + h + ',left=100,top=100');
	}
	
	function popupScrabble(clickTag){
		
		trackFlashClick(clickTag)
		
		popupStd('https://scrabble.subwayfreshbuzz.com/',clickTag)
	
	}
	
	function popupStd(clickTag) {
		
		if(typeof clickTag == 'undefined'){
			trackFlashClick('/lsu/scrabble/interaction/play_btn/launch');
		}
		
		window.open('https://scrabble.subwayfreshbuzz.com/','subway','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=985,height=720,left=0,top=0');
	}
	
	/* POP UP FOR MSNBC.COM */
	
	function confirmation(page) {
		var response = confirm("You are now leaving the SUBWAY"+ unescape("%AE")+" restaurants website(s)."+'\n\n'+"The policies, including the privacy policy, on the site(s) you are going to may vary from SUBWAY"+ unescape("%AE")+" restaurants policies. SUBWAY"+ unescape("%AE")+" restaurants is not responsible for the policies and practices of other companies.");
		if (response){
			OpenWin = this.open(page);
		}
	}
	
	function confirmationAndTarget(page, target) {
		var response = confirm("You are now leaving the SUBWAY"+ unescape("%AE")+" restaurants website(s)."+'\n\n'+"The policies, including the privacy policy, on the site(s) you are going to may vary from SUBWAY"+ unescape("%AE")+" restaurants policies. SUBWAY"+ unescape("%AE")+" restaurants is not responsible for the policies and practices of other companies.");
		if (response){
			OpenWin = this.open(page, target);
		}
	}
	
	function popUpTony(page, clickTag) {
		trackFlashClick(clickTag)
		var response = confirm("You are now leaving the SUBWAY"+ unescape("%AE")+" restaurants website(s)."+'\n\n'+"The policies, including the privacy policy, on the site(s) you are going to may vary from SUBWAY"+ unescape("%AE")+" restaurants policies. SUBWAY"+ unescape("%AE")+" restaurants is not responsible for the policies and practices of other companies.");
		if (response){
			OpenWin = this.open(page);
		}
	}
	
	
	<!--//--><![CDATA[//><!--
	sfHover = function() {
		var sfEls = document.getElementById("primary_nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
	//if (window.attachEvent) window.attachEvent("onload", sfHover);
	
	//--><!]]>
	
	
	/* Omniture Link Tracking */
	
	function trackOmniClick(obj,type,link_name, params, s_obj){
		
		/*
			obj = html element
			types =
				"d" = download
				"e" = exit link
				"o" = custom link
			link_name is a descriptor for the link that was clicked
			params = an array of attributes for the s object
		*/
		
		var s
		
		// Create an s object if one wasnt passed in
		
		if(typeof s_obj == "undefined"){
			s=s_gi(s_account);
		}
		else{
			s = s_obj;
		}
		
		//s.events = "";
		
		// Assign the dynamic attributes
		
		if(typeof params != "undefined"){
		
			for(var i=0; i < params.length; i++){
				eval("s." + params[i][0] +"='" + params[i][1] + "'")
			}
		
		}
		
		if(s.linkTrackVars.toLowerCase() == 'None'){
			s.linkTrackVars = "";
		}
		else{
			s.linkTrackVars += ",channel";
		}
		
		var lt=obj.href!=null?s.lt(obj.href):"";
		
		if (lt==""){
			s.tl(obj,type,link_name);
		}
		
	}
	
	function trackOmniPageView(params){
		if(typeof params != "undefined"){
		
			for(var i=0; i < params.length; i++){
				//alert("s." + params[i][0] +"='" + params[i][1] + "'")
				eval("s." + params[i][0] +"='" + params[i][1] + "'")
			}
		
		}
		
		var s_code=s.t();if(s_code)document.write(s_code)
		
	}
	
	function startTransition(dest){
		
		if(document.location.toString().indexOf("freshfit_meal_builder") == -1){
			location.href = '/menu/freshfit_meal_builder/?section='+dest+'#'+dest;
		}
		else{
			getMovieName("sfb_meal_builder").callTransition(dest);
		}
	}
	
	function getMovieName(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			return window[movieName]
		}
		else {
			return document[movieName]
		}
    }
	
	function updateHash(hash){
		location.hash = hash
		if(hash == "kids"){
			$('#subcat_10_item_0').removeClass("active_item");
			$('#subcat_10_item_1').addClass("active_item");
		}
		else{
			$('#subcat_10_item_1').removeClass("active_item");
			$('#subcat_10_item_0').addClass("active_item");
		}
	}