ns = document.layers;   // 4.0 < ns < 6.0
ie  = document.all;     // for all internet explorers
              // ie4 only
w3 = document.getElementById; // ie5 and ns6 w3 consortium DOM
ie4 = ie&&!w3; 

if (w3 && !ie){
    ns6 = true;  
	moz = true;
}
else{
    ns6 = false;  
	moz = false;
}

mac=(navigator.userAgent.toLowerCase().indexOf('mac'))!=-1;
ie7 = (navigator.userAgent.toLowerCase().indexOf('msie 7'))!=-1;



cmo_counter=0;
i_mover = new Array();
i_mout  = new Array();
i_click = new Array();
function createPngMouseOver(imageObject,moverSrc,clickSrc)
{
		/*if(imageObject.name)
			imageObject.id = imageObject.name
		else if (imageObject.id){
			imageObject.name = imageObject.id;
		}*/
		imageObject.index = cmo_counter;
		imageObject.selected = false;
		i_mover[cmo_counter]=new Image();i_mover[cmo_counter].src=moverSrc;
		i_mout[cmo_counter]=new Image();i_mout[cmo_counter].src=imageObject.src;
		if(ie&&!mac&&!ie7)
		{
		imageObject.mouseover=function iecmo_over(){
		//alert(i_mover[this.index].src);
			this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i_mover[this.index].src+  "',sizingMethod='scale')";
				}
		imageObject.mouseout=function iecmo_out(){
			if(!this.selected)
				//this.src=i_mout[this.index].src
				this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ i_mout[this.index].src+  "',sizingMethod='scale')";
				}
		}
		else{
			imageObject.mouseover=function cmo_over(){this.src=i_mover[this.index].src}
			imageObject.mouseout=function cmo_out(){if(!this.selected)this.src=i_mout[this.index].src}
		}
		if(clickSrc)
		{	
			i_click[cmo_counter]=new Image();i_click[cmo_counter].src=clickSrc;
			if(ie&&mac&&!ie7){
			imageObject.click=function iecmo_click(){
				this.selected=true;
				this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+i_click[this.index].src+  "',sizingMethod='scale')";
			}
			}else{
			imageObject.click=function cmo_click(){
				this.selected = true;
				
				this.src = i_click[this.index].src;
			}
			}
		}
		cmo_counter++;
		imageObject.onload="";
		fixPNG(imageObject);
}	
function fixPNG(imgObj)
{   

	imgObj.onload=function rien(){};
	if(ie7) return;
	if (ie&&!mac)
	{
		w=imgObj.width;h=imgObj.height;
		imgObj.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ imgObj.src+  "',sizingMethod='scale')";
		imgObj.src="images/clear.gif";
		imgObj.style.width=w;
		imgObj.style.height=h;
	}
	imgObj.style.visibility="inherit";
	
}

function createNav(imgObj,onsrc,selectsrc)
{
	createPngMouseOver(imgObj,onsrc,selectsrc);
	imgObj.onmouseover = function(){
		if(!this.selected)
		{
			this.mouseover();
			//this.previousSibling.mouseover();
		}
	}
	imgObj.onmouseout = function(){
		if(!this.selected)
		{
			this.mouseout();
			//this.previousSibling.mouseout();
		}
	}
	//imgObj.onmousedown = function(){
		//toggle(this);
	//}
}

/*SelectedNav = null;
function toggle(imgObj)
{
	
			
	if(!imgObj.selected)
	{
		if(SelectedNav)
			toggle(SelectedNav);
		imgObj.selected=true;
		imgObj.previousSibling.click();
		imgObj.nextSibling.style.display="block";
		SelectedNav = imgObj;
		
	}else{
		imgObj.nextSibling.style.display="none";
		imgObj.selected=false;
		imgObj.previousSibling.selected=false;
		imgObj.previousSibling.mouseout();
		imgObj.onmouseout();
		SelectedNav = null;
	}
		
	
}
*/

onImg = new Array();
offImg = new Array();
selectedID = null;
function preload(imgObject)
{
	offImg[imgObject.id] = new Image();
	offImg[imgObject.id].src = imgObject.src;
	onImg[imgObject.id] = new Image();
	onImg[imgObject.id].src = imgObject.src.replace(/\.gif$/,'_on.gif');
	imgObject.init = true;
	imgObject.onload=function doNothing(){}
}
pimg=new Array();
function preload2(srcc)
{
	nx = pimg.length;
	pimg[nx]=new Image();
	pimg[nx].src=srcc;
}
function mo(n)
{
	im = document.images['n'+n];
	if(im.id != selectedID){
		im.src = onImg[im.id].src;
	}
	
	// when we mouseover we have to hide the 
	// the grey separators
	
	document.images['n'+(n+1)].style.visibility="hidden"
	document.images['n'+(n-1)].style.visibility="hidden"
}
function mout(n)
{
	im = document.images['n'+n];
	if(im.id !=selectedID)
	{
		//alert(offImg[im.id].src);
		im.src = offImg[im.id].src;
	}
	
	// when we mouse-out we make the separators disappear
	// except those that are selected
	
	if((n-1)!=inter1 && (n-1) != inter2)
		document.images['n'+(n-1)].style.visibility="visible";
	if((n+1)!=inter1 && (n+1) != inter2)
		document.images['n'+(n+1)].style.visibility="visible"
}

inter1 = null;
inter2 = null;

// function to set menu selection
//
function _select(n)
{
	if(n!=selectedID&&selectedID!=null)
	{	oldSelected = inter1+1;
		inter1=inter2=null;
		selectedID=null;
		mout(oldSelected);
	}
	inter1 = n-1;
	inter2 = n+1;
	selectedID = 'n'+n;
	mo(n);
}