function s(word, elmt) {
	var hLayer = getHtmlObj('menu');
	var coord = getCoord(elmt);
	hLayer.style.left = coord.x+5;
	hLayer.style.top = coord.y+20;
	hLayer.innerHTML = '<div style="text-align:right;font-size:0.8em;"><a href="#" onclick="getHtmlObj(\'menu\').style.display=\'none\'; return false;">Fermer</a>&nbsp;</div><div><div id="ajaxLoad-search"><img src="img/ajax-loader-red.gif" /></div></div>'
	
	hLayer.style.display = '';
	
	search(word, hLayer.childNodes[1]);
	
}

function search(word, hLayer) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", 'fullTextSearch.php?key='+word, true);	// async
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				_processSearchResults(xmlHttp.responseText, hLayer);
			} else {
				hLayer.innerHTML = 'Erreur : '+xmlHttp.statusText;
			}
		}
	};
	
	// call in new thread to allow ui to update
	window.setTimeout(function () {
		xmlHttp.send(null);
	}, 10);
}

// depends de swapstyle.js
function setCSS(s) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", 'css_switch.php?skin='+s, true);	// async
	
	// call in new thread to allow ui to update
	window.setTimeout(function () {
		xmlHttp.send(null);
	}, 10);

	changeStyle(s);
}


function _processSearchResults(oXml, hLayer) {
	/*
	if( oXml != null && oXml.documentElement != null ) {
		var root = oXml.documentElement;
		hLayer.innerHTML = '';
		var str = '';
		for(var i=0;i<root.childNodes.length; i++) {
				str += root.childNodes[i].childNodes[0]+'<br />';	
		}
		hLayer.innerHTML = str;
	} else {
		// nothing
		hLayer.innerHTML = 'Erreur dans le chargement.';
	}
	*/
	hLayer.innerHTML = oXml;
}


function ajaxLoad() {
	doAjaxLoad('ajaxload_yahoo');
	doAjaxLoad('ajaxload_flickr');
	doAjaxLoad('ajaxload_auto_suggestions');
}


function doAjaxLoad(htmlContainerId) {
	var xmlHttp = XmlHttp.create();
	xmlHttp.open("GET", htmlContainerId+'.php', true);	// async
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-Type", "text/xml; charset=UTF-8");
	xmlHttp.onreadystatechange = function () {
		if (xmlHttp.readyState == 4) {
			if(xmlHttp.status == 200) {
				document.getElementById(htmlContainerId).innerHTML = xmlHttp.responseText;
			} else {
				hLayer.innerHTML = 'Erreur : '+xmlHttp.statusText;
			}
		}
	};
	
	// call in new thread to allow ui to update
	window.setTimeout(function () {
		xmlHttp.send(null);
	}, 10);
}
