/**
 * @author maximvo
 */
function init()
{
	var h = Math.round($(window).height() - $('#header').height() - $('#main').height());
	if (h > 137)
	{
		h = Math.round($(window).height(),10) - 177 - Math.round($('#header').height(),10);
		if (h > $('#main').height()) 
		{
			$('#main').height(h);
		}
	}
	
	$("#fname").focus(
		function()
		{	
			if ($(this).val() == 'Name')
			{		
				$(this).val('');
			}
		}
	);
	$("#fname").blur(
		function()
		{	
			if (!$(this).val())
			{
				$(this).val('Name');
			}
		}
	);
	$("#email").click(
		function()
		{
			if ($(this).val() == 'Email')
			{		
				$(this).val('');
			}
		}
	);
	$("#email").blur(
		function()
		{	
			if (!$(this).val())
			{
				$(this).val('Email');
			}
		}
	);
	$("#info").click(
		function()
		{
			if ($(this).val() == 'Comments & questions')
			{		
				$(this).val('');
			}
		}
	);
	$("#info").blur(
		function()
		{	
			if (!$(this).val())
			{
				$(this).val('Comments & questions');
			}
		}
	);
	var timer;
    $(".headermenu li").hover(
        function()
        { 
        	clearTimeout(timer);
        	$("ul", this).slideDown("fast"); 
       	}, 
        function() 
        {
        	var element = this;
        	timer = setTimeout(
        				function()
        				{
        					$("ul", element).slideUp("fast"); 
        				},1000);
        } 
    );
    
    //$(".hasubmenu").hoverClass ("sfHover");
	
	$("#toeyal, #tomaxim, #tooded").click(function(){
		$("#toeyal, #tomaxim, #tooded").css("text-decoration","none");
		var elem = $(this);
		$("#emailto").val(elem.attr("id"));
		elem.css("text-decoration","underline");
		$("#fname").focus();
		return false;
	});   	
}

/*$.fn.hoverClass = function(c) {
    return this.each(function(){
        $(this).hover( 
            function() { $(this).addClass(c);  },
            function() { $(this).removeClass(c); }
        );
    });
};*/

function checkForm()
{
	$(".error").removeClass("error");
	var error = 0;
	if (!$("#fname").val() || $("#fname").val() == 'Name')
	{
		error = 1;
		$("#fname").addClass("error");
	}
		
	if ($("#email").val().length == 0 || $("#email").val().indexOf("@") == -1)
	{
		error = 1;
		$("#email").addClass("error");
	}
	if (!error)
	{
		return true;
	}
	return false;
}
$(document).ready(init);
