
// SEARCH FORM

  function clearDefault(el)
  {
    if (el.defaultValue == el.value)
    {
      el.value = "";
      $(el).css("color", "#000");
    }
  }

  function fillDefault(el) {
    if (el.value == "")
    {
      $(el).css("color", "#ccc");
      el.value = "search..";
    }
  }

$(document).ready(function(){

  // Taal selecterem
  $("#language_select").change(function()
  {

    var language = $("#language_select").val();
    window.location = "/" + language;
  });

  // MENU ON PAGES

  $(function() {
    $('#page_menu #item1').hover(function(){
      $('#page_menu #item1').animate({marginTop: "-20px", height: "50px"},{queue:false,duration:0});
    },
  function(){
      $('#page_menu #item1').animate({marginTop: "0px", height: "30px"},{queue:false,duration:0});
    });
  });

  $(function() {
    $('#page_menu #item2').hover(function(){
      $('#page_menu #item2').animate({marginTop: "-20px", height: "50px"},{queue:false,duration:0});
    },
  function(){
      $('#page_menu #item2').animate({marginTop: "0px", height: "30px"},{queue:false,duration:0});
    });
  });

  $(function() {
    $('#page_menu #item3').hover(function(){
      $('#page_menu #item3').animate({marginTop: "-20px", height: "50px"},{queue:false,duration:0});
    },
  function(){
      $('#page_menu #item3').animate({marginTop: "0px", height: "30px"},{queue:false,duration:0});
    });
  });

  $(function() {
    $('#page_menu #item4').hover(function(){
      $('#page_menu #item4').animate({marginTop: "-20px", height: "50px"},{queue:false,duration:0});
    },
  function(){
      $('#page_menu #item4').animate({marginTop: "0px", height: "30px"},{queue:false,duration:0});
    });
  });

  $(function() {
    $('#page_menu #item5').hover(function(){
      $('#page_menu #item5').animate({marginTop: "-20px", height: "50px"},{queue:false,duration:0});
    },
  function(){
      $('#page_menu #item5').animate({marginTop: "0px", height: "30px"},{queue:false,duration:0});
    });
  });

  // MENU ON HOMEPAGE

  $("#home_menu #item1 p").fadeTo("slow", 0);
  $("#home_menu #item2 p").fadeTo("slow", 0);
  $("#home_menu #item3 p").fadeTo("slow", 0);
  $("#home_menu #item4 p").fadeTo("slow", 0);
  $("#home_menu #item5 p").fadeTo("slow", 0);

  $(function()
  {
    var ready1 = true;
    var start1 = false;
    $('#home_menu #item1').hover(function()
    {
      if(start1 == false && ready1 == true)
        {
      start1 = true;
      ready1 = false;

      $('#home_menu #item1').animate({top: "-90px"},{queue:false,duration:0});
      $("#home_menu #item1 p").fadeTo("1000", 1,  function(){start1 = true;
      ready1 = false;});
        }
    },
    function()
    {
      setTimeout(function()
      {
        if(ready1 == false && start1 == true)
        {
          $('#home_menu #item1').animate({top: "0px"},{queue:false,duration:0});
          $("#home_menu #item1 p").fadeTo("slow", 0, function()
          {
            start1 = false;
            ready1 = true;
          });
        }
      }, 400);
    });
  });

  $(function()
  {
    var ready1 = true;
    var start1 = false;
    $('#home_menu #item2').hover(function()
    {
      if(start1 == false && ready1 == true)
        {
      start1 = true;
      ready1 = false;

      $('#home_menu #item2').animate({top: "-90px"},{queue:false,duration:0});
      $("#home_menu #item2 p").fadeTo("1000", 1,  function(){start1 = true;
      ready1 = false;});
        }
    },
    function()
    {
      setTimeout(function()
      {
        if(ready1 == false && start1 == true)
        {
          $('#home_menu #item2').animate({top: "0px"},{queue:false,duration:0});
          $("#home_menu #item2 p").fadeTo("slow", 0, function()
          {
            start1 = false;
            ready1 = true;
          });
        }
      }, 400);
    });
  });


  $(function()
  {
    var ready1 = true;
    var start1 = false;
    $('#home_menu #item3').hover(function()
    {
      if(start1 == false && ready1 == true)
        {
      start1 = true;
      ready1 = false;

      $('#home_menu #item3').animate({top: "-90px"},{queue:false,duration:0});
      $("#home_menu #item3 p").fadeTo("1000", 1,  function(){start1 = true;
      ready1 = false;});
        }
    },
    function()
    {
      setTimeout(function()
      {
        if(ready1 == false && start1 == true)
        {
          $('#home_menu #item3').animate({top: "0px"},{queue:false,duration:0});
          $("#home_menu #item3 p").fadeTo("slow", 0, function()
          {
            start1 = false;
            ready1 = true;
          });
        }
      }, 400);
    });
  });


  $(function()
  {
    var ready1 = true;
    var start1 = false;
    $('#home_menu #item4').hover(function()
    {
      if(start1 == false && ready1 == true)
        {
      start1 = true;
      ready1 = false;

      $('#home_menu #item4').animate({top: "-90px"},{queue:false,duration:0});
      $("#home_menu #item4 p").fadeTo("1000", 1,  function(){start1 = true;
      ready1 = false;});
        }
    },
    function()
    {
      setTimeout(function()
      {
        if(ready1 == false && start1 == true)
        {
          $('#home_menu #item4').animate({top: "0px"},{queue:false,duration:0});
          $("#home_menu #item4 p").fadeTo("slow", 0, function()
          {
            start1 = false;
            ready1 = true;
          });
        }
      }, 400);
    });
  });


  $(function()
  {
    var ready1 = true;
    var start1 = false;
    $('#home_menu #item5').hover(function()
    {
      if(start1 == false && ready1 == true)
        {
      start1 = true;
      ready1 = false;

      $('#home_menu #item5').animate({top: "-90px"},{queue:false,duration:0});
      $("#home_menu #item5 p").fadeTo("1000", 1,  function(){start1 = true;
      ready1 = false;});
        }
    },
    function()
    {
      setTimeout(function()
      {
        if(ready1 == false && start1 == true)
        {
          $('#home_menu #item5').animate({top: "0px"},{queue:false,duration:0});
          $("#home_menu #item5 p").fadeTo("slow", 0, function()
          {
            start1 = false;
            ready1 = true;
          });
        }
      }, 400);
    });
  });


});

$(function()
{
	var zIndexNumber = 1000;
	$('div').each(function()
  {
    if($(this).hasClass('cycle_photos') || $(this).hasClass('cycle_item') )
    {
      // nothing
    }
    else
    {
      $(this).css('zIndex', zIndexNumber);
		  zIndexNumber -= 10;
    }
	});
});

// Preloading

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)

jQuery.preLoadImages("/img/cycle/photo1.jpg", "/img/cycle/photo2.jpg", "/img/cycle/photo3.jpg", "/img/cycle/photo4.jpg", "/img/cycle/photo5.jpg",
"/img/photos_home/product_photo1.jpg", "/img/photos_home/product_photo2.jpg", "/img/photos_home/product_photo3.jpg", "/img/photos_home/product_photo4.jpg", "/img/photos_home/product_photo5.jpg");

// Cycle

$(function() {
  $('.cycle_photos').before('<div class="cycle_item">').cycle({
    fx:     'fade',
    speed:  2000,
    timeout: 4000,
    before: function() {if (window.console) console.log(this.src);}
  });
});


