a(document).ready(function(){

a("#subscrice").click(Subcr);
a("#titles").click(Title);
a("#document").click(Documents);
a("#photogallery").click(Cphotos);
a("#getZakaz").click(getPost);

function Subcr(){
		a("#sbut").button();
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#subscrr").dialog({
			modal: true,
			buttons: {
				Отмена: function() {
					a( this ).dialog( "close" );
				}
			}
			});
}

function Title(){
		//a("#sbut").button();
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#dialog-message6").dialog({
			modal: true,
			width: '850',
			height: '600',
			buttons: {
				Закрыть: function() {
					a( this ).dialog( "close" );
				}
			}
			});
			return false;
}

function Documents(){
		//a("#sbut").button();
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#dialog-message7").dialog({
			modal: true,
			width: '600',
			height: '400',
			buttons: {
				Закрыть: function() {
					a( this ).dialog( "close" );
				}
			}
			});
			return false;
}

function Cphotos(){
		//a("#sbut").button();
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#dialog-message8").dialog({
			modal: true,
			width: '750',
			buttons: {
				Закрыть: function() {
					a( this ).dialog( "close" );
				}
			}
			});
		return false;
}


function getPost(){
var country = a.trim(a("#country").val());
var date_in = a.trim(a("#date_in").val());
var date_out = a.trim(a("#date_out").val());
var number = a.trim(a("#number").val());
var hotel = a.trim(a("#hotel").val());
var people = a.trim(a("#mesta_people").val());
var childran = a.trim(a("#mesta_children").val());
var cost = a.trim(a("#cost").val());
var fio = a.trim(a("#fio").val());
var phone = a.trim(a("#phone").val());
var email = a.trim(a("#email").val());
var error = '';

	if(country == '0') { error += "&bull; Страна/маршрут<br/>" }
	if(date_in == '' || date_out == '') { error += "&bull; Сроки тура<br/>" }
	if(hotel == '0') { error += "&bull; Отель<br/>" }
	if(number == '0') { error += "&bull; Номер<br/>" }
	if(people == '0' || childran == '') { error += "&bull; Количества мест<br/>" }
	if(cost == '0') { error += "&bull; Цена<br/>" }
	if(fio == 'ФИО') { error += "&bull; ФИО<br/>" }
	if(phone == 'Телефон') { error += "&bull; Контактный телефон<br/>" }

	if(error != '')
	{

	a(function() {
		a("#compl-text").html(error);
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#dialog-message").dialog({
			modal: true,
			
			buttons: {
				Ok: function() {
					a( this ).dialog( "close" );
				}
			}
			});
		});
		return false;
	} else {
		//a("#o_butt").html("<input type='image' src='images/design/but_zakaz.png' name='zakaz' id='getZakaz' style='margin-left:48px;'/>")
		a("#getZakaz").css("display", "none");
		a("#z_load").css("display", "block");
		
		a.post("/addon/ajax.php", 
        {
        act: "geT",
        contr: country,
		date: date_in + "-" + date_out,
		numb: number,
		hote: hotel,
		peopl: people,
		child: childran,
		cos: cost,
		name: fio,
		phon: phone,
		mail: email
		},Load);
	}
	
	function Load(data) {
		a("#z_load").css("display", "none");
		a("#getZakaz").css("display", "block");
		a("#compl-text").html(data);
		a( "#dialog:ui-dialog" ).dialog( "destroy" );
		a("#dialog-message1").dialog({
			modal: true,
			buttons: {
				Ok: function() {
					a( this ).dialog( "close" );
					a("#country").val("0");
					a("#date_in").val("");
					a("#date_out").val("");
					a("#hotel").val("0");
					a("#number").val("0");
					a("#mesta_people").val("0");
					a("#mesta_children").val("");
					a("#cost").val("0");
					a("#fio").val("ФИО");
					a("#phone").val("Телефон");
					a("#email").val("E-mail");
				}
			}
			});
		
		//a("#o_butt").append(data);
		//a("#o_butt").html("<input type='image' src='images/design/but_zakaz.png' name='zakaz' id='getZakaz' style='margin-left:48px;'/>")
	}
return false;	
}

});
