﻿//------ Text resize NEW ------
function textResizeByStylesheet(direction, isFrontpage){
  //Switch buttons
  if(direction == 'smaller'){
    $("div[id='divTxtResizeSmaller']").hide()
    $("div[id='divTxtResizeBigger']").show()
  }else{
    $("div[id='divTxtResizeBigger']").hide()
    $("div[id='divTxtResizeSmaller']").show()
  }
  
  //Change stylesheets
  var IE7 = ''
  if(navigator.appVersion.indexOf('MSIE 7.')>=0){
    IE7 = '_IE7'
  }
  if(navigator.appVersion.indexOf('MSIE 8.')>=0){
    IE7 = ''
  }
      
  var largeTextExt = ''
  if(direction == 'bigger'){
    largeTextExt = '_LargeTxt'
  }
      
  document.getElementById('cssCustomStyles').href = '/Files/System/CFD/Custom'+ IE7 + largeTextExt + '.css';
  document.getElementById('cssTextStyles').href = '/Files/System/CFD/Text_Styles' + largeTextExt + '.css';
  document.getElementById('cssPrintStyles').href = '/Files/System/CFD/PrintNew' + largeTextExt + '.css';

  //Save cookie
  Set_Cookie("TextResizeDirection", direction, 10, '/', '', '')
}

function textResizeByJQuery(direction, isFrontpage){
  var duration = 200;
  if(direction == 'smaller'){
    $("div[id='divTxtResizeSmaller']").hide()
    $("div[id='divTxtResizeBigger']").show()
  }else{
    $("div[id='divTxtResizeBigger']").hide()
    $("div[id='divTxtResizeSmaller']").show()
  }
  
  if(isFrontpage){
    var elms1 = $('div[id="ContentArea"]').find("span, p, a").not('.paging a').not('.QBHeader')
    var elms2 = $('div[id="ContentArea"]').find(".blueHeader")

    if(direction == 'smaller'){
      elms1.css("font-size", "11px")
      elms2.css("font-size", "1.2em")

      $("#News").css("height", "305px")
      $("#newsBottom").css("height", "16px")
      $(".NewsItemManchet").css("height", "45px")
      $(".QuickBoxContainer").css("height", "115px")
    }else{
      elms1.css("font-size", "20px")
      elms2.css("font-size", "24px")

      $("#News").css("height", "570px")
      $("#newsBottom").css("height", "32px")
      $(".NewsItemManchet").css("height", "150px")
      $(".QuickBoxContainer").css("height", "155px")
    }
  }else{  //Normal pages
    var elmsTxt = $('div[id="ContentArea"]').find(".ParagraphWrapper, p, a, li, .newstext td").not(".BoxRight p").not(".BoxRight .ParagraphWrapper")
    var elmsH1 = $('div[id="ContentArea"]').find(".h1").not(".NewsHeader")
    var elmsH2 = $('div[id="ContentArea"]').find(".h2").not(".BoxRight .h2")
    var elmsH3 = $('div[id="ContentArea"]').find(".billedtekst_roed")

    if(direction == 'smaller'){
      elmsTxt.css("font-size", "11px")
      elmsH1.css("font-size", "18px")
      elmsH2.css("font-size", "11px")
      elmsH3.css("font-size", "11px")

      $(".NewsListItemTextWrapper").css("height", "85px")
    }else{
      elmsTxt.css("font-size", "18px")
      elmsH1.css("font-size", "22px")
      elmsH2.css("font-size", "18px")
      elmsH3.css("font-size", "14px")

      $(".NewsListItemTextWrapper").css("height", "170px")
    }
  }
  
  Set_Cookie("TextResizeDirection", direction, 10, '/', '', '')
  //alert('Resize: '+ getCookie("TextResizeDirection"))
}
//------ END:Text resize NEW ------
//------ Cookies ------
function Set_Cookie(name, value, expires, path, domain, secure )
{
  // set time, it's in milliseconds
  var today = new Date();
  today.setTime( today.getTime() );

  /*
  if the expires variable is set, make the correct
  expires time, the current script below will set
  it for x number of days, to make it for hours,
  delete * 24, for minutes, delete * 60 * 24
  */
  if ( expires )
  {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );

  document.cookie = name + "=" +escape( value ) +
  ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
  ( ( path ) ? ";path=" + path : "" ) +
  ( ( domain ) ? ";domain=" + domain : "" ) +
  ( ( secure ) ? ";secure" : "" );
}

