(function($){
	$(function(){

		if($.fn.fontSize){
			$('div.fontSizeChanger').fontSize();
		}

		$('.dropdown.targetDestination').dropdown({
			trigger:'p.options a.destinationTrigger, p.options a.ddTrigger',
			close:'p.options a'
		});
		
		$('.dropdown.targetOffers').dropdown({
			trigger:'#header a.offersTrigger',
			close:'.offers a'
		});		
		
		//$('.redeem').redeem();
		
		
		//populate menu
		//$('#dropdownDestinations').load('/elements/featured_destinations_ns.html #menuContent');
		
		
		if ($.fn.tooltip) {
			/*
	 $('.hasHTMLTip').tooltip('menuStyle', {offset: ['right', 'bottom'], events: ['mouseover', 'load']})
	 .click(function(){
	 $(this).trigger('tip.close');
	 });
	 */
		    	var elem = $('.hasTitleTip').tooltip('menuStyle', {
				offset: ['right', 'bottom'],
				events: ['mouseover', 'load'],
				src: 'title',
				format: function(text){
					return '<h3>' + text.replace('.', '.</strong></h3><p>') + '</p>';
				}
			}).click(function(){
				$(this).trigger('tip.close');
			})
			.bind('tooltip.onopen', function(){ 
				$('#tooltip .close').click(function(){ 
					elem.trigger('tip.close');
					return false;
				})
				.html('close');
				$('#tooltip h3').attr("role", "alert");
			});
		}
		
		$('.iconPrint').click(function(e){
			e.preventDefault();
			window.print();
		}); 
		
		$('.iconPrint').show();
		
				if( $('#homeBanner').size() > 0 ){
			var featuredImage = $('.bannerContent .feature');
			var featuredName = $('.bannerContent .feature h2 span');
			var featuredDesc = $('.bannerContent .feature p');
			var featuredLink = $('.bannerContent .feature p.buttonStyle01 a');
			
			details.sort(function(a, b){
				return (Math.floor((Math.random() * 2) )*2)-1;
			})
			
			featuredImage.css('background-image', "url(" + details[0].image + ")");
			featuredName.html(details[0].name);
			featuredDesc.eq(1).html(details[0].longDesc);
			featuredLink.attr('href', details[0].url);	
					
		}
		
		if( $('#landingBanner').size() > 0 ){
			var featuredImage = $('.bannerContent .feature');
			var featuredName = $('.bannerContent .feature h2 span');
			var featuredDesc = $('.bannerContent .feature p');
			var featuredLink = $('.bannerContent .feature p.buttonStyle01 a');
			
			details.sort(function(a, b){
				return (Math.floor((Math.random() * 2) )*2)-1;
			})
			
			featuredImage.css('background-image', "url(" + details[0].image + ")");
			featuredName.html(details[0].name);
			featuredDesc.eq(1).html(details[0].longDesc);
			featuredLink.attr('href', details[0].url);	
					
		}
			

		
	});
	
	/*
	
	$.fn.redeem = function() {
		
		return $(this).each(function(){
		
			$(this).click(function(){
			
				$.overlay({closebutton:false})
				.addClass('overlay')
				.load('/templates/overlay-ns.html .overlay', function(){
					$(this)
					.find('.close')
					.click(function(){
						$(this).trigger('overlay.close');
						return false;
					})
					.show();
					
					var inputs = $(this).find('input.card_number').tabGroup({valid: /^\d$/}).eq(0).focus().end();
					var errorBox = $(this).find('div.errorMsg')
					
					$(this).find('#overlayContinue').click(function(){
						var keepers = inputs.filter(function(){
							if(!isNaN(parseInt($(this).val())) && parseInt($(this).val()) < 10 && parseInt($(this).val()) > -1){
								return true;
							}
							return false;
						})
						
						if (keepers.size() != inputs.size()) {
							errorBox.show();
							return false;
						}
					});
					

					
				});
				return false;
			});
		
		});
		
	};
	*/
	
	
	
})(jQuery);

function cleanSearchBox() {		
	var ele = document.getElementById('globalSite');
	if(ele.value == 'Type Merchant Name'){
		ele.value = '' ;
	}

}

