//String.prototype.trim = function () {
    //return this.replace(/^\s*/, "").replace(/\s*$/, "").replace(/\n/g,"").replace(/\r/g,"").replace(/\s/g,"");
//}

//pass the id of the containing UL and tell the function if it's a big hero or not (true or false)
function heroes(selectors, big) {
	//select the featured item in the hero.
	$(selectors + ' li').each(function(i){
		if(big == true) {
			var _t1 = $('div', this).text();
			var _t2 = $('.featureDescription', this).text();
			if(_t1 == _t2) {
				$(selectors + ' .holiday_picker li a').removeClass("on");
				$('a', this).addClass('on');
			}
		}
	});
	//bind the mouseover event to the hero list items
	$(selectors + ' li').bind('mouseover', function(){
		if(big == true) {
			$('.featureDescription').html($('div', this).html());
		}
		$(selectors + ' .holiday_picker li a').removeClass('on');
		$(this).find('a').addClass('on');
	});
}


/* READ MORE/LESS */
$(document).ready(function() {
	$('#expandable_control').click(function() {
		$('.expandedText').toggle();
		$('#expandable_control').toggle();
		return false;
	});
	$('#expandable_hide_control').click(function() {
		$('.expandedText').toggle();
		$('#expandable_control').toggle();
		return false;
	});
});

// If #homepageIntro is on the page, move the text further down the page. If no JS, the text stays where it is!
$(document).ready(function() {
	if($('#homepageIntro').size() > 0) {
		$('#contentBox').append('<div id="SEOIntroPlaceholder">' + $('#homepageIntro').html() + '</div>');
		$('#homepageIntro').css('display', 'none');
	}
});

// show/gide google maps
$(document).ready(function() {
	if($('.gmap_things_to_do').size() > 0) {
		$('.gMapShow').click(function() {
			$('#gMapHolder, .show-button, .hide-button, #infoBoxWrapper').toggle();
			if($('#gMapHolder').css('display') == 'none') {
				$('#gMapPlaceholderHolder').css('height', '30px');
				$('#gMapHolderWrapper').css('border-width', '1px 1px 0');
				$('#gMapHolderWrapper').css('width', '514px');
				$('#rightNav').css('margin', '-38px 0 0');
			} else {
				$('#gMapPlaceholderHolder').css('height', '454px');
				$('#gMapHolderWrapper').css('border-width', '1px');
				$('#gMapHolderWrapper').css('width', '823px');
				$('#rightNav').css('margin', '480px 0 0');
			}
		});
	}
});

// hover over videos - change meta data
$(document).ready(function() {
	if($('#list_gallery').size() > 0) {
		$('#list_gallery ul li').hover(function() {
			$('.listGalleryDescription p').text($('p', this).text());
			$('.listGalleryDescription h4').text($('h4', this).text());
		});
	}
});

//left nav sponsored content 
//reset height of li element if img too tall
$(document).ready(function(){
	if($('li').hasClass('special')){
		
		$('li.special').each(function(idx,item){
			
			var divHeight = $(this).height();
			var imgHeight = $("img", this).height();
			var adjHeight = imgHeight - divHeight;
			var adjHeight = adjHeight + 20;
			if(imgHeight >= divHeight){
				$("a", this).css({"padding-bottom": adjHeight});
			}
		})
	}
});
