function aar(question, location) {	
	if(confirm(question))
		window.location = location;
}


function openHREF(that){
	if(that.href != '')
		window.open(that.href, 'new_window');
	return false;
}

function openPopup(that, options){
	if(that.href != '')
		window.open(that.href, 'new_window_popup', options);
	return false;
}

function reloadCaptcha(that){
	if(that.src != ''){
		that.src = '/captcha.php5?'+Math.random();
	}
}

function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}

function sort(type){
	if(type == 'desc'){
		$('#sort_desc').attr("src", "/gfx/down_on.png?"+Math.random());
		$('#sort_asc').attr("src", "/gfx/up.png?"+Math.random());
		$('#filtr_sort_price').val('d');
	}else{
		$('#sort_asc').attr("src", "/gfx/up_on.png?"+Math.random());
		$('#sort_desc').attr("src", "/gfx/down.png?"+Math.random());
		$('#filtr_sort_price').val('a');
	} 
}

function cBZ(what){
	return ( what < 0 ? 0 : what );
}

function changeSliderVal(index){
	var value = ( index == 0 ? $('#amount-min').val() : $('#amount-max').val() )
	
	value = value.replace(/,/gi, '.');
	
	var check = IsNumeric(value);
	
	if(check === false){
		( index == 0 ? $('#amount-min').val(0) : $('#amount-max').val(0) )
		value = 0;
	}else{
		( index == 0 ? $('#amount-min').val(value) : $('#amount-max').val(value) )
	}

	if($('#slider-range') != null){
		$('#slider-range').slider('values', index, value );
	}
}

function IsNumeric(val) {
    if (isNaN(parseFloat(val))) {
          return false;
     }
     return true
}

var searchState = false; // false = simple, true = adv
var searchAnimation = 250;
function toggleSearchState(){
	if(searchState == false){
		$('#simpleSearch').show();
		$('#searchBtnSimpleDiv').hide();
		$('#searchBtnAdvDiv,#advSearch,#simpleSearch').show();
		$('#slider-range-value').css('width', 550);
		$('#slider-range').css('width', 390);
	
		//$('#searchBox .wyszukiwanie').animate({opacity: 0}, searchAnimation, 'swing', function(){$(this).removeClass('wyszukiwanie-zaawansowane').addClass('wyszukiwanie-proste');});
		//$('#searchBox .wyszukiwanie').animate({opacity: 1}, searchAnimation, 'swing', function(){searchState = true;});
		$('#searchBox .wyszukiwanie').hide().removeClass('wyszukiwanie-zaawansowane').addClass('wyszukiwanie-proste');
		$('#searchBox .wyszukiwanie').show();
		searchState = true;
	}else{
		$('#advSearch,#simpleSearch').hide();
			$('#searchBtnAdvDiv').hide();
			$('#slider-range-value').css('width', 370);
			$('#slider-range').css('width', 205);
			$('#searchBtnSimpleDiv').show();
			$('#simpleSearch').show();
	
		//$('#searchBox .wyszukiwanie').animate({opacity: 0}, searchAnimation, 'swing', function(){$(this).removeClass('wyszukiwanie-proste').addClass('wyszukiwanie-zaawansowane');});
		//$('#searchBox .wyszukiwanie').animate({opacity: 1}, searchAnimation, 'swing', function(){searchState = false;});
		$('#searchBox .wyszukiwanie').hide().removeClass('wyszukiwanie-proste').addClass('wyszukiwanie-zaawansowane');
		$('#searchBox .wyszukiwanie').show();
		searchState = false;;
	}
}

function showObj(obj) {
  str='';
  for(prop in obj)
  {
    str+=prop + " value :"+ obj[prop]+"\n";
  }
  alert(str);
}

