/**************************
used in leftmenu to set rounded corners on mouseover (and onfocus)
****************************/
function CornersLMenuMOverTop(listItemAnchor,shadelvl)
{
  if (listItemAnchor.firstChild.className == "cornerTop")
  {
    listItemAnchor.firstChild.style.background = "transparent url(/upload/_Navigation/amv.LeftMenu/" + shadelvl + "_top.gif) no-repeat top right";
  }
}
function CornersLMenuMOverBottom(listItemAnchor,shadelvl)
{
  if (listItemAnchor.firstChild.firstChild.className == "cornerBottom")
  {
    listItemAnchor.firstChild.firstChild.style.background = "transparent url(/upload/_Navigation/amv.LeftMenu/" + shadelvl + "_bottom.gif) no-repeat bottom right";
  }
}
/**************************
used in leftmenu to set rounded corners on mouseout (and onblur)
****************************/
function CornersLMenuMOutTop(listItemAnchor,shadelvl)
{
  if (listItemAnchor.firstChild.className == "cornerTop")
  {
    listItemAnchor.firstChild.style.background = "transparent url(/upload/_Navigation/amv.LeftMenu/" + shadelvl + "_top.gif) no-repeat top right";
  }
}
function CornersLMenuMOutBottom(listItemAnchor,shadelvl)
{
  if (listItemAnchor.firstChild.firstChild.className == "cornerBottom")
  {
    listItemAnchor.firstChild.firstChild.style.background = "transparent url(/upload/_Navigation/amv.LeftMenu/" + shadelvl + "_bottom.gif) no-repeat bottom right";
  }
}


//  ******************************************
//  *  sets text in searchbox *
//  ******************************************

searchBoxPreInput = function ()
{
  for (i = 0; i<document.forms[0].elements.length; i++)
  {
    if (document.forms[0].elements[i].value == "")
    {
      if (document.forms[0].elements[i].parentNode.className == "littleOrangeSearchBox")
      {
        document.forms[0].elements[i].value = ' Indtast søgeord';
      }
    }
  }
}

if (window.addEventListener)
  window.addEventListener("load", searchBoxPreInput, false)
else if (window.attachEvent)
  window.attachEvent("onload", searchBoxPreInput)

//  ******************************************
//  *  prevents IE bug when autopostback dropdown on afvanced search page *
//  ******************************************

function AdvancedSearchIEEventTargetBugFix(elementId)
{
  var theform;
	if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
		theform = mainform;
	}
	else {
		theform = document.forms["mainform"];
	}
	
	
  if (document.getElementById(elementId))
  {
    theform.__EVENTTARGET.value = document.getElementById(elementId).name;
    theform.submit();
  }
  else
    alert(elementId + " not found!");
}

//  ******************************************
//  *  this CRclickButton will make a click event if it is a CR *
//  ******************************************

function CRClickButton(buttonID, e)
{
  if (e)  //firefix etc.
  {
    if(e.keyCode==13)
    {
      document.getElementById(buttonID).click();
      e.cancelBubble = true;
      e.returnValue = false;
      return false
    }
  }
  else if (window.event)  //IE etc.
  {
    if(window.event.keyCode==13)
    { 
      document.getElementById(buttonID).click();
      window.event.cancelBubble = true;
      window.event.returnValue = false;
      return false
    }
  }
  return true; 
}

//  ******************************************
//  *  returns appropriate style object in different browsers *
//  ******************************************


function getStyleObject(objectId) {
	if(document.getElementById && document.getElementById(objectId))
	{
		return document.getElementById(objectId).style;
	}
	if (document.all && document.all(objectId))
	{
		return document.all(objectId).style;
	}
	if (document.layers && document.layers[objectId])
	{
		return getObjNN4(document,objectId);
	}
	return false;
} 

//  ******************************************
//  *  used for print layout                      *
//  ******************************************

function printPage()
{
  if(FORM_DATA["pf"] == '1')
  {
    if(window.print)
      window.print();
  }
  return false;
}

/*
Webmonkey GET Parsing Module
Language: JavaScript 1.0
The parsing of GET queries is fundamental
to the basic functionality of HTTP/1.0.
This module parses GET with JavaScript 1.0.
Source: Webmonkey Code Library
(http://www.hotwired.com/webmonkey/javascript/code_library/)
Author: Patrick Corcoran
Author Email: patrick@taylor.org
*/


function createRequestObject() {
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  separator = ',';
    // The token used to separate data from multi-select inputs
  query = '' + this.location;
  qu = query
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }
  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.<
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }
  return FORM_DATA;
}



//  ******************************************
//  *  Open new windows                      *
//  ******************************************

function shareLink(linkID,e) 
{
  if (DetectActivate(e)){
    var url="/global/globale_sider/share_link.aspx" + "?link=" + linkID;
    var win = window.open(url,"","modal=yes,resizeable=yes,width=725,height=520,scrollbars=no")

    if (win == null)
      alert("For at tippe en ven skal du tillade brug af pop-up vinduer på denne side.");
    return false;
  }
  return true;
}

function amv_popup(path,e) 
{
  if (DetectActivate(e)){
    var win = window.open(path,"","width=776,height=510,resizable=0,status=0,toolbar=1,scrollbars=1");
    if (win == null)
      alert("Ikke tilgængelig før du har tilladt brug af pop-up vinduer på denne side.");
    return false;
  }
  return true;
}
/* tringuide prototype 31+32 */

function stepguide_popup(path,e) 
{
  if (DetectActivate(e)){
    var win = window.open(path,"","width=776,height=510,resizable=0,status=0,toolbar=1,scrollbars=1");
    if (win == null)
      alert("Ikke tilgængelig før du har tilladt brug af pop-up vinduer på denne side.");
    return false;
  }
  return true;
}

function addToFavoritesPopUp( path , e)
{
  if (DetectActivate(e)){
    var win = window.open(path,"", "location=no, modal=yes, status=no, resizeable=no, scrollbars=no, width=250, height=120");
    
    if (win == null)
      alert("Ikke tilgængelig før du har tilladt brug af pop-up vinduer på denne side.");
      
    return false;
  }
  return true;
}

function DetectActivate(e)
{
 if (e)  //firefox etc.
  {
    if(e.keyCode==0 || e.keyCode == 13)  //tab
      return true;
  }
  else if (window.event)  //IE etc.
  {
    if(window.event.keyCode == 32 || window.event.keyCode==13)   //tab
      return true;
  }
  return false
}

/*----------------------------------------------------------*/
function magazineyear_onchange(path)
{
  var control=document.forms[0].year;
  var index=control.selectedIndex;
  var value=control[index].value;
  document.location.href=path+'?year='+value;  
}


