/**
 * @author adam
 */

var display_timeout = 0;

$(document).ready(function() {
	
	
	/* 
	 * init imageTitle plugin 
	 * on home page highlights
	 */
	
	var mouseEvent = (PHONE == true) ? "click" : "mouseover";
	
	$('#home_highlights .item').hover(function(){
		$(this).find('.caption').animate({'top': 0}, 500);
	}, function() {
		$(this).find('.caption').animate({'top': 150}, 500);
	});
	/*
	$('#highlight-mymove').imageTitle({
		bgColor : "#7F6106",
		color   : "#ffffff",
		opacity : 0.9,
		onEvent : mouseEvent
	}).hover(function() {
		$('.logo_gold').fadeOut();
		$('.logo').fadeIn();
	});
	
	$('#highlight-green').imageTitle({
		bgColor : "#0F4D1C",
		color   : "#ffffff",
		opacity : 0.9,
		onEvent : mouseEvent
	}).hover(function() {
		$('.logo_gold').fadeOut();
		$('.logo').fadeIn();
	});
	
	$('#highlight-birthday').imageTitle({
		bgColor : "#212A60",
		color   : "#ffffff",
		opacity : 0.9,
		onEvent : mouseEvent
	}).hover(function() {
		$('.logo_gold').fadeOut();
		$('.logo').fadeIn();
	});
	*/
	
	
	
	/*
	 * fade logo into gold logo on hover
	 * relocate window on click to location of read more link
	 */
	var link = null;
	$('.block').css('cursor', 'pointer').click(function() {
		window.location = $(this).children('a.read_more').attr('href');
	}).hover(function() {
		$('.imageTitle-caption').fadeOut();
		var this_ref = $(this);
		display_timeout = setTimeout(function() {
				display_timeout = 0;
				
				$('.logo_gold').fadeOut();
				$('.logo').fadeIn();
				
				this_ref.children('.logo').fadeOut(500);
				this_ref.children('.logo_gold').fadeIn();
		}, 200);
	}, function() {		
	
		if(display_timeout != 0) {
			clearTimeout(display_timeout);
		}
	
		$('.logo_gold').fadeOut();
		$('.logo').fadeIn();
		
		$(this).children('.logo_gold').fadeOut(500);
		$(this).children('.logo').fadeIn();
	});
	
	$('.fancy').fancybox();
	
});


