function initPage (){
	externalLinks();
	showmenu();
}

/*
Menu JS functions for IE
*/
function ShowContent(id){
	$(id).style.display = 'block';
}
function showmenu() {
        // code for IE
        if(!document.body) return;
        var subs = document.getElementsByName('submenu');
        for(var i=0; i<subs.length; i++) {
                var li = subs[i].parentNode;
                if(li && li.lastChild.style) {
                        li.onmouseover = function() {
                                this.lastChild.style.visibility = 'visible';
                        }
                        li.onmouseout = function() {
                                this.lastChild.style.visibility = 'hidden';
                        }
                }
        }
}

/*
Rateit
Used for capture and send votes to the RateIt plugin.
must receive the entry id and the vote and will show the 'Voting' text while the vote is being sended.
*/
function RateIt (entry,value) {
	var url = '/mt/mt-RateIt.cgi';
	var pars = 'entry_id='+entry+'&value='+value;
	var target = 'RateIt-'+entry;
	var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});
	d = document.getElementById(target);
	d.innerHTML = "<i>Voting...</i>";
}
function Wtf (entry,value) {
	var url = '/mt/mt-Wtf.cgi';
	var pars = 'entry_id='+entry+'&value='+value;
	var target = 'Wtf-'+entry;
	var myAjax = new Ajax.Updater(target, url, {method: 'get', parameters: pars});
	d = document.getElementById(target);
	d.innerHTML = "<i>Wtf-ing...</i>";
}

/*
Opens external links in new window
*/
function externalLinks () {
 //if (!document.getElementsByTagName) return;
 	$$("a").each(function(anchor){
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 });
}

/*
This is for the submit keys
*/
var submit_key_sending = 0;
function send_submission (form,url) {

  if ( submit_key_sending == 1 ) { return false }

  new Ajax.Request('/secret.cgi', {
    method: 'post',
    parameters: { a: Math.random() },
    onSuccess: function(transport) {
      if (transport.responseText != 'ERROR') {
        form.action = url + '/' + transport.responseText;
        form.submit();
      }
    }
  });

  submit_key_sending = 1;
  return false;
}

window.onload = initPage;
