// JavaScript Document
var chromeColor = "blue";
var chromeWidth = 994;  //old 1008


function trackLink(lid,lpos,obj) {
   try{
     cto.linkObj=obj;
     cto.linkId=lid;
     cto.linkPosition=lpos;
     cto.linkType='o';
     cto.trackLink();

     cto.linkObj="";
     cto.linkId="";
     cto.linkPosition="";
     cto.linkType="";
   }catch(e){}
     //alert("lid="+lid+"      lpos="+lpos+"      obj="+obj );

 }
 
 /*when the search button is clicked*/
 function AnalyticsTrackLink(lid,lpos,obj) {
	 try {
	
		 cto.linkObj=obj;
	
		 cto.linkId=lid;
	
		 cto.linkPosition=lpos;
	
		 cto.linkType='o';
	
		 cto.trackLink();
	
		 //clear link tracking variables
	
		 cto.linkObj="";
	
		 cto.linkId="";
	
		 cto.linkPosition="";
	
		 cto.linkType="";
	
	   } catch(e) {}
	//window.console && console.log("OMNITURE="+lid + ', ' + lpos + ', ' + obj);
   //alert(lid + ', ' + lpos + ', ' + obj);
}
	function OmnitureSubmit (obj){
		AnalyticsTrackLink('global/search/link','global/search/', obj);
	
		gid('search_form').submit();
	}
	
	function convertOmnitureName(obj){
		if ($(obj).attr("name")){
			name=$(obj).attr("name");
		}else{
			name=$(obj).find("a").attr("name");
		}
		omni = name.split('&');
		var lid= omni[1];
		var lpos= omni[2];
		
		lid = lid.substring((lid.indexOf('=')+1),lid.length);
		lpos = lpos.substring((lpos.indexOf('=')+1),lpos.length);
		AnalyticsTrackLink(lid, lpos, obj);
	}
	
	
	
	
function goPremier(){
	
	if (gid('premier_dropdown').selectedIndex!=0) {

		if (gid('premier_dropdown').selectedIndex==1) {
		trackLink("home/premier/premier_manage_account_link", "home/premier/", this);
		} else {
	
		trackLink("home/premier/premier_manage_rewards_link", "home/premier/", this);
		}
		window.open("redirect?destination="+gid('premier_dropdown').value);
	}
}
	
function goCredit(){
	if (gid('credit_dropdown').selectedIndex!=0) {

		if (gid('credit_dropdown').selectedIndex==1) {
		trackLink("home/classic/classic_manage_account_link", "home/classic/", this);
		} else {
		trackLink("classic/classic_manage_rewards_link", "home/classic/", this) ;
		}
		window.open("redirect?destination="+gid('credit_dropdown').value);
	}
}


function openURL(sURL) {
	
	if (sURL=="/cards-overview"){
		window.console && console.log('sURL='+sURL);
		window.opener.test();
		//window.opener.document.getElementById('pop').click();
		
	}else{
		opener.document.location = sURL;
	}
	setTimeout("closePopup()", 1000);
	

};

function closePopup(){
	window.close(); 
}

function test(){
	$(document).ready(function(){
	//alert('testing');
			//Fade in the Popup and add close button
			$('#popup').fadeIn().css({ 'width': 890 }).prepend('<a href="#" class="close">close x</a>');
			
			$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
			$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
			$('html, body').animate({scrollTop:$('body').position().top}); 
	
	});


}


