function setfocus(eid){
	document.getElementById("i"+eid).focus();
}

function rvoid(){
	return true;
}

function wait(){
	return true;
}

function stopandgo(fid){ }

function refocus(fid){
	document.getElementById("i"+fid).focus();
}

function iiframe(src,fid){
	var f = document.createElement("iframe");
	//var fdiv = document.getElementById("if"+fid);
	var fdiv = document.getElementById("if");
	f.setAttribute("src",src);
	f.setAttribute("width","0");
	f.setAttribute("height","0");	
	f.setAttribute("style","width:0;height:0;margin-left:-10000px;margin-top:-10000px;");
	if (fdiv.firstChild){
		fdiv.replaceChild(f,fdiv.firstChild);
	}
	else
		fdiv.appendChild(f);	
	//setTimeout("refocus("+fid+")",1000);
}

function homelink(){
	if(navigator.appName=="Microsoft Internet Explorer"){	
		home = "Faites de ce site votre page d'accueil";
		blank = " | ";
	
		// create a P element, using the variable eDIV as a reference to it
		linkdata = document.createElement("span");
		blankdata = document.createElement("span");

		//use the setAttribute method to assign it an id
		linkdata.setAttribute("id","homelink");	
		linkdata.appendChild(document.createTextNode(home));
		
		blankdata.setAttribute("id","blanklink");	
		blankdata.appendChild(document.createTextNode(blank));

		// append your newly created DIV element to an already existing element.
		document.getElementById("homed").appendChild(linkdata);
		document.getElementById("blankd").appendChild(blankdata);	
	}
}

function homedivs(){
	
	if(navigator.appName=="Microsoft Internet Explorer"){			
		document.getElementById("pageMOZ").style.display="none";
		document.getElementById("pageMSF").style.display="block";
	
	}
	else{
		document.getElementById("pageMOZ").style.display="block";
		document.getElementById("pageMSF").style.display="none";
	}
}

function sHomePage(url){
		document.body.style.behavior='url(#default#homepage)';		
		document.body.setHomePage(url);
}

function createRequestObject() { 
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function formBuilder(id) {
    http.open('get', 'linker.php?id='+id);
    http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 1997 00:00:00 GMT" );
    http.send(null);
}

function stats(eid,q){
    http.open('get', '/res/stats.php?eid='+eid+'&q='+q, false);
    http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 1997 00:00:00 GMT" );
    http.send(null);
    return false;
}

var gfid = "";

////// TLFI  //////

var tlfis = null;

function tlfi(fid){
	
    gfid = fid;
    document.getElementById('i'+gfid).enable = false;
    http.open('get', './res/tlfi.php');
    http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 1997 00:00:00 GMT" );
    http.onreadystatechange = handleTLFIResponse;
    http.send(null);
}

function handleTLFIResponse() {
    if(http.readyState == 4){
		
        tlfis = http.responseText;
		document.getElementById('i'+gfid).enabled = true;
    }
}

////// NATIONAL GEOGRAPHICS  //////

var ng = null;

function fng(fid,c){
    gfid = fid;
    document.getElementById('i'+gfid).enabled = false;
    http.open('get', './res/ngsoap.php?q='+c);
    http.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 1997 00:00:00 GMT" );
    http.onreadystatechange = handleNGResponse;
    http.send(null);
}

function handleNGResponse() {
    if(http.readyState == 4){
		ng = http.responseText;
		document.getElementById('i'+gfid).enabled = true;
    }
}

var searchword = 'null';
var iid = 'null';
var isSt = false;

function popit(theid){
	
	if (theid.substring(1,3) == 'st') {  iid = theid.substring(3);  isSt = true; }
	else if (theid.substring(0,4) == 'bist') { iid = theid.substring(4);  isSt = true; }
	else if (theid.substring(0,1) == 'b') {  iid = theid.substring(2);  isSt = false; }
	else { iid =  theid.substring(1);  isSt = false; }
	var preStr = 'i';
	if (isSt) preStr = 'ist';
	
	searchword = document.getElementById(preStr+iid).value;
	stats(iid,searchword);
	window.open('/action.php','','',true);
}

function MyEvent(currentTarget) {
    this.currentTarget  = currentTarget;
    this.preventDefault = function() { window.event.returnValue = false; }
    return this;
}

function popupPassParams(args) {
	return function(e){
		var code;
		if (!e.target) {  var e = window.event; }
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;
		if (code == 13) {  popit(args);  if (window.event)  window.event.returnValue = false; }
		else if (args.substring(0,1) == 'b')  popit(args); 
	}
}

function listen(event, elem, func) {
	if (typeof elem == "string") 
        elem = document.getElementById(elem);
    if (elem){
    	if (elem.addEventListener)  
        	elem.addEventListener(event,func,false); 
    	else if (elem.attachEvent) 
        	elem.attachEvent('on'+event, function(){ func(new MyEvent(elem)) } );   
   }
}

function initListeners(){
	
	for (i = 0 ; i < 999 ; i++){
		if (document.getElementById('i'+i)){
				listen('keypress','i'+i,popupPassParams('i'+i));
				listen('click','bi'+i,popupPassParams('bi'+i));
		}
		if (document.getElementById('ist'+i)){
				listen('keypress','ist'+i,popupPassParams('ist'+i));
				listen('click','bist'+i,popupPassParams('bist'+i));
				
		}
	}
}




var cpt = 0;
function Ajouter(){
	data = '<p>&nbsp;</p><img src="images/dot.gif" height="1" width="185" alt="" id="dot" /><p>&nbsp;</p><p><label for="destinataire[]">Prénom de votre ami :</label></p><input type="text" name="destinataire[]" size="27" maxlength="45" value=""><br /><br /><p><label for="destinaire_mail[]">Son adresse courriel :</label></p><input type="text" name="destinataire_mail[]" size="27" maxlength="45" value="">';
	d = document.createElement("div");
	d.setAttribute("id","e"+cpt);
	d.appendChild(document.createTextNode(""));
	document.getElementById("amis").appendChild(d);
	document.getElementById("e"+cpt).innerHTML = document.getElementById("e"+cpt).innerHTML + data;//appendChild(d);
	cpt++;

}