/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(document).ready(function() {
	var currencyRate = system.isEmpty(php.currency_rate)?1:php.currency_rate;
	$(".eshFilterLabel").click(function() {
		if ($(this).hasClass('open')) {
			$(this).removeClass('open');
			$(this).next(".eshFilterData").hide();
		} else {
			$(this).addClass('open');
			$(this).next(".eshFilterData").show();
		}
	});

	$( "#filterBoxPriceSlider" ).slider({
		range: true,
		min: Math.ceil(php.price_min / currencyRate),
		max: Math.ceil(php.price_max / currencyRate),
		step: Math.ceil(100 / currencyRate),
		values: [ Math.ceil(php.price_from / currencyRate), Math.ceil(php.price_to / currencyRate) ],
		slide: function( event, ui ) {
			$( "#filterBoxPriceInfo span" ).html( ui.values[ 0 ] + " - " + ui.values[ 1 ] );
			$( "#filterBoxPriceFrom").val(Math.ceil(ui.values[0] * currencyRate));
			$( "#filterBoxPriceTo").val(Math.ceil(ui.values[1] * currencyRate));
		},
		create: function (event, ui) {
			$( "#filterBoxPriceInfo span" ).text( Math.ceil(php.price_from / currencyRate) + " - " + Math.ceil(php.price_to / currencyRate) );
		},
		stop : function (event, ui ) {
			$("#boxFilterFrm").submit();
		}
	});

	if ($("#filterBoxPriceAmount").length > 0) {
		$( "#filterBoxPriceAmount" ).val( $( "#filterBoxPriceSlider" ).slider( "values", 0 ) + " - " + $( "#filterBoxPriceSlider" ).slider( "values", 1 ) );
	}

	$("#boxFilterFrm input").click(function() {
		$("#boxFilterFrm").submit();
	});

	$("#boxFilterFrm input[name='boxFilterSubmit']").hide();

});
