$(function(){		
	// Slider
	$('#slider').slider({
		range: true,
		min: 0,
		max: 10000,
		step: 100,
		values: [0, 10000],
		slide: function( event, ui ) {
			$( "#price" ).val(ui.values[ 0 ]);
			$( "#priceUp" ).val(ui.values[ 1 ]);
		}
	});
	$('#slider').mouseup(function () {
		var str = "";
		$("select option:selected").each(function () {
			var name = $(this).parent().attr('name');
			str += name + "=" + $(this).val() + "&";
		});
		$("#fsform input").each(function () {
			var name = $(this).attr('name');
			str += name + "=" + $(this).val() + "&";
		});
		$.ajax({  	  
		  url: "request_h.php",
		  type: "GET",
		  data: str,
		  dataType: "text",
		  timeout: 7000,
		  beforeSend: function (){
			$("#qwe").html('<img src="img/11.png" />');
		  },
		  success: function (answer){
			$("#qwe").html(answer);
		  },
		  error: function (XMLHttpRequest, textStatus, errorThrown){
			$("#qwe").text(textStatus);
		  }
		});
	});
	$( "#price" ).val($( "#slider" ).slider( "values", 0 ));
	$( "#priceUp" ).val($( "#slider" ).slider( "values", 1 ));
	$(function() {
		var item_width = 190 + 2;
		var pages = Math.floor($('body').width() - 20) / item_width;
		var pages_width = pages * item_width;

		function mycarousel_initCallback(carousel) {
			carousel.clip.hover(function() {
				carousel.stopAuto();
			}, function() {
				carousel.startAuto();
			});

			if (carousel.size() <= Math.floor(pages)) {
				carousel.startAuto(0);
			}
			else {
				carousel.startAuto(2);
			}
		};
		$('#banners').jcarousel({
			wrap: 'circular',
			scroll: 1,
			initCallback: mycarousel_initCallback
		});
		$('.jcarousel-clip-horizontal').css('width', pages_width + 'px');
	});
});


$(document).ready(function(){
  
  $("a.mor").click(function() {
	var val = $(this).attr('value');
	$('a.show').removeClass('show');
	$(this).addClass('show');
  	$.ajax({  	  
	  url: "test1.php",
  	  type: "GET",
  	  data: "q="+val,
  	  dataType: "text",
  	  timeout: 7000,
  	  beforeSend: function (){
  	    var wth = $('div#random').css('width');
		var hgt = $('div#random').css('height');
		$("#random").html('<div style="width:'+wth+'px; height:400px; background:url(img/preload.png) center no-repeat #999; border:1px solid #555;"></div>');
  	  },
  	  success: function (answer){
  	    $("#random").html(answer);
  	  },
  	  error: function (XMLHttpRequest, textStatus, errorThrown){
  	    $("#random").text(textStatus);
  	  }
  	});
  });
  
  $('#fsform select').change(function () {
		var str = "";
		$("select option:selected").each(function () {
			var name = $(this).parent().attr('name');
			str += name + "=" + $(this).val() + "&";
		});
		$("#fsform input").each(function () {
			var name = $(this).attr('name');
			str += name + "=" + $(this).val() + "&";
		});
		$.ajax({  	  
		  url: "request_h.php",
		  type: "GET",
		  data: str,
		  dataType: "text",
		  timeout: 7000,
		  beforeSend: function (){
			$("#qwe").html('<img src="img/11.png" />');
		  },
		  success: function (answer){
			$("#qwe").html(answer);
		  },
		  error: function (XMLHttpRequest, textStatus, errorThrown){
			$("#qwe").text(textStatus);
		  }
		});
	});
  
});

