var image1 = new Image(); image1.src = "/images/arrow-left-hover.jpg";
var image2 = new Image(); image1.src = "/images/arrow-right-hover.jpg";
 
var s=0;
var flag=true;
jQuery(document).ready(function()
{
	$(".prev").disableTextSelect();
	$(".next").disableTextSelect();
	$('.flats tr:odd').attr('style','background:#dadada;');
	function resizing()
	{		
		if($('body').innerWidth()<1001)
		{	
			$("#all").width(1000);
		}
		if($('body').innerWidth()>=1000)
		{	
			$("#all").width("100%");
		}
	}
	
	resizing();
	
	$(window).resize(function()
	{
		resizing();
	});
	
	$('.my-button').mouseover(function()
	{
		$(this).css("background","url('/images/button-hover.jpg')");
	});
	$('.my-button').mouseout(function()
	{
		$(this).css("background","url('/images/button.jpg')");
	});
	$('.my-button').mousedown(function()
	{
		$(this).css("background","url('/images/button-click.jpg')");
	});
	$('.my-button').mouseup(function()
	{
		$(this).css("background","url('/images/button.jpg')");
	});
	
	begin=$(".small_picture").attr('src');
	$("#main_img").attr("src",begin);
	
	$(".small_picture").click(function()
    {
		var pos;
		tmp = $(this).attr("src");
		$("#main_img").attr("src",tmp);
    });
	$(".next").click(function()
    {
		if (flag)
		{
			flag=false;
			first='<div class="bar-item">'+$(".bar-center .bar-item:first").html()+'</div>';
			$(".bar-center .bar-item:first").animate( { marginLeft:"-233"}, 500 , 'linear' ,function(){
				$(".bar-center .bar-item:first").remove();
				$(".bar-center .bar-item:last").after(first);
				flag=true;
			});
		}
    });
	$(".prev").click(function()
    {
		if (flag)
		{
			flag=false;
			last='<div class="bar-item" style="margin-left:-233px;display:none;">'+$(".bar-center .bar-item:last").html()+'</div>';
			$(".bar-center .bar-item:last").remove();
			$(".bar-center .bar-item:first").before(last);
			$(".bar-center .bar-item:first").show();
			$(".bar-center .bar-item:first").animate( { marginLeft:"0"}, 500 , 'linear' ,function(){
				flag=true;
			});
		}
    });
});
						function redir(f) 
						{ 
							s=f.value;
							switch (s)
							{
								case "11": 
								case " 11": 
								case "11 ": 
								case "011": location.replace("/flats/id011"); break;
								case "12": 
								case " 12": 
								case "12 ": 
								case "012": location.replace("/flats/id012"); break;
								case "14": 
								case " 14": 
								case "14 ": 
								case "014": location.replace("/flats/id014"); break;
								case "15": 
								case " 15": 
								case "15 ": 
								case "015": location.replace("/flats/id015"); break;
								case "16": 
								case " 16": 
								case "16 ": 
								case "016": location.replace("/flats/id016"); break;
								case "17": 
								case " 17": 
								case "17 ": 
								case "017": location.replace("/flats/id017"); break;
								case "18": 
								case " 18": 
								case "18 ": 
								case "018": location.replace("/flats/id018"); break;
								case "19": 
								case " 19": 
								case "19 ": 
								case "019": location.replace("/flats/id019"); break;
								case "20": 
								case " 20": 
								case "20 ": 
								case "020": location.replace("/flats/id020"); break;
								case "21": 
								case " 21": 
								case "21 ": 
								case "021": location.replace("/flats/id021"); break;
								case "22": 
								case " 22": 
								case "22 ": 
								case "022": location.replace("/flats/id022"); break;
								case "23": 
								case " 23": 
								case "23 ": 
								case "023": location.replace("/flats/id023"); break;
								case "24": 
								case " 24": 
								case "24 ": 
								case "024": location.replace("/flats/id024"); break;
								case "25": 
								case " 25": 
								case "25 ": 
								case "025": location.replace("/flats/id025"); break;
								default: alert('Введите правильное значение ID');
							}
							return false;
						} 
