/***********************************************
* jQuery functions execute
***********************************************/
(function($) {
	$.fn.equalHeights = function(minHeight, maxHeight) {
		tallest = (minHeight) ? minHeight : 0;
		this.each(function() {
			if($(this).height() > tallest) {
				tallest = $(this).height();
			}
		});
		if((maxHeight) && tallest > maxHeight) tallest = maxHeight;
		return this.each(function() {
			$(this).height(tallest).css("overflow","hidden");
		});
	}
	})(jQuery);

jQuery(document).ready(function(){                  
              
	/*cmx form */
	if(jQuery.browser.mozilla) {
		$('form.cmxform').hide().find('label:not(.nocmx)').each(function(){
                          	var $labelContent = $(this).html();
                                       var $labelWidth = $(this).css('width');
                                       $(this).empty();
                                       $(this).append('<span style="display: block; width: '+$labelWidth+';">');
                                       $(this).prepend('</span>');
                                       $(this).css('display', '-moz-inline-box');
                                       $(this).find('span').html($labelContent);
                                       $('form.cmxform').show();
                                });
                };             
	/*on focus for input boxes*/
	$.fn.search = function() {
		return this.focus(function() {if( this.value == this.defaultValue ) {this.value = "";}})
		.blur(function() {if( !this.value.length ) {this.value = this.defaultValue;}});};
	$("#product-search input").search();
	
	/*external link*/
	$('a[rel*=external], a#hotels').click( function(){this.target = "_blank";});

	/*making float container equal height so background runs through*/
	//$(".grid").equalHeights();
	
	$('#logo, #more-about-hwt span, .panel input.send, input#convert, input#submitButton, #search-listing li, .listing-box li, #deals-search input, input#enquirycruise').css('cursor', 'pointer');
	$('.listing-box li').click(function(){window.location = $(this).find('a').attr("href");});
	/*slimbox*/
	$('#lbOverlay').css('cursor', 'pointer');
	/*dimming images on hover*/
	$('#city-gallery li, #country-gallery li').css('opacity', '0.75').css('cursor', 'pointer');
	$('#city-gallery li, #country-gallery li').hover(function() {$(this).css('opacity', '1.0');}, function() {$(this).css('opacity', '0.75')});
	$('#header, #main-contents').mouseover(function(){$('.submenu').hide();});
	
	/*locator table*/
	$('#search-listing').css('overflow-x', 'hidden');
	$('#search-listing li:even').addClass('alt');
	
	/*set hover class for anything*/
	$('.deals-list li').css('cursor', 'pointer').click(function(){window.location = $(this).find('a').attr("href");});
	$('#product-search input.send').css('cursor', 'pointer').hover(function() {$(this).addClass('gohover');}, function() {$(this).removeClass('gohover');});	
	$('form.cmxform input.send').css('cursor', 'pointer').hover(function() {$(this).addClass('inputhover');}, function() {$(this).removeClass('inputhover');});	
});

