$(document).ready(function() {
	
	// Auto clear search form input
	$('input,textarea').focus(function() { if($(this).val() == $(this).attr('title')) { $(this).val(''); } });
	$('input,textarea').blur(function() { if($(this).val() == '') { $(this).val($(this).attr('title')); } });
	
	// Hook menu hovers for ie6
	$('#header ul li, .buttons button').mouseenter(function() { $(this).addClass('hover'); });
	$('#header ul li, .buttons button').mouseleave(function() { $(this).removeClass('hover'); });
	
	// Starting slideshow
	$('.slideshow').tabs('.slideshow .items a', { 
		rotate: true, 
		effect: 'fade'
	}).slideshow({
		autoplay: true,
		interval: 3000
	});
	
	// Setting replaceing custom fonts on headings
	Cufon.set('fontFamily', 'Eurostile').replace('.awards-block h2')('.two-columns h1')('.two-columns .right-column h3')('.eu-stile');
	
	// Process rel="_blank"
	$('a[rel="_blank"]').click(function() {
		window.open($(this).attr('href'));
		return false;
	});
	
	// Starting Gallery
	$('a[rel=gallery], a[rel=spotlight]').fancybox();
	
	// Video Player
	$("#various5").live("click", function(){
		jQuery.fancybox({
			'width'				: 580,
			'height'			: 370,
	        'autoScale'     	: false,
	        'autoDimensions'    : false,
	        'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe',
			'href'              : $(this).attr('href')
		});
		return false;
	});
	
	// Starting AJAX Froms
	$('form.ajax').submit(function() {
		$(this).ajaxSubmit({ success: function( message ) {
			if(message != 'done') {
				$('.error-msg').text(message).fadeIn();
			} else {
				$('.error-msg').text(message).hide();
				$('form.ajax').hide();			
				$('#thank-you').fadeIn();			
			}
			return true;
        }});
        
		return false;
	});
});
