function documentLoad(){
   $("[name='msg']").attr('value','Введите что-нибудь...');
   $("[name='msg']").css("color", "#777777");
   $("[name='msg']").focus( function(){
        if ($(this).attr('value') == 'Введите что-нибудь...'){
                $(this).attr('value','');
                $(this).css("color", "#000000");
        }
   });
   $("[name='msg']").blur( function(){
        if (!$(this).attr('value')){
                $(this).attr('value','Введите что-нибудь...');
                $(this).css("color", "#777777");
        }
   });
/*   $("[name='tel']").attr('value','+7 495 789 99 09');
   $("[name='tel']").css("color", "#777777");
   $("[name='tel']").focus( function(){
        if ($(this).attr('value') == '+7 495 789 99 09'){
                $(this).attr('value','')
                $(this).css("color", "#000000")
        }
   });
   $("[name='tel']").blur( function(){
        if (!$(this).attr('value')){
                $(this).attr('value','+7 495 789 99 09')
                $(this).css("color", "#777777")
        }
   });*/
   $("[name='fio']").attr('value','Имя Фамилия');
   $("[name='fio']").css("color", "#777777");
   $("[name='fio']").focus( function(){
        if ($(this).attr('value') == 'Имя Фамилия'){
                $(this).attr('value','')
                $(this).css("color", "#000000")
        }
   });
   $("[name='fio']").blur( function(){
        if (!$(this).attr('value')){
                $(this).attr('value','Имя Фамилия')
                $(this).css("color", "#777777")
        }
   });
   $('[name=email]').attr('value','Введите свой E-Mail');
   $('[name=email]').css("color", "#777777");
   $("[name='email']").focus( function(){
        if ($(this).attr('value') == 'Введите свой E-Mail'){
                $(this).attr('value','')
                $(this).css("color", "#000000")
        }
   });
   $("[name='email']").blur( function(){
        if (!$(this).attr('value')){
                $(this).attr('value','Введите свой E-Mail')
                $(this).css("color", "#777777")
        }
   });

}
function sendMail(obj)
{
	var str='Проверьте правильность ввода поля: ';
	$("[name=fio]").css('border','');
        $("[name=tel]").css('border','');
        $("[name=email]").css('border','');
        $("[name=msg]").css('border','');
	if (
//!$("[name=fio]").attr('value').match(/\w/) ||
		$("[name=fio]").attr('value').indexOf(' ')==-1 ||
		$("[name=fio]").attr('value')=='Имя Фамилия'){
		alert(str+'"Имя и фамилия"');
		$("[name=fio]").css('border-color','red');
                $("[name=fio]").focus();
		return false;
	}
/*        if (!$("[name=tel]").attr('value').match(/\d/) ||
		!$("[name=tel]").attr('value').match(/^[\d\(\) \+\-]+$/) ||
		$("[name=tel]").attr('value')=='+7 495 789 99 09'){
                alert(str+'"Контактный телефон"');
                $("[name=tel]").css('border-color','red');
                $("[name=tel]").focus();
		return false;
        }*/
//        if (!$("[name=email]").attr('value').match(/^[\-\_\w\d]+\@[\-\_\w\d]+\.[\-\_\w\d\.]+$/)){
//                alert(str+'"E-Mail"');
//                $("[name=email]").css('border-color','red');
//                $("[name=email]").focus();
//                return false;
//        }
        if ($("[name=msg]").attr('value').length<2 ||
		$("[name=msg]").attr('value')=='Введите что-нибудь...'){
                alert(str+'"Текст сообщения"');
                $("[name=msg]").css('border-color','red');
                $("[name=msg]").focus();
                return false;
        }
        $("#loading").css('display','');
        $("#submit_btn").attr('disabled',1);
        $.post(obj.action, $('#mailform').serialize(),
function(data)
        {
		$('#loading').css('display','none');
	        $("#submit_btn").attr('disabled',0);
                if (data == 'yes')
                {
                        alert('Сообщение успешно отправлено.')
                        $("[name='fio']").attr('value','')
                        $("[name='tel']").attr('value','')
                        $("[name='email']").attr('value','')
                        $("[name='msg']").attr('value','')
//                        tb_remove()
                }
                else
                {
                        alert("Не удалось отправить сообщения.\nПожалуйста, повторите попытку позже.");
                }
        });
//        setTimeout("$('#loading').css('display','none');",500);
        return false;
}


