var intval="";

function toogle_block(id) {
  element = document.getElementById(id);
  if(element.style.display != 'block') {
    element.style.display = 'block';
  } else {
    element.style.display = 'none';
  }
}

function ShowHideFilter(id) {
	element = document.getElementById(id);
	if(element.style.display != "block") {
		element.style.display = "block";
	} else {
		element.style.display = "none";
	}
}

function renew_total_price() {
	var delivery = '';
	var price = '';
	var total_price = '';

	delivery = parseFloat(document.getElementById('delivery_price').innerHTML);
	price = parseFloat(document.getElementById('__price').value);
	total_price = document.getElementById('total_price');
	
	if($("#total_price_span")) {
		$("#total_price_span").html(parseFloat(price + delivery));
	}

	total_price.value = parseFloat(price + delivery);
	
}
function change_delivey_price(newprice) {
	if(newprice == '0.00') {
		newprice = '0';
	}
	document.getElementById('delivery_price').innerHTML=newprice;
	document.getElementById('deliveryTotalShowPrice').innerHTML=newprice;
	
	renew_total_price();
}
function renew_delivery() {
	var delivery_default = '';
	delivery_default = window.document.getElementById('delivery_default').innerHTML;
	window.document.getElementById('delivery_price').innerHTML = delivery_default;
}

function check_hide() {
	$("body").click(function(){
		$("#SearchForm label").fadeOut(500);
	});
}

function scrollThis(){
	var count = $('#scrollable .element').length;
	if(count > 1) {
		$('#scrollable').animate({left: '-758px'}, 700, function() {
			$('#scrollable .element:first-child').remove();
			$('#scrollable').css('left', '0px');
		});
		$('#scrollable').append('<div class="element">' + $('#scrollable .element:first-child').html() + '</div>');
	}
}

function startScroller() {


	$('#scrollable').mouseenter(function(){
		window.clearInterval(intval);
	});
	
	$('#scrollable').mouseout(function(){
		intval = window.setInterval("scrollThis()", 5500);
	});

	intval = window.setInterval("scrollThis()", 5500);
}

function startShowHideFiltersClicker() {
	$('#show').click(function(){
		$(this).hide();
		$('#SmallFilter').css('height', '1040px');
	});
	$('#hide').click(function(){
		$('#SmallFilter').css('height', '190px');
		$('#show').show();
	});
}

$(document).ready(function(){
	
	// firstpage scroller
	startScroller();
	
	// show/hide filters
	startShowHideFiltersClicker();
	
});
