jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
return true;
}

$(document).ready(function() {

  //click function
  $('.chgborder').click(function() {
    var id = this.id;
    var price = $(this).attr('rel');
    var name = $(this).attr('name');
    if (price==0) {
      price = 'na dotaz';
      } else {
      price = price+',- Kč';
      }
    $("#listapricetext").text(price);
    $("#listanametext").text(name);
    //hidden form
    $("#listaName").val(name);
    $("#listaId").val(id);
    
    //alert($("#listaId").val() + ' / ' + $("#listaName").text());
    
    //$('#selectedlista').attr('value',id);
    $("#detailform select[@name='lista'] option[@value='"+id+"']").attr("selected","selected");//select beta
    var pathimg = 'listy/' + id + '/';
    if ($.preloadImages(pathimg+'lhr.jpg',pathimg+'hr.jpg',pathimg+'phr.jpg',pathimg+'ls.jpg',pathimg+'ps.jpg',pathimg+'lsr.jpg',pathimg+'sr.jpg',pathimg+'pdr.jpg')) {
      var lhr = $('#lhr');
    
      $('#lhr').attr('src','listy/' + id + '/lhr.jpg');
      $('#hr').attr('background','listy/' + id + '/hr.jpg');
      $('#phr').attr('src','listy/' + id + '/phr.jpg');
    
      $('#ls').attr('background','listy/' + id + '/ls.jpg');
      $('#ps').attr('background','listy/' + id + '/ps.jpg');
    
      $('#lsr').attr('src','listy/' + id + '/lsr.jpg');
      $('#sr').attr('background','listy/' + id + '/sr.jpg');
      $('#pdr').attr('src','listy/' + id + '/pdr.jpg');
    
      }
    
    
  });
  //end click fn
  //serial scroll
    $.easing.easeOutQuart = function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		};
    $('#listycontrol').serialScroll({
        items:'img',
        prev:'a#scrollleft',
				next:'a#scrollright',
				axis:'x',
				step:3, //when scrolling to photo, stop 230 before reaching it (from the left)
				duration:800,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
});