function Get_Cookie(check_name) {
  // first we'll split this cookie up into name/value pairs
  // note: document.cookie only returns name=value, not the other components
  var a_all_cookies = document.cookie.split( ';' );
  var a_temp_cookie = '';
  var cookie_name = '';
  var cookie_value = '';
  var b_cookie_found = false; // set boolean t/f default f

  for ( i = 0; i < a_all_cookies.length; i++ )
  {
    // now we'll split apart each name=value pair
    a_temp_cookie = a_all_cookies[i].split( '=' );


    // and trim left/right whitespace while we're at it
    cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

    // if the extracted name matches passed check_name
    if ( cookie_name == check_name )
    {
      b_cookie_found = true;
      // we need to handle case where cookie has no value but exists (no = sign, that is):
      if ( a_temp_cookie.length > 1 )
      {
        cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
      }
      // note that in cases where cookie is initialized but no value, null is returned
      return cookie_value;
      break;
    }
    a_temp_cookie = null;
    cookie_name = '';
  }
  if ( !b_cookie_found )
  {
    return null;
  }
}
//------ /Cookies ------


//------ Video implementation ------
function FrontpageVideoShow(videoId, videoPath){
  if(document.getElementById('divGalleryParagraphContentWrapper') && document.getElementById('divGallerySWFContentWrapper')){
    ShowJWPlayer(videoPath, videoId, '458', '268');

    document.getElementById('divGalleryParagraphContentWrapper').style.display = 'none'
    document.getElementById('divGallerySWFContentWrapper').style.display = 'inline'
  }
}

function ShowJWPlayer(filePath, instanceId, width, height){
  if(width == undefined){
    width = '290'
  }
  if(height == undefined){
    height = '212'
  }

  var so = new SWFObject('/Files/System/JWPlayer/player.swf','ply',width,height,'9','#000000');//Added 24px to height, to compensate for player-bar.                  
  so.addParam('allowfullscreen','true');                  
  so.addParam('allowscriptaccess','always');                  
  so.addParam('wmode','opaque');                  
  so.addVariable('file',filePath);                  
  so.addVariable('image','/Files/System/JWPlayer/Video_Preview.png'); 
         so.addVariable('playerready','playerReady'+ instanceId);
         so.write('mediaspace'+ instanceId);
}
//------ END:Video implementation ------


function toggleElements(elm1, elm2){
  //if($(elm1).css('display') != 'none'){
    $(elm1).css('display', 'none');
    $(elm2).css('display', 'inline');
  //}else{
  //  $(elm1).css('display', 'inline');
  //  $(elm2).css('display', 'none');
  //}
}

function toggleElementsAnimate(elm1, elm2){
  var duration = 200;
  //if($(elm1).css('display') != 'none'){
    $(elm1).hide(duration, function(){$(elm2).show(duration)});
  //}else{
  //  $(elm2).hide(duration, function(){$(elm1).show(duration)});
  //}
}

<!--
function thisMovie(movieName) {
// IE and Netscape refer to the movie object differently.
// This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName]
  } else {
    return document[movieName]
  }
}

function start_topflash(topflashname) {
  if(document.getElementById(topflashname)){
    thisMovie(topflashname).Play()
  }
}

function stop_topflash(topflashname) {
  if(document.getElementById(topflashname)){
    thisMovie(topflashname).StopPlay();
  }
}

/*
function start_topflash(topflashname) {
  alert(topflashname);
}
function stop_topflash(topflashname) {
  alert(topflashname);
}
*/
//-->
