//var $J = jQuery.noConflict();
function isValidEmail(email) 	{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(email) == false)
	{
		return false;
	}
return true;
}
jQuery(document).ready(function(){
	jQuery("a.lightbox").lightBox();
    
	//$('.tracks').cornerz({radius: '20', background: '#0f0f0f'});
	
    /*$('a').focus(function(){
        $(this).blur();
    });*/
    
    $("#feedback_wrapper").fadeTo(0, 0.8);
    
    $("#feedback a").click(function(){
        $("#feedback_wrapper").height($(document).height()).show(500);
        $("#feedback_form").show(500);
        return false;
    });
    
    $("#close").click(function(){
        $("#feedback_wrapper, #feedback_form").hide(500);
    });
	$('.btn').live('click',function(e){
	var error = "";
	if($(this).attr('id') == 'send_feed') var that = '#get_it';
	else var that = '#f_form';
	var name  = $(that).find('#name_input').val();
	var email = $(that).find('#email_input').val();
	var phone = $(that).find('#phone_input').val();
	var text  = $(that).find('#question_input').val();
	if(isValidEmail(email) !== true){
	error += "Неверный формат E-Mail. \n";
	}
	if(name ==""){ error += "Не заполнено поле Имя. \n";}
	if(text ==""){ error += "Не заполнено поле Вопрос.";}
	if(error !=="")
	alert(error);
	else{
		$.get('/ru/q/',{email: email, name: name, phone: phone, text:text},
				function(data){
					if (data!=0) {
							$(that).find('#name_input').val("");
							$(that).find('#email_input').val("");
							$(that).find('#phone_input').val("");
							$(that).find('#question_input').val("");
						alert(data);
					}
				});
		}
		return false;
	});	    
});

$(window).resize(function(){
});
