function returnFalse() { return false; };
$(document).ready(function(){	
	// +-+-+-+-+-+- LIST PAGE

			$('.textItem').hide();
			$('#item1').slideDown('slow');
			$('#items h3').click(function() {

				if ($(this).next('.textItem:visible').length != 0)
				{
					$(this).next('.textItem').stop().slideUp('slow');
				}			
				else 
				{
					$('.textItem').slideUp('slow');
					$(this).next('.textItem').stop().slideDown('slow');
				}
			});

			$('#items h3').mouseover(function(){
				$(this).stop().fadeTo('fast', 0.9);								  
			});
			
			$('#items h3').mouseout(function(){
				$(this).stop().fadeTo('slow', 1);								  
			});

	// ***** PROMO BOX
	
	$('.promoBox').mouseover(function(){
		$(this).stop().fadeTo('slow', 0.8);								  
	});
	
	$('.promoBox').mouseout(function(){
		$(this).stop().fadeTo('slow', 1);								  
	});


	/* -++-+-+-+-+-+-+- CONTACT FORM +-+-+-++-+-+- */
	
	$('#submit .button').bind('click', returnFalse);
	var firstName = false;
	var lastName = false;
	var emailFrom = false;
	
	$('#txtFirstName').blur(function(){
		if ($('#txtFirstName').val() == '')
		{
			$('#alertFirstName').append('<p class="red">* Your first name is requested</p>');
			firstName = false;
		}
		else {
			$('#alertFirstName').append('<p class="green">* Field first name completed</p>');	
			firstName = true;
		}		

		if (emailFrom && lastName && firstName)
		{
			$('#submit .button').unbind('click', returnFalse);
		}		
	});

	$('#txtLastName').blur(function(){
		if ($('#txtLastName').val() == '')
		{
			$('#alertLastName').append('<p class="red">* Your last name is requested</p>');	
			lastName = false;
		}
		else {
			$('#alertLastName').append('<p class="green">* Field last name completed</p>');	
			lastName = true;
		}		

		if (emailFrom && lastName && firstName)
		{
			$('#submit .button').unbind('click', returnFalse);
		}	
	});

	var filter=/^.+@.+\..{2,3}$/;
	$('#txtEmailFrom').blur(function(){
		if ($('#txtEmailFrom').val() == '')
		{
			$('#alertEmailFrom').append('<p class="red">* The field email is requested</p>');	
			emailFrom = false;
		}
		else if (filter.test($('#txtEmailFrom').val())) {
			$('#alertEmailFrom').append('<p class="green">* Field email is completed</p>');	
			emailFrom = true;
		}
		else {
			$('#alertEmailFrom').append('<p class="orange">* Please enter a valid email address</p>');	
			emailFrom = false;
		}		
		
		if (emailFrom && lastName && firstName)
		{
			$('#submit .button').unbind('click', returnFalse);
		
		}	
	});


	$('#txtEmailFrom').focus(function(){
		$('#alertEmailFrom').empty();	
	});	
	
	$('#txtFirstName').focus(function(){
		$('#alertFirstName').empty();	
	});		

	$('#txtLastName').focus(function(){
		$('#alertLastName').empty();	
	});	
	
	$('#submit .button').click(function(){
	  if (emailFrom && lastName && firstName)
	  {
	 	$('#submit .button').unbind('click', returnFalse);
	  }
	 
	});	
	
// +-+-+-+-+-+-+-+- TOP IMAGE 	
	var currentTopImage = $('#imageTopImage01');
	var direction = 'next';
	var timer = setInterval (function () {
		if (currentTopImage.attr('id') != undefined )
		{		
		//alert(direction);
		//alert(currentTopImage.prev('.imageTopImage').attr('class'));
		if ((currentTopImage.next('.imageTopImage').attr('class') == undefined) || ((direction == 'previous') && (currentTopImage.prev('.imageTopImage').attr('class') != undefined)))
		{
			
			
			currentTopImage = currentTopImage.prev('.imageTopImage'); 
			currentTopImage.show(function(){currentTopImage.fadeTo('slow', 1);});
			direction = 'previous';
		}
		else
		{
			currentTopImage.fadeTo('slow', 0, function(){$(this).hide();});
			currentTopImage = currentTopImage.next('.imageTopImage');
			direction = 'next'; 
			
			
		}
		}
		
	}, 3000 ); 


// +-+-+-+-+-+-+-+- GALLERY IMAGE 	
	var currentGalleryImage = $('#imageGalleryImage01');
	var direction = 'next';
	var timerTwo = setInterval (function () {
		if (currentGalleryImage.attr('id') != undefined )
		{
		
		if ((currentGalleryImage.next('.imageGalleryImage').attr('class') == undefined) || ((direction == 'previous') && (currentGalleryImage.prev('.imageGalleryImage').attr('class') != undefined)))
		{
			
			currentGalleryImage = currentGalleryImage.prev('.imageGalleryImage'); 
			currentGalleryImage.show(function(){currentGalleryImage.fadeTo('slow', 1);});
			direction = 'previous';
		}
		else
		{
			currentGalleryImage.fadeTo('slow', 0, function(){/*$(this).hide();*/});
			currentGalleryImage = currentGalleryImage.next('.imageGalleryImage');
			direction = 'next'; 
			
		}	
		
		}
		
	}, 2000 ); 


// ++-+-+-+- HORIZONTAL && VERTICAL BOXES

	$('.boxContainer').mouseover(function(){$(this).stop().fadeTo('fast',0.7)});
	$('.boxContainer').mouseout(function(){$(this).stop().fadeTo('slow',1)});


// ++-+-+-+- MAIN MENU

	$('.MMlink').mouseover(function(){								  
		$(this).children('img').stop().animate({top: '80px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$(this).children('img').attr('src','/medias/mainMenu/green'+id+'.png');
	});
	$('.MMlink').mouseout(function(){								  
		$(this).children('img').stop().animate({top: '90px'},{queue:false, duration:200, easing: 'easeInOutExpo'});
		id = $(this).attr('id');
		id= id.substring(id.length - 2, id.length);	 
		$(this).children('img').attr('src','/medias/mainMenu/white'+id+'.png');		
	});
});




