//var $ = jQuery.noConflict();
$(document).ready(function(){

		//Suckerfish
	$('#menu ul li:has(ul)').hoverIntent(function() {
		$('#menu ul li:has(ul)').not(this).children('ul').hide("normal");
		$(this).children("ul").show("normal");
	},
	function() {
		$('#menu ul li:has(ul)').not(this).children('ul').hide("normal");
	});
	
	$('#contentWrapper, #footer').click( function() {
		$('#menu ul li:has(ul)').children('ul').hide("normal");
	});

	//ScrollPane
	$('#content').jScrollPane();
	$('#contentArea').jScrollPane();
	
	//Slideshow
	
	$('#slideshow').cycle({ 
		fx:     'fade', 
		speed:   1000, 
		timeout: 3000
	 });
	 
	//fancyBox
	$("a.fancy").fancybox({ 
		'frameWidth'  : 720, 
		'frameHeight' : 600,
		'overlayShow' : true,
		'zoomOpacity' : true,
		'zoomSpeedIn' : 500,
		'zoomSpeedOut': 500,
		'padding'	  : 0	
	}); 
	
	//Newsletter form validation
	$("#newsletterForm form").submit(function() {
		if ( ( $("input#name").val() == "") || ($("input#name").val() == "Your name")) {
			//alert('Please type your name');
			$('span#valResult').html('Please type your name');
			return false;
		}
		if ( ( $("input#jrflt-jrflt").val() == "") || ($("input#jrflt-jrflt").val() == "Your email address")) {
			//alert('Please type your email address');
			$('span#valResult').html('Please type your email address');
			return false;
		} else {
			var rules  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if ($("input#jrflt-jrflt").val().match(rules)) {
				return true;
			} else {
				//alert('You povided wrong email address');
				$('span#valResult').html('Email address is not valid');
				return false;
			}
		}
    });

	$('#footerOuter a.crean_m').hoverIntent(function() { $('#logosPlaceholder img.crean_m').fadeIn(); },function() { $('#logosPlaceholder img.crean_m').fadeOut();});
	$('#footerOuter a.aston').hoverIntent(function() { $('#logosPlaceholder img.aston').fadeIn(); },function() { $('#logosPlaceholder img.aston').fadeOut();});
	
	$('img.hovers').hover(function() {
		var src = $(this).attr('src').match(/[^\.]+/) + '_hover.gif';
        $(this).attr('src', src);	
	},function() {
		var src = $(this).attr('src').replace('_hover', '');
		$(this).attr('src', src);
	});

	

}); //Close document.ready

$(window).bind("load", function() {
	$('#loading').hide();
	$('#slideshowWrapper').fadeIn('slow');
});


