function swapHtml(objName, newText) {
  if ((obj=document.getElementById(objName))!=null) with (obj) 
    if (navigator.appName=='Netscape' && navigator.userAgent.indexOf('Safari') == -1 && navigator.userAgent.indexOf('Gecko') == -1) {document.write(unescape(newText)); document.close();} 
    else innerHTML = unescape(newText); 
}

function swapImg(objName, mode) {
	obj=document.getElementById(objName);
	if (mode == 'over') {
		obj.src = 'images/'+objName+'_over.jpg';
	} else {
		obj.src = 'images/'+objName+'.jpg';		
	}
}

function hideInfos() {
	swapHtml('link_description', dataInfos['default']);
}

function displayInfos(pointer) {
	swapHtml('link_description', dataInfos[pointer]);
}

var subMenus = ['autoprod', 'clients', 'projets', 'connexion'];

function switchSubMenu(target) {
	for(i=0;i<subMenus.length;++i) {
		obj = document.getElementById(subMenus[i]);
		if (target == subMenus[i]) {
			obj.style.visibility = 'visible';
		} else {
			obj.style.visibility = 'hidden';
		}
	}
}

var g = 1;
var r = 5;
zstatus = [0, 0, 0, 0, 0, 0, 0];
smin = 1;
smax = 10;

function ZoomIn(i) {
	if (zstatus[i] != 1) return;
	o = document.getElementById("newscontent"+i);
	s = parseInt(o.style.fontSize);
	if (isNaN(s)) {s = smin};
	if (s < smax) {
		o.style.display = 'block';
		s += g;
		o.style.fontSize = s+"px";
		t = setTimeout("ZoomIn("+i+");", r);
	} else {
		zstatus[i] = 0;
	}
}

function ZoomOut(i) {
	if (zstatus[i] != 2) return;
	o = document.getElementById("newscontent"+i);
	s = parseInt(o.style.fontSize);
	if (s > smin) {
		s -= g;
		o.style.fontSize = s+"px";
		t = setTimeout("ZoomOut("+i+");", r);
	} else {
		zstatus[i] = 0;
		o.style.display = 'none';
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function showRub(requis, cible, script) {
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { alertContents(http_request, cible); };
	http_request.open('GET', 'inc/'+script+'.php?c='+requis, true);
	http_request.send(null);
}

function alertContents(http_request, cible) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			swapHtml(cible, http_request.responseText);
		} else {
			alert('There was a problem with the request.');
		}
	}
}

function closeAjax() {
	o = document.getElementById('ajax_layer');
	o.style.visibility = 'hidden';
}

function showContacts(lang) {
	o = document.getElementById('ajax_layer');
	o.style.background = 'url(./images/contact_background.jpg) top left no-repeat';
	o.style.visibility = 'visible';
	showRub(lang, 'ajax_layer', 'contact.inc');
}