﻿var lastmenu=null;

window.addEvent('domready', function() { 

hideThem();

/*for (var i=0;i<document.getElementsByTagName('*').length;i++) 
{ 
    if (document.getElementsByTagName('*')[i].id.substr(0,3)=='cat')
    {
        var num=document.getElementsByTagName('*')[i].id.substr(3,document.getElementsByTagName('*')[i].id.length-3);
        
        if (document.getElementById('subMenu'+num)) 
        {    
            var taille=((eval('menucat'+num).getElementsByTagName('a').length-1)*24+20);
            
            eval("$('menucat"+num+"').addEvent('mouseclick',function(e) { e.stop();  hideThem('menucat"+num+"');   var effect=new Fx.Morph('menucat"+num+"',{duration: 'short', transition: Fx.Transitions.Sine.easeIn}); effect.start({ 'height': [(eval('menucat"+num+"').style.height)?eval('menucat"+num+"').style.height:'20px','"+taille+"px'] });  });");
            //eval("$('menucat"+num+"').addEvent('mouseout',function(e) { e.stop();   eval('menucat"+num+"').style.height='20px'; })"); 
            eval("$('menucat"+num+"').addEvent('mousemove',function(e) { e.stop(); })");
            eval("$('cat"+num+"').addEvent('mouseout',function(e) { e.stop(); })");
            //eval("$('subcat"+num+"').addEvent('mouseover',function(e) { })");
           //eval("var osubMenu"+num+"=$('subMenu"+num+"');")            
           //eval("$('cat"+num+"').addEvent('mouseover', function(e) { e.stop(); if ((lastmenu!=null)&&(lastmenu!='subMenu"+num+"')) {  var oldEffect = new Fx.Morph(lastmenu, {duration: 'short', transition: Fx.Transitions.Sine.easeIn});  oldEffect.start({ 'height': [eval(lastmenu).style.height, 0] }); } var myEffect = new Fx.Morph('subMenu"+num+"', {duration: 'short', transition: Fx.Transitions.Sine.easeIn});  myEffect.start({ 'height': [eval('subMenu"+num+"').style.height, 60] }); lastmenu='subMenu"+num+"'; });"); 
        }
     }
}

$('body').addEvent('mousemove',function(e) { e.stop(); hideThem0('');  });
*/

});

function hideMenus()
{
    hideThem(lastmenu);
}

function hideme(name)
{
   
    alert(name);
    var effect=new Fx.Morph(name,{duration: 'short', transition: Fx.Transitions.Sine.easeIn});
    effect.start({ 'height': [(eval(name).style.height)?eval(name).style.height:20,20] });
   
}

function hideThem(name)
{
    
    for (var i=0;i<document.getElementsByTagName('*').length;i++) 
    { 
        if ((document.getElementsByTagName('*')[i].id.substr(0,7)=='subMenu')&&(document.getElementsByTagName('*')[i].id!=name))
        {
            
            eval(document.getElementsByTagName('*')[i].id).style.display='none';
            //var effect=new Fx.Morph(document.getElementsByTagName('*')[i].id,{duration: 'short', transition: Fx.Transitions.Sine.easeIn});
            //effect.start({ 'height': [(eval(document.getElementsByTagName('*')[i].id).style.height)?eval(document.getElementsByTagName('*')[i].id).style.height:20,20] });
            //eval(document.getElementsByTagName('*')[i].id.substr(4,document.getElementsByTagName('*')[i].id.length-4)).style.backgroundImage='url(/images/menuCatalog.png)'; 
            //eval(document.getElementsByTagName('*')[i].id.substr(4,document.getElementsByTagName('*')[i].id.length-4)).style.backgroundColor='transparent';
        }
        else
        {
            /*if (document.getElementsByTagName('*')[i].id==name)
            {
                eval(document.getElementsByTagName('*')[i].id).style.display='block';
            }*/
        }
    }
  
    
}

function hideThem0(name)
{
   
    for (var i=0;i<document.getElementsByTagName('*').length;i++) 
    { 
        if ((document.getElementsByTagName('*')[i].id.substr(0,7)=='menucat')&&(document.getElementsByTagName('*')[i].id!=name))
        {
      
            eval(document.getElementsByTagName('*')[i].id).style.height='20px';
            //eval(document.getElementsByTagName('*')[i].id.substr(4,document.getElementsByTagName('*')[i].id.length-4)).style.backgroundImage='url(/images/menuCatalog.png)'; 
            //eval(document.getElementsByTagName('*')[i].id.substr(4,document.getElementsByTagName('*')[i].id.length-4)).style.backgroundColor='transparent';
            //var effect=new Fx.Morph(document.getElementsByTagName('*')[i].id,{duration: 'short', transition: Fx.Transitions.Sine.easeIn});
            //effect.start({ 'height': [(eval(document.getElementsByTagName('*')[i].id).style.height)?eval(document.getElementsByTagName('*')[i].id).style.height:60,60] });
        }
    }
}

window.onload=function() {
/*	if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
    }
	
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

	if (myHeight<yWithScroll)
	{
		document.getElementById('bottom').style.top=yWithScroll+'px';
		document.getElementById('accueilbtn').style.top=yWithScroll+25+'px';
	}
	else
	{
		document.getElementById('bottom').style.bottom=0;
		document.getElementById('accueilbtn').style.bottom='25px';
	}
	var rnd=Math.round(Math.random()*4)+1;
	var ajout="";
	var taille="";
	if (xWithScroll<myWidth) xWithScroll=myWidth;
	if (xWithScroll<=1280) taille='1280';
	if (xWithScroll<=1024) taille='1024';
	if ((window.location.href=="http://bleco.devstage.com/Front/Render.aspx")||(window.location.href=="http://bleco.devstage.com/Front/c2-141/Accueil.aspx"))
	   ajout='b';
	document.body.style.backgroundImage='url(/images/fond'+rnd+ajout+taille+'.jpg)';
	document.getElementById('bt1').className='';
    document.getElementById('bt2').className='';
    document.getElementById('bt3').className='';
    document.getElementById('bt4').className='';
    document.getElementById('bt5').className='';
    document.getElementById('bt'+rnd).className='on';*/
}
window.onresize=function() {
	//window.location.reload(true);
}

function showfond(id)
{
    if (window.innerHeight && window.scrollMaxY) {// Firefox
        yWithScroll = window.innerHeight + window.scrollMaxY;
        xWithScroll = window.innerWidth + window.scrollMaxX;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
        yWithScroll = document.body.scrollHeight;
        xWithScroll = document.body.scrollWidth;
    } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
        yWithScroll = document.body.offsetHeight;
        xWithScroll = document.body.offsetWidth;
    }
	
	var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

    var ajout="";
    var taille="";
    if (xWithScroll<myWidth) xWithScroll=myWidth;
    if (xWithScroll<=1280) taille='1280';
	if (xWithScroll<=1024) taille='1024';
	if (window.location.href=="http://bleco.devstage.com/Front/Render.aspx")
	   ajout='b';
    document.body.style.backgroundImage='url(/images/fond'+id+ajout+taille+'.jpg)';
    document.getElementById('bt1').className='';
    document.getElementById('bt2').className='';
    document.getElementById('bt3').className='';
    document.getElementById('bt4').className='';
    document.getElementById('bt5').className='';
    document.getElementById('bt'+id).className='on';
    
}
