﻿// jQuery Forsideslider

$(document).ready(
      function(){
        $(".smallImage img").click(function() {
        var url = $(this).attr("src").replace("_t", "");
        var bigImage = $("#carBigImage").fadeTo("fast");
        
        // the large image
        var img = new Image();

        // call this function after it's loaded
        img.onload = function() {

          // make wrapper fully visible
          bigImage.fadeTo("fast", 1);

          // change the image
          bigImage.find("img").attr("src", url);      
          
        };  
        
        // begin loading the image from flickr
        img.src = url;

// when page loads simulate a "click" on the first image
}).filter(":first").click();
});





$(document).ready(function() {
  
  // Language selecter
  $("#choose").click(function() {
  $("#options").toggle();
  });
  
  $("#options ul li").mouseenter(function(){
    $(this).find("a").css("color", "#68acff").css("text-shadow","none");
  });

  $("#options ul li").mouseleave(function(){
    if ($(this).hasClass("active") ) {
      $(this).find("a").css("color", "#68acff").css("text-shadow","none");
    }
    else
      $(this).find("a").css("color", "#ffffff").css("text-shadow","1px 1px 1px #0E4C66");
  });
  
});

// jQuery Søgefunktion: input felt ændrer focus fra søg her... til ingenting når man klikker i inputfeltet
$(document).ready(function() {
  $('input[type="text"]').focus(function() {
    if (this.value == this.defaultValue){
      this.value = '';
    }
    if(this.value != this.defaultValue){
      this.select();
    }
  });
  $('input[type="text"]').blur(function() {
    if ($.trim(this.value) == ''){
      this.value = (this.defaultValue ? this.defaultValue : '');
    }
  });
});
        
       

// acordion start
    
$(document).ready(function(){

  //Hide (Collapse) the toggle containers on load
  $(".toggle_container").hide();

  //Switch the "Open" and "Close" state per click
  $("h2.trigger").toggle(function(){
    $(this).addClass("active");
    }, function () {
    $(this).removeClass("active");
  });

  //Slide up and down on click
  $("h2.trigger").click(function(){
    $(this).next(".toggle_container").slideToggle("slow");
  });

});
