
	function createCookie(name,value,days) {
		if (days) {
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name) {
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}

	
	function mnu_collaptor(elemID)
	{
		var imgID = 'image'+elemID;
		var aID = 'a'+elemID;
		var elemID = 'mnu_n'+elemID;
		
		
		state = document.getElementById(elemID).style.display;
		if('none'==state|| ''==state)
		{
			document.getElementById(elemID).style.display='block';
			document.getElementById(imgID).src='/templates/'+theme_name+'/img/minus.gif';
			document.getElementById(aID).style.fontWeight="bold";
			createCookie(elemID,1);
		}
		else
		{
			document.getElementById(elemID).style.display='none';
			document.getElementById(imgID).src='/templates/'+theme_name+'/img/plus.gif';
			document.getElementById(aID).style.fontWeight="normal";
			createCookie(elemID,0);
		}
	}
	
	function mnu_restorestate()
	{
		for(var i=0; i<document.cookie.length; i++)
			if (1==readCookie('mnu_n'+i))
			{
				document.getElementById('mnu_n'+i).style.display='block';
				document.getElementById('image'+i).src='/templates/'+theme_name+'/img/minus.gif';
				document.getElementById("a"+i).style.fontWeight="bold";
			}
	}

	function gotospec (step) 
		{
			history.go(-step);
		}

	function go_to_page(page_url)
	{
		top.location.href=page_url;
	}

	function func_save()
	{
		createCookie('spec',2);
		if (document.getElementById('my_textarea_id')){XBB.form_submit();}
		document.forms.main_form.submit();
	}

	function func_apply()
	{
		createCookie('spec',1);	
		if (document.getElementById('my_textarea_id')){XBB.form_submit();}
		document.forms.main_form.submit();
	}

	function response_check()
	{
		
		var warn_text;
		warn_text=0;
		$('#form_name_warn').html('');
		$('#form_city_warn').html('');
		$('#form_email_warn').html('');
		$('#form_text_warn').html('');	
		$('#form_code_warn').html('');	

		if ($('#form_name').attr('value')=='')
		{
			warn_text=1;
			$('#form_name_warn').html('Введите имя');
		}

		if ($('#form_city').attr('value')=='')
		{
			warn_text=1;
			$('#form_city_warn').html('Введите город');
		}

		if ($('#form_email').attr('value')=='')
		{
			warn_text=1;
			$('#form_email_warn').html('Введите Ваш e-mail');
		}else
		{
			value=$('#form_email').attr('value');
			reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
			if (!value.match(reg)) 
			{
				warn_text=1;
				$('#form_email_warn').html('Введите корректный e-mail');
			}
		}
		
		if ( $('#form_text').attr('value')=='')
		{
			warn_text=1;
			$('#form_text_warn').html('Введите текст');
		}
		if ( $('#form_code').attr('value')=='')
		{
			warn_text=1;
			$('#form_code_warn').html('Введите защитный код');
		}

		if(warn_text==0)
		{
			document.forms.response_form.submit();
		}

		
	}


	function book_check()
	{
		
		var warn_text;
		warn_text=0;
		$('#form_name_warn').html('');


		$('#form_mobtel_warn').html('');
		$('#form_login_warn').html('');
		$('#form_password_warn').html('');
		$('#form_password2_warn').html('');

		if ($('#form_name').attr('value')=='')
		{
			warn_text=1;
			$('#form_name_warn').html('Введите имя');
		}




		
		if ( $('#form_mobtel').attr('value')=='')
		{
			warn_text=1;
			$('#form_mobtel_warn').html('Введите телефон');
		}
		if ( $('#form_code').attr('value')=='')
		{
			warn_text=1;
			$('#form_code_warn').html('Введите защитный код');
		}
	if (document.getElementById('form_login'))
	{
		if ( $('#form_login').attr('value')!='')
		{
			
		
		if ( $('#form_password').attr('value')=='')
		{
			warn_text=1;
			$('#form_password_warn').html('Введите пароль');
		}
		if ( $('#form_password2').attr('value')=='')
		{
			warn_text=1;
			$('#form_password2_warn').html('Введите пароль');
		}
		if ( $('#form_password2').attr('value')!=$('#form_password').attr('value'))
		{
			warn_text=1;
			$('#form_password2_warn').html('Пароль должен совпадать');
		}
		}
	}
		if(warn_text==0)
		{
			document.forms.book_form.submit();
		}

		
	}
	
			jQuery(function(){
			// main navigation init
			jQuery('ul.sf-menu').supersubs({ 
				  minWidth:    10,   // minimum width of sub-menus in em units 
				  maxWidth:    1000,   // maximum width of sub-menus in em units 
				  extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
								 // due to slight rounding differences and font-family 
			}).superfish();
			jQuery('ul.sf-menu').superfish({
				animation:   {opacity:'show', height:'show'}
			});
		});

			$(document).ready(function(){
				$("area[rel^='prettyPhoto']").prettyPhoto();
				
				$(".gallery_in:first a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'normal',theme:'light_rounded',slideshow:3000, autoplay_slideshow: false});
				$(".gallery_in:gt(0) a[rel^='prettyPhoto']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});
		
				$("#custom_content a[rel^='prettyPhoto']:first").prettyPhoto({
					custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
					changepicturecallback: function(){ initialize(); }
				});
				$("#custom_content a[rel^='prettyPhoto']:last").prettyPhoto({
					custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
					changepicturecallback: function(){ _bsap.exec(); }
				});
				
				
							jQuery('#slider').nivoSlider({
				effect: 'slideInRight',
				animSpeed:500,
				pauseTime:5000,
				startSlide:0,
				slices:15,
				directionNav:false,
				directionNavHide:false,
				controlNav:true,
				controlNavThumbs:false,
				keyboardNav:true,
				pauseOnHover:true,
				captionOpacity:0.8			});
				
			});
		
