var allEvents = new Array();
var activeMenu = null; //defines which menu is currently open
var activeMenuImg = null;
var mouseX = mouseY =0;
var leftX = 0;
var	rightX = 0;
var leftY = 0;
var rightY = 0;
var javascriptVersion1_1 = true;
var detectableWithVB = false;
var pluginFound = false;
var subtest=0;
var menuopened=false;

if (!document.all)
	{
	document.writeln('<style type="text/css">');
	document.writeln('.c, .click {cursor:pointer}');
	document.writeln('.noborder {border:1px solid}');
	document.writeln('</style>');
	}

if (document.all) classFix = "className";
else classFix = "class";

if (document.images)
{
	var MenuImgRoot="http://www.itechno.com/img/en/";
 	var imagesOn = new Array( );
    imagesOn["img_soc"] = new Image(93,18);
    imagesOn["img_soc"].src = MenuImgRoot + "soc_m_top_on.gif";
    imagesOn["img_pro"] = new Image(103,18);
    imagesOn["img_pro"].src = MenuImgRoot + "pro_m_top_on.gif";
    imagesOn["img_sol"] = new Image(110,18);
    imagesOn["img_sol"].src = MenuImgRoot + "sol_m_top_on.gif";
    imagesOn["img_sup"] = new Image(165,18);
    imagesOn["img_sup"].src = MenuImgRoot + "sup_m_top_on.gif";
    imagesOn["img_ach"] = new Image(174,18);
    imagesOn["img_ach"].src = MenuImgRoot + "ach_m_top_on.gif";
  var imagesOff = new Array( );
    imagesOff["img_soc"] = new Image(93,18);
    imagesOff["img_soc"].src = MenuImgRoot + "soc_m_top.gif";
    imagesOff["img_pro"] = new Image(103,18);
    imagesOff["img_pro"].src = MenuImgRoot + "pro_m_top.gif";
    imagesOff["img_sol"] = new Image(110,18);
    imagesOff["img_sol"].src = MenuImgRoot + "sol_m_top.gif";
    imagesOff["img_sup"] = new Image(165,18);
    imagesOff["img_sup"].src = MenuImgRoot + "sup_m_top.gif";
    imagesOff["img_ach"] = new Image(174,18);
    imagesOff["img_ach"].src = MenuImgRoot + "ach_m_top.gif";
}

function imgShow(imgID)
{
	var oImg;

	if (document.images)
	{	
		oImg = document.images[imgID];
		oImg.src = imagesOn[imgID].src;
		activeMenuImg = oImg;
	}
}

function imgHide()
{
	if (document.images)
	{	
		if (activeMenuImg != null)
		{
			var section = 'Produits';
			section = section.substr(0, 3);
			activeMenuImg.src = imagesOff[activeMenuImg.id].src;
		}
	}
}

function getAbsPosition( element, topElement )
{
	if( topElement == null ) // if topElement is not specified
		topElement = document.body; // use the body as the root
	var x = 0;
	var y = 0;
	for( var temp = element; temp != topElement; temp = temp.offsetParent )
	{
		x += temp.offsetLeft;
		y += temp.offsetTop;
	}
	var position = new Object();
	position.left = x;
	position.top = y;
	return position;
	}
	
function menuOver()
	{
	document.onclick = null;
	if (document.all) event.cancelBubble=true
	}

function menuOut()
	{
	//document.onmouseout = 
	eventHideMenu;
	if (document.all) event.cancelBubble=true
	}

function eventShowMenu(e)
	//turns on the display for nav menus
	{
	var mainMenu;
	var posMenu;

	if (activeMenu != null) eventHideMenu()
	mainMenu = "nav"+this.id.substring(3,this.id.length);
	activeMenu = "sm"+this.id.substring(3,this.id.length);
	imgmenu = "img"+this.id.substring(3,this.id.length);
	
	MenuItem = activeMenu+"_i";
	obj = document.getElementById(activeMenu);
	mMobj = document.getElementById(mainMenu);
	mIobj = document.getElementsByName(MenuItem);
	
	posMenu = getAbsPosition(mMobj);
	menuleftX = posMenu.left;
	menurightX = menuleftX + mMobj.offsetWidth;
	menuleftY = posMenu.top;
	menurightY = menuleftY + mMobj.offsetHeight;
	
	if (obj) 
		{
		imgShow(imgmenu);
		obj.style.top = menurightY;
		obj.style.left = menuleftX;
		obj.style.width = mMobj.offsetWidth;
		obj.style.visibility = "visible";
		
		leftX = menuleftX;
		leftY = menuleftY;
		rightX = menurightX;
		rightY = menurightY + obj.offsetHeight;
		
		}
	if(mIobj.length > 0)
		{
		for (j=0; j < mIobj.length; j++) mIobj[j].style.width = "100%";
		}
	if (document.all) document.onclick = eventHideMenu;
	event.cancelBubble=true
	}

function eventHideMenu()
	//hides nav menus and pop ups
	{
	document.onclick = null;
	if (activeMenu != null) 
		{
		imgHide();
		obj = document.getElementById(activeMenu)
		obj.style.visibility = "hidden"
		activeMenu = null;
		}
	}

