/* Erstat H1 og H2 med cufon fonten */
Cufon.replace('h1');
Cufon.replace('h2');


$('document').ready(function(){

  $('#mytable').tablesorter(); 
  
  if ($.cookie('textSize') != null){
    $('#mainContent').attr('class',$.cookie('textSize'));
  };
  
  // FORM HELP //
  $('div.formInputHelp').click(function(){
    if($(this).children().css('display') == 'none')
      {
        $('div.formInputHelp').children().css('display','none');
        $(this).children().css('display','inline');
      } else {
        $('div.formInputHelp').children().css('display','none');
      }
  });

  // Invoice HELP //
  $('div.invoiceInfoItem').hover(
    function(){
      $(this).css('zIndex',1000);
      if($(this).children().css('display') == 'none')
      {
        $('div.invoiceInfoItem').children().css('display','none');
        $(this).children().css('display','inline');
        $(this).children().css('zIndex', 1010);
      }
  });
  $('div.invoiceInfoItem').mouseleave(function(){
    $(this).css('zIndex',100);
    $(this).children().css('display','none');
  });
  
  // FORM SUBMIT //
  
  $('.formContainer input[type="submit"]').click(function(){
    $(this).val('Vent venligst...');
    $(this).attr('class','submitFeedback');
  });

  function updateSlideshowHeight(){
    var x=$('ul.slideShow').parent().css('height');
    $('ul.slideShow, ul.slideShow li').css('height',x);
  }

  
  function startSlideShow(){
    $('ul.slideShow').cycle({
            fx: 'scrollRight',
            random: 1,
            timeout: 7000,
            pause: 1
          });
  }
  
  startSlideShow();
  
  $('.content2columns').equalHeights();
  
  updateSlideshowHeight();

  $('#textSizeToggle').click(function(){
   if ($.cookie('textSize') == null || $.cookie('textSize') == 'normalText')
   {
     $.cookie('textSize', 'largeText');
   window.location=window.location;
   }
   else
   {
     var x = $.cookie('textSize');
     if (x == 'largeText'){
     $.cookie('textSize', 'largerText');
     window.location=window.location;
   }
   else
   {
     $.cookie('textSize', 'normalText');
     window.location=window.location;
   }
   }
  });

  
    //When page loads...
  $(".tab_content").hide(); //Hide all content
  $("ul.tabs li:first").addClass("active").show(); //Activate first tab
  $(".tab_content:first").show(); //Show first tab content
  
});

//On Click Event
$("ul.tabs li").click(function() {

  $("ul.tabs li").removeClass("active"); //Remove any "active" class
  $(this).addClass("active"); //Add "active" class to selected tab
  $(".tab_content").hide(); //Hide all tab content

  var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
  $(activeTab).fadeIn(); //Fade in the active ID content
  return false;
});


