$(document).ready(function ()
{
	//search
	$("#search")
		.bind("keypress", function(e)
		{
			if(e.which == 13 && $(this).attr("value"))
				document.location.href = "/search/" + encodeURI($(this).attr("value"));
		});
	$('table.search_table tr').hover(function()
		{
			$(' > td:first', this).css({background: "URL('/images/plus_b.gif') no-repeat 5px"});  
			$(' > td', this).css({background: "#eeeeee"});  
		}, function()
		{
			$(' > td', this).css({background: ""});
		})
	$('span.suchen_name').css('background', '#FF4040');
	$('span.suchen').css('background', '#FFFF00');
	$('table.search_table td a').click(function()
	{
		$('form[@name=search]').attr('action', $(this).attr('href')).submit();
		return false;
	});	
		
	//search button
	$('#getform').click
	(
		function() {
			if($('#search').attr('value') && $('#search').attr('value') != '')
				document.location.href = "/search/" + encodeURI($('#search').attr("value"));
		}
	);
	//drop-down-menu
	$('#nav').droppy();
	//reviews
	$('#check').hide();
	//lightbox
	$('a[@rel=lightbox]').css({textDecoration: "none", margin: "0px"}).lightBox({fixedNavigation:false});
	
	//form.php // reviews.php
	$('#quest_form').formValidation({
		alias     : 'name'
		,required : 'accept'
		,err_list : false
		,callback : 'success_form'
	});
	
	//site
	$('#nav li.main').hover(
		function() {
			var w = $(this).width();
			//alert($(this).width());
			if(w>80)
				$(this).css('background', 'url(/images/bg_hover.gif) no-repeat');	
			else if(w<80 && w>55)
				$(this).css('background', 'url(/images/bg_mhover.gif) no-repeat');	
			else
				$(this).css('background', 'url(/images/bg_mmhover.gif) no-repeat');	
			$(this).find('a').eq(0).css('color', '#fff').end();
		}, function() {
			$(this).css('background', 'url(/images/bg_menu.gif) no-repeat');
			$(this).find('a').eq(0).css('color', '#595959').end();
		}
	);
	$('#bron').formValidation({
		alias     : 'name'
		,required : 'accept'
		,err_list : false
		,callback : 'sender'
	});
	$('#main_links a').click(
		function(e) {
			$('#main_links a').css({textDecoration: 'underline', cursor: 'pointer'});
			$(this).css({textDecoration: 'none', cursor: 'text'});
			switch($(this).attr('name'))
			{
				case 'first':
					$('#block1:hidden').show();
					$('#block2:visible').hide();
				//	$('#phones').text('299-15-14 299-64-30 299-64-70');
					break;
				case 'second':
					$('#block2:hidden').show();
					$('#block1:visible').hide();
				//	$('#phones').text('201-22-90 201-24-63 201-24-82');
					break;
			}
		}
	);
});
function sender() {}
function nm(){
	if (document.nm_dost.reys1.value==""){
		document.nm_dost.dturk1.value="Без доставки";
		document.nm_dost.dturk2.value="Без доставки";
	}
	if (document.nm_dost.reys1.value==1){
		document.nm_dost.dturk1.value="Новосибирск";
		document.nm_dost.dturk2.value="Ареда-1";
	}
	if (document.nm_dost.reys1.value==2){
		document.nm_dost.dturk1.value="Новосибирск";
		document.nm_dost.dturk2.value="Золотое озеро";
	}
	if (document.nm_dost.reys1.value==3){
		document.nm_dost.dturk1.value="Барнаул";
		document.nm_dost.dturk2.value="Ареда-1";
	}
	if (document.nm_dost.reys1.value==4){
		document.nm_dost.dturk1.value="Барнаул";
		document.nm_dost.dturk2.value="Золотое озеро";
	}
	if (document.nm_dost.reys1.value==5){
		document.nm_dost.dturk1.value="Новосибирск";
		document.nm_dost.dturk2.value="Мустаг";
	}
	if (document.nm_dost.reys1.value==6){
		document.nm_dost.dturk1.value="Новосибирск";
		document.nm_dost.dturk2.value="Семинский перевал";
	}
	if (document.nm_dost.reys2.value==""){
		document.nm_dost.dturk_end1.value="Без доставки";
		document.nm_dost.dturk_end2.value="Без доставки";
	}
	if (document.nm_dost.reys2.value==1){
		document.nm_dost.dturk_end1.value="Ареда-1";
		document.nm_dost.dturk_end2.value="Новосибирск";
	}
	if (document.nm_dost.reys2.value==2){
		document.nm_dost.dturk_end1.value="Ареда-1";
		document.nm_dost.dturk_end2.value="Барнаул";
	}
	if (document.nm_dost.reys2.value==3){
		document.nm_dost.dturk_end1.value="Золотое озеро";
		document.nm_dost.dturk_end2.value="Новосибирск";
	}
	if (document.nm_dost.reys2.value==4){
		document.nm_dost.dturk_end1.value="Золотое озеро";
		document.nm_dost.dturk_end2.value="Барнаул";
	}
	if (document.nm_dost.reys2.value==5){
		document.nm_dost.dturk_end1.value="Мустаг";
		document.nm_dost.dturk_end2.value="Новосибирск";
	}
	if (document.nm_dost.reys2.value==6){
		document.nm_dost.dturk_end1.value="Семинский перевал";
		document.nm_dost.dturk_end2.value="Новосибирск";
	}
	document.nm_dost.submit()
}
function ddatas() {
	var today=new Date();
	var today_year=today.getYear();
	if (today_year<1900){today_year=today_year+1900;}
	var today_month=today.getMonth()+1;
	var gmonth=parseFloat(document.nm_dost.dmonth.value);
	var gdata=parseFloat(document.nm_dost.ddata.value);
	var gyear=today_year;
	if (gmonth<6 && today_month>7){gyear=gyear+1;}
	var data_n=new Date(gyear,gmonth-1,gdata);
	var data_k=new Date(gyear,gmonth-1,gdata+8);
	document.nm_dost.ddata_end.value=data_k.getDate();
	document.nm_dost.dmonth_end.value=data_k.getMonth()+1;
}
function tb_enter(){
	if (document.bron.tourbaza.value=='УКАЖИТЕ ТУРКОМПЛЕКС ИЛИ МАРШРУТ'){document.bron.tourbaza.value='';}
}
function tb_exit(){
	if (document.bron.tourbaza.value==''){document.bron.tourbaza.value='УКАЖИТЕ ТУРКОМПЛЕКС ИЛИ МАРШРУТ';}
}