$(document).ready(function(){

//new menu

		$('li.menu2').click(function() {
			$(this).removeClass('active');			
		});	

	function Overlay() {	
		//When you click on a link with class of poplight and the href starts with a # 
			$('a.poplight[href^=#]').click(function() {
			var popID = $(this).attr('rel'); //Get Popup Name
			var popURL = $(this).attr('href'); //Get Popup href to define size
					
			//Pull Query & Variables from href URL
			var query= popURL.split('?');
			var dim= query[1].split('&');
			var popWidth = dim[0].split('=')[1]; //Gets the first query string value
			
			//Fade in the Popup and add close button
			$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close">close x</a>');
			
			//Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css
			//var popMargTop = ($('#' + popID).height() ) / 2;
			//var popMargLeft = ($('#' + popID).width() ) / 2;
			
			//Apply Margin to Popup
			/*$('#' + popID).css({ 
				'margin-top' : -popMargTop,
				'margin-left' : -popMargLeft
			}); */
			
			//Fade in Background
			$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
			$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
			$('html, body').animate({scrollTop:$('body').position().top}); 
			return false;
			});
			
			
			//Close Popups and Fade Layer
			$('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...
			$('#fade , .popup_block').fadeOut(function() {
				$('#fade, a.close').remove();  
			}); //fade them both out
			
			return false;
			});
	}

	$('#main_nav ul li').hover(function () {
			//show its submenu
			$('ul.drop', this).slideDown(100);
			}, function () {
			//hide its submenu
			$('ul.drop', this).slideUp(100);			
		});

		//main nav - hover
		$('#main_nav ul li').not('ul.drop li').each(function(){
			$(this).on({
				mouseenter: function(){
				$(this)
				.css({
				'top':'-3px',
				'left':'-3px'
				})
				.addClass('hover');
				},
				mouseleave: function(){
				$(this)
				.css({
				'top':'0px',
				'left':'0px'
				})
				.removeClass('hover');
				}
			});
		});

		
		//main nav - if the main nav is active, do not have the hover
		  $('#main_nav ul li').not('ul.drop li').hover(function(){
			  if ( $(this).hasClass('active') )
				$(this).css('margin','0px');
			});
		
			$('#main_nav ul li').hover(function () {
				$('ul', this).slideDown(100);
				}, function () {
				$('ul', this).slideUp(100);			
			});	

		$('#main_nav ul li').not('.menu2').click(function(index) {
			   convertOmnitureName(this);
			   window.location=$(this).find("a").attr("href");
				return false;
		});	
		
		//drop down

		$(".drop h3").click(function(){
			AnalyticsTrackLink(this);
			$(this).next("div.hidden").slideToggle('fast')
			.siblings("div.hidden:visible").slideUp('fast');
			$(this).toggleClass("active");
			$('html, body').animate({scrollTop:$('h3.active').position().top});
			$(this).siblings("h3").removeClass("active");
		});

				

						   
	//*************************************************************************

function omnidrop(formdrop, target){
		$(target).attr("name", $("option:selected", formdrop).attr("name"));
	}
		
	$("#manage_credit_account").change(function () {
			omnidrop("#manage_credit_account","#buttonA");
	});
	$("#manage_credit_rewards").change(function () {
			omnidrop("#manage_credit_rewards","#buttonB");
	});
	$("#manage_debit_account").change(function () {
			omnidrop("#manage_debit_account","#buttonC");
	});
	$("#manage_debit_rewards").change(function () {
			omnidrop("#manage_debit_rewards","#buttonD");
	});
	
	//menu1 = "ul#menu_level1_outter >li.menu"+first_teir_menu_selected;
	menu1 = "#main_nav ul >li.menu"+first_teir_menu_selected;
	$(menu1).addClass("active");
	
	menu2 = "ul.menu_level2 li.menu"+second_teir_menu_selected;
	$(menu2).addClass("active");
	
	menu3 = ".menu_level3 a:eq("+(third_teir_menu_selected-1)+")";
	$(menu3).addClass("active");
	$(menu3).after("<a href=# class=cap>&nbsp;</a>");

    //added menu4 to control the 3rd tier navigation on Credit/Debit rewards pages
    
	menu4 = "ul.menu_level4 li >a.menu"+third_teir_menu_selected;
	$(menu4).addClass("active");

	
	//search bar box
	//$("#search_bar_box, .home_search > input").click(function(event){$(this).attr("value", "")});
	
	//footer popups
	$(".popupwindow").popupwindow();
	
	//menu set at height 1 overflow hidden to preload, setting back to normal.
	$("#menu_level1 ul.debit").hide();
	$("ul.credit").hide();
	$("#menu_level1 ul.debit").css({'height': '140px'});
	$("ul.credit").css({'height': '160px'});
	
	//if($("body").attr("template_version")=="0.9.3"){}else{
//		$("<div class='alert'>Warning: The template used by this page is outdated.</div>").prependTo("#page").slideDown("slow");
//	}
	
	//*************************************************************************

	$("ul#menu_level1_outter >li").mouseover(function(event){$(this).addClass("hover")});
	$("ul#menu_level1_inner").mouseover(function(event){$(this).addClass("hover")});
	$("ul#menu_level1_outter >li").mouseout(function(event){$(this).removeClass("hover")});
	$("ul#menu_level1_inner").mouseout(function(event){$(this).removeClass("hover")});
	
   $("ul#menu_level1_outter > li").mouseover(
		function(event){
		if($(this).hasClass("menu4")==false&&$(this).hasClass("menu3")==false){
			if($(this).hasClass("active")!=true){$(this).animate({'margin': '-3px 3px 3px -3px'},{queue:false, duration:200, easing: 'easeOutCubic'})}
			$("ul.credit").stop(true, true).hide();
			$("#menu_level1 ul.debit").stop(true, true).hide();
		}else if($(this).hasClass("menu3")==true){
			if($(this).hasClass("active")!=true){$(this).animate({'margin': '-3px 3px 3px -3px'},{queue:false, duration:200, easing: 'easeOutCubic'})}
			$("ul.credit").fadeIn();
			$("#menu_level1 ul.debit").stop(true, true).hide();
		}else if($(this).hasClass("menu4")==true){
			if($(this).hasClass("active")!=true){$(this).animate({'margin': '-3px 3px 3px -3px'},{queue:false, duration:200, easing: 'easeOutCubic'})}
			$("#menu_level1 ul.debit").fadeIn();
			$("ul.credit").stop(true, true).hide();
		}
   });
   
    $("ul#menu_level1_outter > li").mouseout(
		function(event){
			if(($(this).hasClass("menu3")!=true)&&($(this).hasClass("menu4")!=true)){
				$(this).stop(true, true).animate({'margin':'0px'},{queue:false, duration:300, easing: 'easeOutBounce'})
				$("ul.credit").stop(true, true).hide();
				$("#menu_level1 ul.debit").stop(true, true).hide();
			}else if($(this).hasClass("menu3")){
				$(this).stop(true, true).animate({'margin':'0px'},{queue:false, duration:300, easing: 'easeOutBounce'})
				if($("ul.credit").hasClass("hover")!=true){
					$("ul.credit").stop(true, true).hide();
				}
			}else if($(this).hasClass("menu4")){
				$(this).stop(true, true).animate({'margin':'0px'},{queue:false, duration:300, easing: 'easeOutBounce'})
				if($("#menu_level1 ul.debit").hasClass("hover")!=true){
					$("#menu_level1 ul.debit").stop(true, true).hide();
				}
			}
	});
	
	
	$("ul.credit").mouseout(function(event){
			$(this).hide();
	});
	
	$("#menu_level1 ul.debit").mouseout(function(event){
			$(this).hide();
	});
	
	$("ul.credit").mouseover(function(event){
			$(this).show();
	});
	
	$("#menu_level1 ul.debit").mouseover(function(event){
			$(this).show();
	});
	
	
	$("ul#menu_level1_outter > li").click(
		function(event){
			convertOmnitureName(this);
			$("ul.credit").hide();
			$("#menu_level1 ul.debit").hide();
			
			$("ul#menu_level1_outter > li").removeClass("active");
			$(this).css({'padding': '0px', 'margin': '0px'});
			$(this).addClass("active");
	});
	
	$("ul#menu_level1_inner").click(function(event){
			convertOmnitureName(this);
			$("ul.credit").hide();
			$("#menu_level1 ul.debit").hide();
			
			if($(this).hasClass("credit")){
				$("ul#menu_level1_outter > li").removeClass("active");
				$("ul#menu_level1_outter > li.menu2").css({'padding': '0px', 'margin': '0px'});
				$("ul#menu_level1_outter > li.menu2").addClass("active");
			}else{
				$("ul#menu_level1_outter > li").removeClass("active");
				$("ul#menu_level1_outter > li.menu3").css({'padding': '0px', 'margin': '0px'});
				$("ul#menu_level1_outter > li.menu3").addClass("active");
			}
	});

   $(".widget_faq .w_button > a").click(
		function(event){
			if(!($(this).parent().hasClass("active"))){
				//convertOmnitureName(this);
				$(".widget_faq .w_button.active .w_content").slideUp();
				$(".widget_faq .w_button").removeClass("active");
				$(this).parent().toggleClass("active");
     			$(".w_content", $(this).parent()).slideDown("fast");
                
			}else{
		
				$(this).parent().toggleClass("active");
                $(".w_content", $(this).parent()).slideToggle();
     			
     			
			}
			
   });
   
   //deeplinks
  // window.console && console.log(window.location.pathname);
   var urlpath = window.location.pathname;
   var id = getUrlVars()["id"];
   
   if (urlpath=="/cards-overview-apply" ){
   		if (id=="designs"){
			var $tabs = $('#tabs').tabs(); // first tab selected
			$tabs.tabs('select', 1); // switch to tab 2
			return false;
	        $('#tabs-2').show();    
    	}
   
   } else if (urlpath=="/" ){
   		if (id=="card_members"){
		//Fade in the Popup and add close button
		$('#popup').fadeIn().css({ 'width': 890 }).prepend('<a href="#" class="close">close x</a>');
		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer 
		$('html, body').animate({scrollTop:$('body').position().top});  			
    	}
   
   } else if (urlpath=="/rewards" ){
   		
   		if (id=="earn"){ 
			$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/earning');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/earning');
			});
			
    	} else if (id=="redeem") {
    		
			$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/redeeming');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/redeeming');
			});

    	} else if (id=="disney"){
  
			$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/redeem-disney');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/redeem-disney');
			});
			
		} else if (id=="airline"){

			$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/redeem-airline');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/earning'); //defaults to earning
			});		
    	
    	} else if (id=="locations"){
    	
    		$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/disney-locations');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/disney-locations'); 
			});		
    	
    	} else if (id=="theaters"){

    		$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/movie-theaters');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/movie-theaters'); 
			});		
    	
    	
    	}else if (id=="stores"){
    	    //?id=stores
    		$('#cardpremier a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/premier/other-stores');
			});
			
			$('#cardclassic a.select_btn').click(function(index){
				$(this).attr('href', '/rewards/classic/other-stores'); 
			});		
    	
    	}

   } else if (urlpath=="/rewards/premier/disney-locations" || urlpath=="/rewards/classic/disney-locations" ){
   
   
   	//alert("id="+id);
   		if (id=="wdw"){
			$("ul.widget_drawer:eq(0) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(0) li.w_button ul.w_content").slideToggle();
			$('html, body').animate({scrollTop:$("#content").position().top}, 500);
		} else if (id=="dlr"){
			$("ul.widget_drawer:eq(1) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(1) li.w_button ul.w_content").slideToggle();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(1) li.w_button").position().top}, 500);
		} else if (id=="ds"){
			$("ul.widget_drawer:eq(2) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(2) li.w_button ul.w_content").slideToggle();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(2) li.w_button").position().top}, 500);
		} else if (id=="odl"){
			$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
		} else if (id=="other_travel"){
			$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
			$("ul.widget_drawer:eq(3) li.w_sub_button:eq(0)").addClass("active");
		$("ul.widget_drawer:eq(3) li.w_sub_button:eq(0) .w_sub_content").slideDown();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
		} else if (id=="other_dcl"){
			$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
			$("ul.widget_drawer:eq(3) li.w_sub_button:eq(1)").addClass("active");
		$("ul.widget_drawer:eq(3) li.w_sub_button:eq(1) .w_sub_content").slideDown();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
		} else if (id=="other_abd"){
			$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
			$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
			$("ul.widget_drawer:eq(3) li.w_sub_button:eq(2)").addClass("active");
		$("ul.widget_drawer:eq(3) li.w_sub_button:eq(2) .w_sub_content").slideDown();
			$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
		} else if (id=="other_aulani"){
		  $("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
		  $("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
		  $('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
		} else if (id=="dvc"){
		  $("ul.widget_drawer:eq(4) li.w_button").toggleClass("active");
		  $("ul.widget_drawer:eq(4) li.w_button ul.w_content").slideToggle();
		  $('html, body').animate({scrollTop:$("ul.widget_drawer:eq(4) li.w_button").position().top}, 500);
		}
  	
    } else if (urlpath=="/rewards/premier/movie-theaters" || urlpath=="/rewards/classic/disney-theaters" || urlpath=="/rewards/premier/other-stores" || urlpath=="/rewards/classic/other-stores" ) {
   
   
   	//alert("id="+id);
   	if (id=="how-to-order"){
        	$("ul.widget_drawer:eq(0) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(0) li.w_button ul.w_content").slideToggle();
        	$('html, body').animate({scrollTop:$("#content").position().top}, 500);
    	} else if (id=="order-vouchers"){
        	$("ul.widget_drawer:eq(1) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(1) li.w_button ul.w_content").slideToggle();
        	$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(1) li.w_button").position().top}, 500);
  	} else if (id=="order-status"){
        	$("ul.widget_drawer:eq(2) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(2) li.w_button ul.w_content").slideToggle();
        	$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(2) li.w_button").position().top}, 500);
  	} else if (id=="participating-theaters"){
        	$("ul.widget_drawer:eq(2) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(2) li.w_button ul.w_content").slideToggle();
        	$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(2) li.w_button").position().top}, 500);
  	} else if (id=="participating-retailers"){
        	$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
        	$("ul.widget_drawer:eq(3) li.w_sub_button:eq(0)").addClass("active");
		$("ul.widget_drawer:eq(3) li.w_sub_button:eq(0) .w_sub_content").slideDown();
        	$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
  	} else if (id=="faq"){
        	$("ul.widget_drawer:eq(3) li.w_button").toggleClass("active");
        	$("ul.widget_drawer:eq(3) li.w_button ul.w_content").slideToggle();
        	$("ul.widget_drawer:eq(3) li.w_sub_button:eq(1)").addClass("active");
		$("ul.widget_drawer:eq(3) li.w_sub_button:eq(1) .w_sub_content").slideDown();
        	$('html, body').animate({scrollTop:$("ul.widget_drawer:eq(3) li.w_button").position().top}, 500);
  	}
    
    } else if (urlpath=="/perks/card-perks"){
    	if (id=="10-off"){
    	$('.drop h3:eq(0)').toggleClass('active');
		$('div.hidden:eq(0)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(0)').position().top}, 500);
    	
    	} else if (id=="financing"){
    	$('.drop h3:eq(1)').toggleClass('active');
		$('div.hidden:eq(1)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(1)').position().top}, 500);
    	
    	} else if (id=="theme-park-perks"){
    	$('.drop h3:eq(2)').toggleClass('active');
		$('div.hidden:eq(2)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(2)').position().top}, 500);
		
    	} else if (id=="cruise"){
    	 $('.drop h3:eq(3)').toggleClass('active');
		$('div.hidden:eq(3)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(3)').position().top}, 500);
    	
    	} else if (id=="dvc-financing"){
    	$('.drop h3:eq(4)').toggleClass('active');
		$('div.hidden:eq(4)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(4)').position().top}, 500);
    	
    	} else if (id=="card-designs"){
    	$('.drop h3:eq(5)').toggleClass('active');
		$('div.hidden:eq(5)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(5)').position().top}, 500);    	
    	}

    } else if (urlpath=="/perks/wdw-perks"){
		if (id=="meet-n-greet"){
    	$('.drop h3:eq(0)').toggleClass('active');
		$('div.hidden:eq(0)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(0)').position().top}, 500);
		
		} else if (id=="10-off"){
		$('.drop h3:eq(1)').toggleClass('active');
		$('div.hidden:eq(1)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(1)').position().top}, 500);
				
		} else if (id=="guided-tours"){
		$('.drop h3:eq(2)').toggleClass('active');
		$('div.hidden:eq(2)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(2)').position().top}, 500);
				
		} else if (id=="pdf"){
				
    	}
 
    
    } else if (urlpath=="/perks/disneyland-perks"){
		if (id=="meet-n-greet"){
    	$('.drop h3:eq(0)').toggleClass('active');
		$('div.hidden:eq(0)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(0)').position().top}, 500);		
			
		} else if (id=="10-off-merch"){
    	$('.drop h3:eq(1)').toggleClass('active');
		$('div.hidden:eq(1)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(1)').position().top}, 500);				
			
		} else if (id=="10-off-dining"){
    	$('.drop h3:eq(2)').toggleClass('active');
		$('div.hidden:eq(2)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(2)').position().top}, 500);
		
		} else if (id=="10-off-merch-and-dining"){
    	$('.drop h3:eq(3)').toggleClass('active');
		$('div.hidden:eq(3)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(3)').position().top}, 500);		
			
		} else if (id=="guided-tours"){
		 $('.drop h3:eq(4)').toggleClass('active');
		$('div.hidden:eq(4)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(4)').position().top}, 500);	
			
		} else if (id=="hotel-package"){
		 $('.drop h3:eq(5)').toggleClass('active');
		$('div.hidden:eq(5)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(5)').position().top}, 500);			
			
		} else if (id=="phone-line"){
		 $('.drop h3:eq(6)').toggleClass('active');
		$('div.hidden:eq(6)').slideToggle('fast');
		$('html, body').animate({scrollTop:$('.drop h3:eq(6)').position().top}, 500);		
				
		} else if (id=="pdf"){
			var findPDF = $(this).find('a.go_btn').attr('href');
		  
		   window.onload = function(){
			 document.location = findPDF;
			}
			
		}
    	
    
    
    } else if (urlpath=="/perks/card-design-options"){
    	if (id=="classic"){
			var $tabs = $('#tabs').tabs(); // first tab selected
			$tabs.tabs('select', 1); // switch to tab 2
			return false;
	        $('#tabs-2').show();    		        
    	}
    }

	
	$("ul.widget_drawer li.w_button > a").click(
		function(event){
			//convertOmnitureName(this);
			$(this).parent().toggleClass("active");
     		$(this).siblings(".w_content").slideToggle();
   });
	
	$("ul.widget_drawer li.w_sub_button > a").click(
		function(event){
			sel = $(this);
			$('html').animate({scrollTop: sel.closest("ul.widget_drawer").offset().top-100}, 300, function(event){
				if(sel.parent().hasClass("active")){
                
					sel.parent().removeClass("active");
					sel.siblings(".w_sub_content").slideUp();
				}
				else{
                    //convertOmnitureName(this);
					sel.parent().parent().find(".w_sub_button.active .w_sub_content").slideUp();
					sel.parent().parent().find(".w_sub_button.active").removeClass("active");
					sel.parent().addClass("active");
					sel.siblings(".w_sub_content").slideDown();
				}
			});
   });
  
  
  
 	 // print button
	$('a#print_btn').click(function() {
		convertOmnitureName(this);
		window.print();
		return false;
	});

	$("img.rollover").hover(function(event){
		var f = $(this).attr("src");
		var f_ext = f.slice(f.length-4, f.length);
		var f_name = f.slice(0, f.length-4);
		$(this).attr("src", f_name + "_rollover" + f_ext);
	},function(event){
		var f2 = $(this).attr("src");
		var f2_ext = f2.slice(f2.length-4, f2.length);
		var f2_name = f2.slice(0, f2.length-13);
		$(this).attr("src", f2_name + f2_ext);
	});
	
	function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}

 });
