																							// javascript для макета
// Библиотека jQuery подключена по умалчанию

jQuery(document).ready(function(){
	
	
		
	$("#menu li").hover(function(){
		$(this).find('ul:first').stop(true, true);
		$(this).find('ul:first').slideDown("fast");
		$(this).find('ul:first').css("display","block");
		
	},function(){
		$(this).find('ul:first').slideUp("fast");
		$(this).find('ul:first').css("display","none");
	});
	
	
	
	$("#registerNow").click(function(){
		pos = $(this).offset();
		showMessageMain("Вы будете автоматически зарегистрированы в системе при совершении любого заказа на нашем сайте", pos, 0);
	});
	$("#enterFormSubmit").click(function(){
		pos = $(this).offset();
		$.post("/account/", {enter:true, myLogin:$("#myLogin").val(), myPwd:$("#myPwd").val()}, function (data){
			if(data == 0){
				showMessageMain("Ошибка при авторизации", pos, 1);
			}else{
				location.href = "/account/";
			}
		});
	});
	
	
	$("#emailForgetBtn").live("click", function(){
		 $.post('/account/', {forgetPwd:true, e_mail: $("#emailForget").val()}, function(data){
		 	showMessageMain(data, false, 1)
		 });
	});
	
	$("#forgetPwd").click(function(){
		pos = $(this).offset();
		showMessageMain('<p>Для восстановления, укажите e-mail, указанный при регистрации. На этот адрес будут отправлены регистрационные данные</p><input type="text" value="" id="emailForget" /> <input type="button" value="Ок" id="emailForgetBtn" />', pos, 0);
	});
	
	$("a.close").click(function(){
		$("#showClientData").fadeOut(450);
	});
	
});


function showMessageMain(str, pos, hide){
	$("#showClientData div.data").html(str);
	$("#showClientData").css("left", pos.left+50+"px");
	$("#showClientData").css("top", pos.top-50+"px");
	$("#showClientData").fadeIn(450);
	if(hide) setTimeout(function(){$("#showClientData").fadeOut(450);}, 2000);
	
}


















