

/*----   
  Enable jquery to work eventhough we also use mootools
----*/

var jq = jQuery.noConflict();
     
jq(document).ready(function($){



//Organisation extension

//Groups
if(document.getElementById("group-1")){
  $(".group").hide();
  showGroup('-1');
}

if(document.getElementById("group-1")){
  //Alphabet
  $(".organisation").hide();
  showLetter('A');
}

//style aktiviteter kategori
$('#current .box_content .news_list_container .news_list_item .date').each(function(){
  var Nytext = $(this).html().replace('Regionskontor ','');
  $(this).html(Nytext);

});

//new frontpage style aktiviteter kategori
$('#eventsDiv .news_list_container .news_list_item .dateEvent .eventCat').each(function(){
  var Nytext2 = $(this).html().replace('Regionskontor ','');
  $(this).html(Nytext2);

});

//vertical align genveje
$('#shortcuts ul li a').each(function(){
        var genWidth = $(this).text().length;
        if(genWidth > 18)
        $(this).addClass("twoline");
});

//-----   
// Switch stylesheets starts
//-----

var c = readCookie('style');

if (c) {
  
  switchStylestyle(c);
   
  if (c == "font_11px") {
          $('.big_font').each(function(i) {
      $(this).attr({
        rel: "font_12px"
            });
          });
          $('.small_font').each(function(i) {
      $(this).attr({
        rel: "font_11px"
            });
          });
        } else if (c == "font_12px") {
          $('.big_font').each(function(i) {
      $(this).attr({
        rel: "font_13px"
            });
          });
          $('.small_font').each(function(i) {
      $(this).attr({
        rel: "font_11px"
            });
          });
        } else if (c == "font_13px") {
          $('.big_font').each(function(i) {
      $(this).attr({
        rel: "font_13px"
            });
          });
          $('.small_font').each(function(i) {
      $(this).attr({
        rel: "font_12px"
            });
          });
        }
}
  
$('.big_font').click(function() {

  var relatt = this.getAttribute("rel");
        
         switchStylestyle(relatt);
        
        if (relatt == "font_12px") {
    $(this).attr({
      rel: "font_13px"
          });
        }
        if (relatt == "font_13px") {  
          $('.small_font').attr({
      rel: "font_12px"
          });
  }
  
        return false;
});   

$('.small_font').click(function() {

  var relatt = this.getAttribute("rel");
        
         switchStylestyle(relatt);
        
        if (relatt == "font_12px") {
    $(this).attr({
      rel: "font_11px"
          });
        }
        if (relatt == "font_11px") {  
          $('.big_font').attr({
      rel: "font_12px"
          });
  }
  
        return false;
});   

//-----
// Switch stylesheets ends
//-----

//style pagebrowser
$(".tx-ttnews-browsebox table td:last-child").each(function(){
   this.addClass( "noslash" );
 });
  
$(".tx-ttnews-browsebox table td:first-child").each(function(){
   this.addClass( "noslash" );
 });
 
 if($(".tx-ttnews-browsebox table td:first-child p a").text()=="< Forrige"){
   $(".tx-ttnews-browsebox table td:first-child").next().addClass("noslash");
 }
 
 $(".tx-indexedsearch-browsebox ul li:last-child").each(function(){
   this.addClass( "noslash" );
 });
  
$(".tx-indexedsearch-browsebox ul li:first-child").each(function(){
   this.addClass( "noslash" );
   if($(this).find("a").text()=="< Forrige"){
    $(this).next().addClass("noslash");
   }  
 });
 
   
}); //Ends jquery onload


function switchStylestyle(styleName)
{
        jq('link[@rel*=style][@title]').each(function(i)
        {
                this.disabled = true;
                if (this.getAttribute('title') == styleName) this.disabled = false;
        });
        createCookie('style', styleName, 365);
}

// Ends all jquery



// cookie functions http://www.quirksmode.org/js/cookies.html

function createCookie(name,value,days){
  if (days)  {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++){
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name){
  createCookie(name,"",-1);
}

// cookie functions end
