//on page load
$(document).ready(function() {
	
	//superfish
	$('ul.sf-menu').superfish({
		autoArrows: 	false,
		dropShadows: 	false,
		speed: 			100,
		delay: 			400, 
		animation:     {opacity:'show'}
	});
	
	//clear the search box words when focused
	$("#search-keywords").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	//clear the search box words when focused
	$(".search-keywords").focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
	
	//show login box on mouseover
	$('#top_menu li.login').click(
		function() {
			//show the box on click
			$('#login-box-wrapper').show();
	});
	
	$('#login-box-wrapper .close').click(
		function() {
			//hide the box on click
			$('#login-box-wrapper').hide();
		});
	
	//trigger validation
	$('#login_form').validate({
	
		rules: {
		   username: {
				required: true,
				email: true
			},
			password: "required"
		  }
		
	});
	
	//external links
	$('A[rel="external"]').click( function() {
	        window.open( $(this).attr('href') );
        return false;
    });
	
	//preload login images
	$.preload([ 'login_form_top_bg', 'login_form_bottom_bg', 'login_form_bg' ], {
	    base:'images/layout/',
	    ext:'.png'
	});
	
});
