
  function getForm(name)
  {
    var f;
    if (!name)
    {
      f = document.getElementsByTagName("form")[0];
    }
    else
    {
      f = document.forms[name];
    }
    return f;
  }

	function fatlasRecommend(form)
	{
    f = getForm(form);
		f.method = "post";
		f.action = "http://www.dr.dk/php/drmu/forfatteratlas/user_input.php";
		f.submit();
	}

  function fatlasSearch()
	{
		var loc = "?";
		loc += "q=" + escape(encode64(document.getElementById("fatlasSearchQ").value)) + "&";
		loc += "mode=" + document.getElementById("fatlasSearchMode").value + "&";
		loc += "page=" + document.getElementById("fatlasSearchPage").value + "&";
		loc += "id=" + document.getElementById("fatlasSearchID").value + "&";
		loc += "last=" + document.getElementById("fatlasSearchLast").value;
		document.location = loc;
	}

	function fatlasRate(id, form)
	{
		f = getForm(form);
    document.getElementById("rating_" + id).name = "rating";
    document.getElementById("book_" + id + "_id").name = "book_id";
		f.method = "post";
		f.action = "http://www.dr.dk/php/drmu/forfatteratlas/user_input.php";
		f.submit();
	}


  function showVideo(file)
  {
    var element = document.getElementById("videoHolder");
    var playerHtml = '<object standby="Henter banner..." type="application/x-shockwave-flash" data="http://www.dr.dk/ff/forfatteratlas/mediaplayer.swf" width="100%" height="400">';
    playerHtml += '<param name="movie" value="http://www.dr.dk/ff/forfatteratlas/mediaplayer.swf"/>';
    playerHtml += '<param name="wmode" value="transparent"/>';
    playerHtml += '<param name="allowfullscreen" value="true"/>';
    playerHtml += '<param name="flashvars" value="autostart=true&amp;file=' + file + '&amp;backcolor=0x96abc3&amp;lightcolor=0xFFFFFF&amp;screencolor=0x96abc3 "/>';
    playerHtml += '</object>';
    element.innerHTML = playerHtml;
    element.style.display = 'block';
  }
  
  function showAudio(file)
  {
    var element = document.getElementById("videoHolder");
    var playerHtml = '<object standby="Henter banner..." type="application/x-shockwave-flash" data="http://www.dr.dk/ff/forfatteratlas/mediaplayer.swf" width="100%" height="20">';
    playerHtml += '<param name="movie" value="http://www.dr.dk/ff/forfatteratlas/mediaplayer.swf"/>';
    playerHtml += '<param name="wmode" value="transparent"/>';
    playerHtml += '<param name="allowfullscreen" value="true"/>';
    playerHtml += '<param name="flashvars" value="autostart=true&amp;file=' + file + '&amp;backcolor=0x96abc3&amp;lightcolor=0xFFFFFF&amp;screencolor=0x96abc3 "/>';
    playerHtml += '</object>';
    element.innerHTML = playerHtml;
    element.style.display = 'block';
  }
  
  var LOCAL = 1;
  var ALTERNATE = 2;
  var INTERNATIONAL = 3;
  
  function switchLangauge(holder, type)
  {
    var divs = holder.getElementsByTagName("div");
    for (var i=0; i < divs.length; i++)
    {
      var tag = divs[i];
      switch (tag.className)
      {
        case "local":
        tag.style.display = (type == LOCAL ? 'block' : 'none');
        tag.style.background = (type == LOCAL ? 'white' : '#CCC');
        break;
		
		case "alternate":
        tag.style.display = (type == ALTERNATE ? 'block' : 'none');
        tag.style.background = (type == ALTERNATE ? 'white' : '#CCC');
        break;
        
        case "international":
        tag.style.display = (type == INTERNATIONAL ? 'block' : 'none');
        tag.style.background = (type == INTERNATIONAL ? 'white' : '#CCC');
        break;
        
        case "language_selection":
        
        var as = tag.getElementsByTagName("a");
        for (var j=0; j < as.length; j++)
        {
          var a = as[j];
          switch (a.className)
          {
            case "local":
            a.style.borderBottom = (type == LOCAL ? '1px solid white' : '1px solid #bdc15f');
            a.style.background = (type == LOCAL ? 'white' : '#e3ff56');
            break;
			
			case "alternate":
            a.style.borderBottom = (type == ALTERNATE ? '1px solid white' : '1px solid #bdc15f');
            a.style.background = (type == ALTERNATE ? 'white' : '#e3ff56');
            break;
            
            case "international":
            a.style.borderBottom = (type == INTERNATIONAL ? '1px solid white' : '1px solid #bdc15f');
            a.style.background = (type == INTERNATIONAL ? 'white' : '#e3ff56');
            break;
          }
        }
        break;
      }
    }
  }
  
  
  
  var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

  function encode64(input)
  {
    var output = "";
    var chr1, chr2, chr3;
    var enc1, enc2, enc3, enc4;
    var i = 0;
    
    do
    {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);
      
      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;
      
      if (isNaN(chr2))
      {
        enc3 = enc4 = 64;
      }
      else if (isNaN(chr3))
      {
        enc4 = 64;
      }
      
      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
    }
    while (i < input.length);
   
    return output;
  }

