$(document).ready(function(){  
  
    $("ul.topnav li a, ul.topnav_tours li a, ul.topnav_reservations li a, ul.topnav_rentals li a, ul.topnav_groups li a, ul.topnav_photos li a, ul.topnav_aboutus li a").hover(function() { 
  
        //Following events are applied to the subnav itself (moving subnav up and down)  
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click  
  
        $(this).parent().hover(function() {  
        }, function(){  
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up  
        });  
  
        //Following events are applied to the trigger (Hover events for the trigger)  
        }).hover(function() {  
            $(this).addClass("subhover"); //On hover over, add class "subhover"  
        }, function(){  //On Hover Out  
            $(this).removeClass("subhover"); //On hover out, remove class "subhover"  
    });  
  
});  

$(document).ready(function(){  
	$('.buy-tours').mouseover(function() {
		$(this).css('background-image', 'url(images/buy-tour-hover.png)')
	});
	$('.buy-tours').mouseout(function() {
		$(this).css('background-image', 'url(images/buy-tour.png)')
	});
});

$(document).ready(function(){  
	$('#tour-cp').mouseover(function() {
		$(this).css('background-image', 'url(images/centralpark-tour-hover.png)');
	});
	$('#tour-cp').mouseout(function() {
		$(this).css('background-image', 'url(images/centralpark-tour.png)');
	});
});

$(document).ready(function(){  
	$('#tour-nyc').mouseover(function() {
		$(this).css('background-image', 'url(images/nyc-tour-hover.png)');
	});
	$('#tour-nyc').mouseout(function() {
		$(this).css('background-image', 'url(images/nyc-tour.png)');
	});
});

$(document).ready(function(){  
	$('#tour-brooklyn').mouseover(function() {
		$(this).css('background-image', 'url(images/brooklyn-tour-hover.png)');
	});
	$('#tour-brooklyn').mouseout(function() {
		$(this).css('background-image', 'url(images/brooklyn-tour.png)');
	});
});

$(document).ready(function(){  
	$('#tour-harlem').mouseover(function() {
		$(this).css('background-image', 'url(images/harlem-tour-hover.png)');
	});
	$('#tour-harlem').mouseout(function() {
		$(this).css('background-image', 'url(images/harlem-tour.png)');
	});
});

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

jQuery.preLoadImages("centralpark-tour-hover.png.gif", "images/centralpark-tour-hover.png");
jQuery.preLoadImages("nyc-tour-hover.png.gif", "images/nyc-tour.png-hover");
jQuery.preLoadImages("brooklyn-tour-hover.png.gif", "images/brooklyn-tour-hover.png");
jQuery.preLoadImages("harlem-tour-hover.png.gif", "images/harlem-tour-hover.png");
jQuery.preLoadImages("buy-tours-hover.png.gif", "images/buy-tours-hover.png");

function gallery_initCallback(carousel) {
    jQuery('.jcarousel-control a').bind('click', function() {
        //carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		carousel.scroll(jQuery.jcarousel.intval(jQuery(this).find('img').attr("alt")));
        return false;
    });
 
    jQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });
 
    jQuery('#gallery-next').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('#gallery-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

jQuery(document).ready(function() {
    jQuery('#gallery').jcarousel({
		initCallback: gallery_initCallback,
    	wrap: 'circular',
		scroll: 1,
		visible: 1,
		buttonNextHTML: null,
		buttonPrevHTML: null
    });
	jQuery('#thumb-gallery').jcarousel({
    	wrap: 'circular'
    });
});
