$(document).ready( function() {
	
	//setHeight();
	
	$('#arrow').click( function() {
		var content = $(this).parent();
		if ( $(content).hasClass('open') ) {
			$('#home_box').slideUp('slow', function() {
				$(content).animate({ width: '320px' }, 500 );
				$(content).removeClass('open');
			});
		} else {
			$(content).animate({ width: '640px' }, 500, function() {
				$('#home_box').slideDown('slow');
				$(content).addClass('open');
			});
		}
		return false;
	});
	
	
	$("a.fancyimage").fancybox({
		'hideOnContentClick': true,
		'zoomSpeedIn': 300,
		'zoomSpeedOut':	300,
		'overlayOpacity':0.7,
		'overlayColor':'#000'
	});
	
	Date.format = 'yyyy-mm-dd';
	$('.date-pick').datePicker({ clickInput:true });
	
});

$(window).resize( function() {
	//setHeight();
});

function setHeight() {
	if ( $('#home').length == 1 ) {
		var wh = $(window).height();
		var ch = $('#container').height();
		var ct = 0;
		var bb = 0;
		if ( wh > ch ) {
			ct = ( wh / 2 ) - ( ch / 2 ) + 'px'
			bb = '-' + ( 1200 - wh ) / 2 + 'px';
		} else {
			ct = '20px'
			bb = '-290px';
		}
		$('#container').css( 'top', ct );
		$('body').css( 'background-position', '50% ' + bb );
	}
}

function slideTimeout( currElement, nextElement, opts, isForward ) {
	var st = $(currElement).find('img').attr('class').replace("t:", "");
	return ( st > 0 ? parseInt( st ) : opts.timeout );
} 
