var check_captcha = false;
var curStatus ='';
var url = window.location.host;

/**
  * @descr Submit the partner form
  */
function funcSubmit( val )
{
	error='';
	check_captcha = false; 
    $("#check_captcha").html("<font color='red'>verification...</font>");
    
    if( $("#name").val() == '' ) 
    {
        error = error + "<font color='red'>Your name cann't be empty</font><br />";
    }
    
    if( $("#hotel_name").val() == '' ) 
    {
        error = error + "<font color='red'>Hotel name cann't be empty</font><br />";
    }

    if( $("#email").val() == '' ) 
    {
        error = error + "<font color='red'>Email cann't be empty</font><br />";
    }
    else
    {   
        if (!validateEmail($("#email").val()))
        {
            error = error + "<font color='red'>Incorrect e-mail</font><br />"; 
        }
    }
    
    if( $("#imgcode").val() == '' ) 
    {
        error = error + "<font color='red'>Security code cann't be empty</font><br />";
        $("#check_captcha").html("");
    }
    else
    {
        $.post(
            "http://"+url+"/check_captcha.php",
            { 
                code: $("#imgcode").val() 
            },
            function( data )
            {
                if( data == '0' )
                {
                    $("#check_captcha").html("<font color='red'>Security code is incorect</font>");
                    check_captcha = false;
                }
                if (data == '1')
                {
                    $("#check_captcha").html("<font color='red'>right</font>");
                    check_captcha = true;
                    if ( error == '' )
                    {
                        $("form").submit();
                    } 
                }
            }
        );
    }

	if (( error == '' ) && (check_captcha == true))
	{
		$("form").submit();
	}
	else
	{
		$("#errors").html(error);
	}
}