var winWidth = jQuery(window).width(), winHeight = jQuery(window).height(), windowResizeTimeout;
var width=screen.width/2;
jQuery(document).ready(
	function()
	{ 
            
            
            
        jQuery("#pikame").PikaChoose({carousel:true});
        
        
        jQuery('#twitter_widget').floating_panel({
        'fromCenter': width,
        'fromTop': 50,
        'minTop': 200,
        'location': 'left'
    });
        
jQuery("#contacts").mouseenter(function()
		{
			if (jQuery("#contacts-text").attr("class")=="")
			{
				var wWidth = jQuery(window).width();
				var wHeight = jQuery(window).height();
				if (wHeight<jQuery("#contacts").offset().top+430)
					jQuery(this).css({"width":370+"px","height":(wHeight-jQuery("#contacts").offset().top)+"px","left":wWidth-370+"px"});
				else
					jQuery(this).css({"width":370+"px","height":430+"px","left":wWidth-370+"px"});
				
				jQuery("#contacts-text").attr("class","visible").show();
			}
			
		});

		jQuery("#contacts").mouseleave(function()
		{
			if (jQuery("#contacts-text").attr("class")=="visible")
			{
				jQuery("#contacts-text").attr("class","").hide();
				jQuery("#contacts").css({"left":jQuery(window).width()-40+"px","width":40+"px","height":142+"px"});
			}
		});
                
                	// Contacts but
	if (jQuery("#contacts-text").attr("class")=="")
	{
		jQuery("#contacts").css({"left":jQuery(window).width()-40+"px","width":40+"px","height":142+"px"});
		if (jQuery(window).height()<530)
			jQuery("#contacts").css({"top":100+"px"});
		else
			jQuery("#contacts").css({"top":Math.round($(window).height()/2-150)+"px"});
	}
	
	jQuery("span[class='price_but']:first").click();

	jQuery('#content').jScrollPane(
	{
		showArrows: true
	});
	
	wWidth = jQuery(window).width();
	wHeight = Math.round(oHeight*wWidth/oWidth);
	
	// Contacts but
	if (jQuery("#contacts-text").attr("class")=="")
	{
		jQuery("#contacts").css({"left":jQuery(window).width()-40+"px","width":40+"px","height":142+"px"});
		if (jQuery(window).height()<530)
			jQuery("#contacts").css({"top":100+"px"});
		else
			jQuery("#contacts").css({"top":Math.round(jQuery(window).height()/2-150)+"px"});
	}
	
	jQuery("#bg img").css({"width":wWidth+"px","height":wHeight+"px"});
	
	jQuery("span[class='price_but']:first").click();

        });

function searchfull() //расширеный поиск
{
         var id_country = jQuery('#selectcountry').val();
		 var id_region = jQuery('#select2').val();
		 var id_city = jQuery('#select3').val();
		 var id_rest = jQuery('#select4').val();
		 var id_bas = jQuery('#select5').val();
		 var id_pit = jQuery('#select6').val();
		 var id_lech = jQuery('#select7').val();
		 var id_deti = jQuery('#select8').val();
        // Отсылаем паметры
        jQuery.ajax({
                type: "POST",
                url: "/js/ajax_search.php",
                data: "id_country="+id_country+"&id_region="+id_region+"&id_city="+id_city+"&id_rest="+id_rest+"&id_bas="+id_bas+"&id_pit="+id_pit+"&id_lech="+id_lech+"&id_deti="+id_deti,
                // Выводим то что вернул PHP
                success: function(html){
                        //$("#mess-"+id).slideUp('slow');
                        jQuery("#result").empty();
                        jQuery("#result").append(html);

                        // Убираем хрень
                        //jQuery.("#load").fadeOut('slow');
                }
        });
}
function region_list() //регионы для расширеного поиска
{
                //jQuery.("#load").show('fast');
                //jQuery.("#load").fadeIn('slow');
				var id = jQuery('#selectcountry').val();
        // Отсылаем паметры
        jQuery.ajax({
                type: "POST",
                url: "/js/region.php",
                data: "id="+id,
                // Выводим то что вернул PHP
                success: function(html){
                        //$("#mess-"+id).slideUp('slow');
                        jQuery("#select2").empty();
                        jQuery("#select2").append(html);

                        // Убираем хрень
                        //jQuery.("#load").fadeOut('slow');
                }
        });
}
function city_list() //список городов для расш поиска
{
                //jQuery.("#load").show('fast');
                //jQuery.("#load").fadeIn('slow');
				var id = jQuery('#select2').val();
        // Отсылаем паметры
        jQuery.ajax({
                type: "POST",
                url: "/js/city.php",
                data: "id="+id,
                // Выводим то что вернул PHP
                success: function(html){
                        //$("#mess-"+id).slideUp('slow');
                        jQuery("#select3").empty();
                        jQuery("#select3").append(html);

                        // Убираем хрень
                        //jQuery.("#load").fadeOut('slow');
                }
        });
}
function searchregion() // поиск по регионам
{

		 var idregion = jQuery('#idregion').val();
		 var id_city = jQuery('#select2').val();
		 var id_rest = jQuery('#select3').val();
		 var id_bas = jQuery('#select5').val();
		 var id_pit = jQuery('#select6').val();
		 var id_lech = jQuery('#select7').val();
		 var id_deti = jQuery('#select8').val();
		 var id_country = jQuery('#idcountry').val();

        // Отсылаем паметры
        jQuery.ajax({
                type: "POST",
                url: "/js/ajax_searchregion.php",
                data: "id_region="+idregion+"&id_rest="+id_rest+"&id_bas="+id_bas+"&id_pit="+id_pit+"&id_lech="+id_lech+"&id_deti="+id_deti+"&id_country="+id_country+"&id_city="+id_city,
                // Выводим то что вернул PHP
                success: function(html){
                        //$("#mess-"+id).slideUp('slow');
                        jQuery("#resultsearch").empty();
                        jQuery("#resultsearch").append(html);

                        // Убираем хрень
                        //jQuery.("#load").fadeOut('slow');
                }
        });
}

