

function formNamesYes(textId, fildName) {
    $("#" + textId).removeClass("red");    
    $("#" + textId).addClass("red");
    $("#" + textId).text(fildName);
}

function formNamesNo(textId, text) {
    $("#" + textId).removeClass("red");    
    $("#" + textId).addClass("red");
    $("#" + textId).text(text);
}

function remclass(){
	$('.contact').removeClass('newcontact');
}

function changeTextStyle(){
	$('.contact').addClass('newcontact');
	setTimeout ( "remclass()", 2000 );
}


$(document).ready(function(){  

/* - - - - - - - - - - - - - changetext - - - - - - - - - - - - - - - - -*/



	
/* - - - - - - - - - - - - - email - - - - - - - - - - - - - - - - -*/

    $('#emaila').focusout(function(){ 
        var value = $(this).val();
        var reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
        if (!value.match(reg)) {
            alert("Неправильный електронный адрес, попробуйте снова!");
        }
        
    });
    
/* - - - - - - - - - - - - - password - - - - - - - - - - - - - - - - -*/

    $('#reppassword').focusout(function(){
        var first = $('#passworda').val();
        var second = $('#reppassword').val();
        
        if (first != second) {
            alert('Пароли не совпали - попробуйте еще раз!');
        }
    });    
    $('.jscheck').focusout(function(){
    	$(this).parentsUntil('emptyfild').removeClass('emptyfild');
    });
	

});

function clearText(field){

    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;

}

var ghosts = new Array();
  	 ghosts[0] = 'Например: Сергей';
  	 ghosts[1] = 'Например: КиевБуд';
  	 ghosts[2] = 'Например: (097) 188 2117';
  	 ghosts[3] = 'Например: Киев';
  	 ghosts[4] = 'Например: kievbud@comp.com';

var checkfild1 = 0;
var checkfild2 = 0;
function checkinput(){
	for(var i=0; i<8; i++){
  	 	var data = $(".jscheck:eq("+i+")").val();
  	 	if (data == ""){ 
			$(".jscheck:eq("+i+")").parent().addClass('emptyfild'); 
			checkfild1 = 1;
  	 	}
  	 	if(data != "") {
  	 		for(var j=0; j<5; j++){
  	 			if(data == ghosts[j]){ 
  	 				$(".jscheck:eq("+i+")").parent().addClass('emptyfild'); 
  	 				checkfild2 = 1;
  	 			}
  	 		}
  	 	}
  	 }
  	 
  	 if( checkfild1 == 1 || checkfild2 == 1){
  	 	alert('Внимание! Не все обязательные поля заполнены!');
  	 	checkfild1 = 0;
  	 	checkfild2 = 0;
  	 }else{
  	 	$("#inputform").submit();
  	 	return false;
  	 }
}


















