$(function() {
	$("#menu").lavaLamp({
		fx: "backout",
		speed: 800//,
		//  click: MenuClick
		// function(event, menuItem) {
		//       return false;
		// }
	});
	
	$(".current").hover(function() {

		$("#menu_glow").stop().animate({ opacity:1.0}, 200);
		
		

		}, function() {

		$("#menu_glow").stop().animate({ opacity:0.6}, 200);
	});
	$("#menu_glow").hover(function() {

		$("#menu_glow").stop().animate({ opacity:1.0}, 200);
		
		

		}, function() {

		$("#menu_glow").stop().animate({ opacity:0.6}, 200);
	});
	
	$("#dentry").hover(function() {

		$("#header_glow").stop().animate({ opacity:1.0}, 200);
		
		

		}, function() {

		$("#header_glow").stop().animate({ opacity:0.6}, 200);
	});
	
	$("#crabim").mousedown( function() {

		$(this).stop().animate({ width:54, height:54}, 50);
	});
	$("#crabim").mouseup( function() {

		$(this).stop().animate({ width:57, height:57}, 50);
	});
	
	
	/*
	$("#phone").hover(function() {

		$("#showphone").fadeIn(300);
		
		

		}, function() {

		$("#showphone").fadeOut(300);
	});
	*/
	
	$("a.fancy").hover(function() {

		$(this).animate({opacity:0.6}, 200);
		
		

		}, function() {

		$(this).animate({opacity:1.0}, 200);
	});
	
	
	var inps = $("#feedback .input");
	
	$("#feedback").submit(function(event){
		event.preventDefault();
		
		var _form = $(this),
			isCanSend = true;
		
		inps.parent().parent().removeClass().addClass("input-outer1");
		
		if(!inps.eq(0).val()){
			isCanSend = false;
			inps.eq(0).parent().parent().removeClass().addClass("input-outer3");
		}else{
			inps.eq(0).parent().parent().removeClass().addClass("input-outer2");
		}
		
		if(inps.eq(1).val()) inps.eq(1).parent().parent().removeClass().addClass("input-outer2");
		if(inps.eq(2).val()) inps.eq(2).parent().parent().removeClass().addClass("input-outer2");
		
		if(!inps.eq(1).val() && !inps.eq(2).val()){
			isCanSend = false;
			inps.eq(1).parent().parent().removeClass().addClass("input-outer3");
			inps.eq(2).parent().parent().removeClass().addClass("input-outer3");
		}
		
		if(!isCanSend) return false;
		
		var data_url = _form.attr('action');
			data_name  = _form.find('input[name="name"]').val(),
			data_email = _form.find('input[name="email"]').val(),
			data_phone = _form.find('input[name="phone"]').val(),
			data_text  = _form.find('textarea[name="text"]').val();
		
		$.ajax({
			type: 'POST',
			url: data_url,
			data: {
				action: 'send',
				name: data_name,
				email: data_email,
				phone: data_phone,
				text: data_text
			},
			success: function(data){
				console.log(data);
				$(".block1-feedback-cont", _form).html($.trim(data));
				$(".block1-feedback-cont").unbind('mouseenter');
				$(".block1-feedback-cont").unbind('mouseleave');
				$(".tofade").fadeTo(100, 1.0);
			},
			dataType: 'html'
		});
	});
});

function redirectPage() {
	window.location = linkLocation;
}

var linkLocation;

function MenuClick (event, menuItem)
{
	event.preventDefault();
	linkLocation = $(menuItem).find('a').attr('href');
	if ($(menuItem).find('a').attr('id') =='port')
	{
		$('#menu_glow').fadeOut(200, mov3);
		
	}
	if ($(menuItem).find('a').attr('id') =='serv')
	{
		$('#menu_glow').fadeOut(200, mov2);
		
	}
	if ($(menuItem).find('a').attr('id') =='main')
	{
		$('#menu_glow').fadeOut(200, mov1);
		
	}
	if ($(menuItem).find('a').attr('id') =='cont')
	{
		$('#menu_glow').fadeOut(200, mov4);
		
	}
}
function mov3()
{
	$('#menu_glow').removeClass('four');
	$('#menu_glow').addClass('three');
	$('#menu_glow').fadeIn(200, redirectPage);
}
function mov4()
{

	$('#menu_glow').addClass('four');
	$('#menu_glow').fadeIn(200, redirectPage);
}
function mov2()
{
		$('#menu_glow').removeClass('four');
			$('#menu_glow').removeClass('three');
	$('#menu_glow').addClass('two');
	$('#menu_glow').fadeIn(200, redirectPage);
}
function mov1()
{
		$('#menu_glow').removeClass('four');
			$('#menu_glow').removeClass('three');
				$('#menu_glow').removeClass('two');
	$('#menu_glow').addClass('one');
	$('#menu_glow').fadeIn(200, redirectPage);
}
