/* 
*
* Copyright(C): BeyondReason Hungary Kft - http://beyondreason.hu
* Minden jog fenntartva! All rights reserved! 
*
*/

	$("#items img[title]").tooltip({ 
	 
	    // place tooltip on the right edge 
	    position: "right", 
	 
	    // a little tweaking of the position 
	    offset: [180, 5], 
	 
	    // use the built-in fadeIn/fadeOut effect 
	    effect: "fade", 
	 
	    // custom opacity setting 
	    opacity: 0.9, 
	 
	    // use this single tooltip element 
	    tip: '.tooltip' 
	 
	});
	
	// execute your scripts when DOM is ready. this is a good habit 
	$(function() {         
	         
	    // initialize scrollable  
	    $("div.scrollable").scrollable({ 
	        vertical:true,  
	        size: 2 
	         
	    // use mousewheel plugin 
	    }).mousewheel();
		
		// Kapcsolat effekt indítása
		$("a[rel]").overlay({expose: '#000', effect: 'apple'});     
	     
	}); 
	
	// execute your scripts when DOM is ready. this is a good habit 
	$( document ).ready( function() {

		// Validate Contact form

		$( "#messageForm" ).validate();
		
		$( "#contact" ).click( function() {
			$( "#serverMsg" ).css( "visibility", "hidden" );
			$( "#name" ).attr( "value", "" );
			$( "#email" ).attr( "value", "" );
			$( "#message" ).attr( "value", "" );				
		});

		// Contact form handling of AJAX
		
		$( "#sendMessage" ).click( function() {			
			if ( $( "#name" ).val() != 0 && $( "#email" ).val() != 0 && $( "#message" ).val() != 0 ) {
				var data = "name=" + $( "#name" ).val() + "&email=" + $( "#email" ).val() + "&message=" + $( "#message" ).val() + "&sendMessage=";
				$.ajax({
					type: "POST",
					url: "index.php",
					data: data,
					cache: false,
					success: function( response ) {
						//alert(response);
						$( "#name" ).attr( "value", "" );
						$( "#email" ).attr( "value", "" );
						$( "#message" ).attr( "value", "" );						
						$( "#serverMsg" ).css( "visibility", "visible" );
						$( "#serverMsg" ).fadeOut(800).fadeIn(800).fadeOut(400).fadeIn(400).fadeOut(400).fadeIn(400);
					}
				});
				return false;
			}
		});
		
		// Menu animation
		
		$( "#mainmenu li a" ).wrapInner( '<span class="out"></span>' );
		
		$( "#mainmenu li a" ).each( function() {
			$( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
		});

		$( "#mainmenu li a" ).hover( function() {
			$( ".out",	this ).stop().animate({'top':	'32px'},	200); // move down - hide
			$( ".over",	this ).stop().animate({'top':	'0px'},		200); // move down - show

		}, function() {
			$( ".out",	this ).stop().animate({'top':	'0px'},		200); // move up - show
			$( ".over",	this ).stop().animate({'top':	'-32px'},	200); // move up - hide
		});		
		
	});
