$(document).ready(function(){

$(".switch img").click(switchit);
$("#auth input[name='Login']").defaultvalue("логин");
$("#auth input[name='Password']").defaultvalue("пароль");
$("#logout").click(function(){ 
	
		$.ajax({
			   type: "POST",
			   dataType: "json",
				url: '/register/?mode=json_do_logout', 
			   complete: function(data){$("#profile, #auth").toggle(); }
			 });
	
		return false;});

var options = { 
        //beforeSubmit:  validator,  
       success:        function(data) { if(data["error"]) alert("Пользователь с таким логином и паролем не обнаружен"); 
       		else
       			{
       				$("#CustomerName").html(data["Name"]);
       				$("#profile, #auth").toggle();
       				
       				}
       	
       	},
       error:      function() { alert("Ошибка при обработке данных")},
		url: '/register/?mode=json_do_login', 
       type:      "post", 
       dataType:  "json"
        	};
 
	$("#auth_form").ajaxForm(options);	


	
});


function switchit()
{
	if($(this).attr("state")=="open") 
		$(this).attr("state", "close").attr("src", "img/plus.gif");
	else
		$(this).attr("state", "open").attr("src", "img/minus.gif");
		
	$("#"+this.id+"_small").toggle();
	$("#"+this.id+"_full").toggle();
}

function draw_hotel_images(images)
{
 var html = '<div class="image"><img src="'+images[0]+'" width="250" id="main_image"></div>';
 if(images.length>1)
 {
 	html +='<table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>';
	html +='<td align="left" width="33%" >' + ((images[0]) ?  '<img src="'+images[0]+'" class="thumb" width="75" height="75">' : "") + '</td>';
 	html +='<td align="center" width="34%" >' + ((images[1]) ?  '<img src="'+images[1]+'" class="thumb" width="75" height="75">' : "") + '</td>';
 	html +='<td align="right"  width="33%">' + ((images[2]) ?  '<img src="'+images[2]+'" class="thumb" width="75" height="75">' : "") + '</td>';
 	
 	html+="</tr></table>"
}
	$(".thumb", $("#image_gallery").append(html)).click(function(){$("#main_image").attr("src", this.src);});
}