function Update(e)
	{
	var posMainMenu;
	var lMenu;
	var tMenu;
	if ( activeMenu != null)
	{
			var x = mouseX;
			var y = mouseY;
			if (activeMenu != null)
			{
				//AfficPosObj= document.getElementById('taille');
				//AfficPosObj.innerHTML= activeMenu + '<br>' + leftX + ' ; ' + rightX + '<br>' + leftY  + ' ; ' + rightY;
			}
			if (x > rightX || x < leftX ) eventHideMenu();
				else if (y > rightY || y < leftY ) eventHideMenu();
	}
}

menus = new Array("soc","pro","sup","ach");

function userEventsInit()
	{
	//nav events
		for (i=0; i < menus.length; i++)
		{
		obj = document.getElementById("nav_"+menus[i])
		obj.onmouseover = eventShowMenu;
		}
	}

function mousePosition(e)
	{
	if (e) event = e;   //for Netscape
	//mouseX = event.clientX;
	//mouseY = event.clientY;
	
	if (event.pageX) {
        mouseX = event.pageX;
        mouseY = event.pageY;
    } else if (event.clientX) {
        mouseX = event.clientX + document.body.scrollLeft - document.body.clientLeft;
        mouseY = event.clientY + document.body.scrollTop - document.body.clientTop;
	}

	//AfficPosObj= document.getElementById('pos');
	//AfficPosObj.innerHTML= 'Mouse :' + mouseX + ' ; ' + mouseY
	Update(e);
	}

function initialize()
	//runs at onload of window
	{
	userEventsInit(); //set up all user events
	document.onmousemove = mousePosition; //moz
	}
	

function displayFix()
	//in IE there is a bug will cause some elements to not draw on screen when the user uses the back button
	//the below fixes that problem by forcing the page to redraw
	{
	document.getElementById("bodyNode").style.display = "block"
	}

function redirectCheck(pluginFound, redirectURL, redirectIfFound) {
    // check for redirection
    if( redirectURL && ((pluginFound && redirectIfFound) || 
	(!pluginFound && !redirectIfFound)) ) {
	// go away
	goURL(redirectURL);
	return pluginFound;
    } else {
	// stay here and return result of plugin detection
	return pluginFound;
    }	
}
function canDetectPlugins() {
    if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) {
	return true;
    } else {
	return false;
    }
}

function detectFlash(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Shockwave','Flash'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('ShockwaveFlash.ShockwaveFlash.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectDirector(redirectURL, redirectIfFound) { 
    pluginFound = detectPlugin('Shockwave','Director'); 
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('SWCtl.SWCtl.1');
    }
    // check for redirection
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectQuickTime(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('QuickTime');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectQuickTimeActiveXControl();
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectReal(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('RealPlayer');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = (detectActiveXControl('rmocx.RealPlayer G2 Control') ||
		       detectActiveXControl('RealPlayer.RealPlayer(tm) ActiveX Control (32-bit)') ||
		       detectActiveXControl('RealVideo.RealVideo(tm) ActiveX Control (32-bit)'));
    }	
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectWindowsMedia(redirectURL, redirectIfFound) {
    pluginFound = detectPlugin('Windows Media Player');
    // if not found, try to detect with VisualBasic
    if(!pluginFound && detectableWithVB) {
	pluginFound = detectActiveXControl('MediaPlayer.MediaPlayer.1');
    }
    return redirectCheck(pluginFound, redirectURL, redirectIfFound);
}

function detectPlugin() {
 	// allow for multiple checks in a single pass
  var daPlugins = detectPlugin.arguments;
  // consider pluginFound to be false until proven true
  var pluginFound = false;
  // if plugins array is there and not fake
  if (navigator.plugins && navigator.plugins.length > 0) {
	var pluginsArrayLength = navigator.plugins.length;
	// for each plugin...
	for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) {
		// loop through all desired names and check each against the current plugin name
	  var numFound = 0;
	  for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) {
			// if desired plugin name is found in either plugin name or description
			if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || 
		    (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) {
		    // this name was found
		    numFound++;
			}   
	    }
	    // now that we have checked all the required names against this one plugin,
	    // if the number we found matches the total number provided then we were successful
	    if(numFound == daPlugins.length) {
		pluginFound = true;
		// if we've found the plugin, we can stop looking through at the rest of the plugins
		break;
	    }
	}
    }
    return pluginFound;
}

function goURL(daURL) {
    // if the browser can do it, use replace to preserve back button
    if(javascriptVersion1_1) {
	window.location.replace(daURL);
    } else {
	window.location = daURL;
    }
    return;
}

function closenav(){
		if (subtest != 0) {
			subtest.style.display="none";	
			menuopened=false;
			}
	}

function nav(subsection) {
		if (subtest != eval(subsection)) {
			//alert(subsection);
			//alert(subtest);
			if (subtest!=0){
				subtest.style.display="none";
				menuopened=false;
			}
			document.getElementById(subsection).style.display="block";
			menuopened=true;
		}
		else {
  			if (menuopened == false) {
					document.getElementById(subsection).style.display="block";
					menuopened=true;
				}
				else {
    			document.getElementById(subsection).style.display="none";
    			menuopened=false;
				}
		}
	subtest=document.getElementById(subsection);
	}