$(document).ready(function(){
	
	setup_labelover();
	$('a>img.showcase').parent().fancybox({
		'hideOnContentClick': true,
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'speedIn': 600,
		'speedOut': 600
	});
	$('a.noscript').children('').unwrap();
	$('ul#showcase li').css('display', 'block').fadeOut(10, function(){
		$('ul#showcase li.selected').fadeIn(250);
	});

});


function get_content( url ) {
	$('#content').fadeOut(400, function(){
		$('#content').load( url, function(){
			setup_labelover();
			$('.price').focus(function(){
				$(this).mask( $(this).attr('label') + ': 9,999 EUR');
			});
			$('.price').blur(function(){
				$(this).unmask();
			});
			$('#content').fadeIn(400);
		} );
	} );
}


function showcase( id ) {
	$('ul#showcase li.selected').stop().fadeOut(250, function(){	$(this).removeClass( 'selected' );	});
	$('ul#showcase li'+ id).addClass( 'selected' ).stop().fadeIn(250);
}


function setup_labelover() {
	$('input[type="text"], input[type="password"], textarea').each(function(){
		if( $(this).attr('label') )
			labelover( $(this), $(this).attr('label') );
	});
}


function labelover( element, title ) {
	var color_label = '#AAA';
	var color_text = '#000';

	if( element.is('textarea') ) {
		if( element.text() == '' )
			element.text(title).css( 'color', color_label );
		element.focus(function(){
			if( $(this).text() == title )
				$(this).text('').css( 'color', color_text );
		});
		element.blur(function(){
			if( $(this).text() == '' )
				$(this).text(title).css( 'color', color_label );
		});
	}
	else if( element.is('input') ) {
		if( element.val() == '' )
			element.val(title).css( 'color', color_label );
		element.focus(function(){
			if( $(this).val() == title )
				$(this).val('').css( 'color', color_text );
		});
		element.blur(function(){
			if( $(this).val() == '' )
				$(this).val(title).css( 'color', color_label );
		});
	}
}
