// Title: Millthorpe Business Committee - javascript
// Author: Kalon Edser, http://www.kalonedser.com/
// Updated: 26 April 2010

jQuery(document).ready(function() {

	$('body').addClass('js');

	// fix png images with alpha channels
	$.ifixpng('../img/pixel.gif');
	$('.png').ifixpng();

	// slideshow
	$('#slideshow').cycle({ 
		timeout: 5000,
	    speed:  2500
	});
	
	// subnav drop down
	$('#nav li').hover(
	  function () {
		$(this).addClass("over");
	  },
	  function () {
		$(this).removeClass("over");
	  }
	);
	
	// map tooltips (custom easyTooltip library)
	$('.legend a, .map-points a').easyTooltip({ useElement: '1' });

	$('.map-points').find('li').each(function(i){
		$(this).addClass('point'+i);
	});

	// preload images
	$.preloadImages('/img/prettyPhoto/light_rounded/sprite.png','/img/prettyPhoto/light_rounded/loader.gif');
	
	// inline viewer
	$("a[rel^='inlineView']").prettyPhoto({
		animationSpeed: 'normal', /* fast/slow/normal */
		padding: 40, /* padding for each side of the picture */
		opacity: 0.35, /* Value betwee 0 and 1 */
		showTitle: false, /* true/false */
		allowresize: true, /* true/false */
		counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded' /* light_rounded / dark_rounded / light_square / dark_square */
	});
	
	// delay vine load
	function showVines() {
		$('#vine-top').addClass('load-vine-top');
		$('#vine-btm').addClass('load-vine-btm');
	}

	$('#home .vines').each(function() {
		if ($(window).complete) {
			showVines();
		} else {
			$(window).bind('load', showVines);
		}
	});

	// open new window for external links
	$('A[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });

});