areaId = 0;
//AreaId is set in master template

var translations = new Array();
//UK
translations[29] = new Array();
translations[29][0] = "4037"; //Forside ID
translations[29][1] = "Ciso pictures must be used only in connection with Ciso."; //Gallery text

//NL
translations[30] = new Array();
translations[30][0] = "4120"; //Forside ID
translations[30][1] = "Ciso pictures mogen uitsluitend gebruikt worden in combinatie met het Ciso logo"; //Gallery text

function TranslationText(index) {
  return translations[areaId][index];
}

// Giver dig en parameter fra urlen
function getURLParam(strParamName) {
  return getParameterFromLink(strParamName, window.location.href);
}

// Giver dig en parameter fra et link
function getParameterFromLink(strParamName, link) {
  var strReturn = "";
  var strHref = link;
  if (strHref.indexOf("?") > -1) {
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
    var aQueryString = strQueryString.split("&");
    for (var iParam = 0; iParam < aQueryString.length; iParam++) {
      if (aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1) {
        var aParam = aQueryString[iParam].split("=");
        strReturn = aParam[1];
        break;
      }
    }
  }
  return unescape(strReturn);
}

function setCookie(c_name, value, expiredays) {
  var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays);
  document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function getCookie(c_name) {
  if (document.cookie.length > 0) {
    c_start = document.cookie.indexOf(c_name + "=");
    if (c_start != -1) {
      c_start = c_start + c_name.length + 1;
      c_end = document.cookie.indexOf(";", c_start);
      if (c_end == -1) c_end = document.cookie.length;
      return unescape(document.cookie.substring(c_start, c_end));
    }
  }
  return "";
}

runningId = 0;
stopId = 0;
//Changes the opacity for the object with the chosen id
function opacity(id, opacStart, opacEnd, millisec, showElement) {
  if (!showElement) {
    setTimeout("hideElement('" + id + "')", 0);
  } else
    setTimeout("showElement('" + id + "')", 0);
  //speed for each frame 
  var speed = Math.round(millisec / 100);
  var timer = 0;

  //determine the direction for the blending, if start and end are the same nothing happens 
  if (opacStart > opacEnd) {
    for (i = opacStart; i >= opacEnd; i--) {
      setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
      timer++;
    }
  } else if (opacStart < opacEnd) {
    for (i = opacStart; i <= opacEnd; i++) {
      setTimeout("changeOpac(" + i + ",'" + id + "')", (timer * speed));
      timer++;
    }
  }
  
}

function hideElement(id) {
  document.getElementById(id).style.display = "none";
}

function showElement(id) {
  document.getElementById(id).style.display = "block";
}

//change the opacity for different browsers 
function changeOpac(opacity, id) {
  var object = document.getElementById(id).style;
  object.opacity = (opacity / 100);
  object.MozOpacity = (opacity / 100);
  object.KhtmlOpacity = (opacity / 100);
  object.filter = "alpha(opacity=" + opacity + ")";
}

/*
  IPaper Specific START
*/
//G?r et eller andet ved IPaper, som ellers fejler.
function onPaperLoad() { return; }

function checkIpaperOpen() {
  var showIpaper = getURLParam("ShowIpaper");
  if (showIpaper && showIpaper != "") {
    showPopup("IPaper", showIpaper);
  }
}

function checkIpaperClose() {
  window.setInterval(checkToClose, 300);
}

function checkToClose() {
  var allIsDisplayNone = true;
  jQuery(".popupContent").each(function() {
    if (jQuery(this).css("display") === "block") {
      allIsDisplayNone = false;
    }
  });
  if (allIsDisplayNone)
    window.opener.closePopUp(window);
}
/*
IPaper Specific END
*/
