//Executes functions at page load
function addLoadEvent(func) 
{
  var oldonload = window.onload;
  
  if (typeof window.onload != 'function') 
  {
    window.onload = func;
  } 
  else 
  {
    window.onload = function()
    {
      if (oldonload) 
      {
        oldonload();
      }
      func();
    }
  }
}

//Actions
function attachAction() {
   if (document.getElementById) 
   {
      if (document.getElementById('About')) 
      {
           element = document.getElementById('About');
           element.onmouseover = function() 
           {
               homeOver(this,"jpg");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"jpg");
           }
      }
      if (document.getElementById('AboutMenuTop')) 
      {
           element = document.getElementById('AboutMenuTop');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
      if (document.getElementById('AboutMenuBottom')) 
      {
           element = document.getElementById('AboutMenuBottom');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
      
      if (document.getElementById('Contact')) 
      {
           element = document.getElementById('Contact');
           element.onmouseover = function() 
           {
               homeOver(this,"jpg");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"jpg");
           }
      }
      if (document.getElementById('ContactMenuTop')) 
      {
           element = document.getElementById('ContactMenuTop');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
      if (document.getElementById('ContactMenuBottom')) 
      {
           element = document.getElementById('ContactMenuBottom');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
      
      if (document.getElementById('Work')) 
      {
           element = document.getElementById('Work');
           element.onmouseover = function() 
           {
               homeOver(this,"jpg");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"jpg");
           }
      }
      if (document.getElementById('WorkMenuTop')) 
      {
           element = document.getElementById('WorkMenuTop');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
      if (document.getElementById('WorkMenuBottom')) 
      {
           element = document.getElementById('WorkMenuBottom');
           element.onmouseover = function() 
           {
               homeOver(this,"png");
           }
           element.onmouseout = function() 
           {
               homeOut(this,"png");
           }
      }
   }
}

//Add attachAction to page
addLoadEvent(attachAction);

//shows other image on mouseOver on home page
function homeOver(element,type)
{
  var section = element.id;
  section = First2LowerCase(section);
  element.style.backgroundImage="url(images/layout/"+section+"Over."+type+")";
}

//shows other image on mouseOut on home page
function homeOut(element,type)
{
  var section = element.id;
  section = First2LowerCase(section);
  element.style.backgroundImage="url(images/layout/"+section+"BW."+type+")";
}


function First2LowerCase(texte) 
{
	var t = new Array();
	for(j=0 ; j < texte.length ;j++) 
	{
		if(j == 0) t[j] = texte.substr(j,1).toLowerCase();
		else t[j] = texte.substr(j,1);
	}
	return t.join('');
}