function formSearchValidate() {
    if(!$('input#keywords').val()) { $('input[name=search_by]').remove(); $('input#keywords').remove(); }
	if($('form#search select').val() == '') $(".search_brand").remove();	
	$('form#search').submit();
}
add_image_handlers = function() {
  $("#main-image").data('selectedThumb', $('#main-image img').attr('src'));
  $('ul.thumbnails li').eq(0).addClass('selected');
/*  $('#main-image img').click(function() {
    $(this).attr('src').replace("/product/", "/original/");
  }); */
  $('ul.thumbnails li a').click(function() {
    $("#main-image").data('selectedThumb', $(this).attr('href'));
    //$("#image_link").attr('href', $(this).attr('href').replace("/product/", "/original/"));
    $('ul.thumbnails li').removeClass('selected');
    $(this).parent('li').addClass('selected');
    return false;
  }).hover(
          function() {
            $('#main-image img').attr('src', $(this).attr('href').replace('mini', 'product'));
          },
          function() {
            $('#main-image img').attr('src', $("#main-image").data('selectedThumb'));
          }
          );
};
jQuery(function() {
$(document).ready(function(){


$("#fotoFrame").dynamicSlideshow({duration: 7000});
});
$("select.property option").each(function() {
  var pattern = '/with_property_value/'+$(this).parents("select").attr('name')+','+$(this).attr('value')+'/';
  if(decodeURIComponent(document.location.href).indexOf(pattern)!=-1) {
    $(this).attr('selected', 'selected');
  }
});

$("#submit").click(function() {
var href=document.location.href.split('/s/')[0]+'/s';

$("#filter form select.property").each(function(){
if($(this).attr('value')) {
href += '/with_property_value/'+encodeURIComponent($(this).attr('name'))+','+encodeURIComponent($(this).attr('value'));
}
});

 //with_property_value
if($('#pg').attr('value')) {
  href += '/master_price_gte/'+$('#pg').attr('value');
}
if($('#pl').attr('value')) {
  href += '/master_price_lte/'+$('#pl').attr('value');
}
if($('#filter_select').attr('value')) {
  href += '/in_name/'+$('#filter_select').attr('value');
}
if($('#order_by_price').val()) {
href += '/'+$('#order_by_price').attr('value')+'_by_master_price/true';
}
//$('#pg') master_price_gte
//$('#pl')master_price_lte
//$('#order by price') order_by_price
//alert(href);
href = href.replace(/\?page=[0-9]+/i, '');
href = href.replace(/\?per_page=[0-9]+/i, '');
href = href.replace(/\&page=[0-9]+/i, '');
href = href.replace(/\&per_page=[0-9]+/i, '');
href = href.replace('/s/s/', '/s/');
href = href.replace('/s/s', '/s/');

//alert(href);
document.location.href = href;
});

jQuery("#partner-icons").scrollable({clickable: true, circular: true, autoscroll: true});
jQuery(".navigation-list a.root").click(function() {

  if(jQuery(this).parents("ul").find("div").css("display") == "block") {
  jQuery(".navigation-list a.root").parents("ul").find("ul").hide();
  } else {
  jQuery(".navigation-list a.root").parents("ul").find("ul").hide();
  jQuery("ul#taxonomies-"+$(this).parents('li').attr('id')).slideToggle();
  }
});

$jScroller.add("#partner-icons",".items","left",1, true);



          $jScroller.start();

jQuery("a.root").parents("li").css("background", "none");
});
