function include(fileName){
	document.write("<script type='text/javascript' src='js/"+fileName+"'></script>" );
}
function addLoadEvent(func){	
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}
function verifForm(form){
	var input = document.getElementById(form).getElementsByTagName('input');
	for(var i=0; i<input.length; i++){
		if(input[i].type == 'text' || input[i].type == 'password'){
			if(input[i].value == ''){
				var msg = 'No '+input[i].name;
				break;
			}
		}
	}
	if(msg){
		alert(msg);
		return false;
	}else{
		return true;
	}
}
function verifForm2(classname){
	var tab = classname.split(".");
	if(tab.length==2){
		var div = document.getElementById(tab[0]).getElementsByTagName('div');
		classname = tab[1];
	}else{
		var div = document.getElementsByTagName('div');
	}
	for(var j=0; j<div.length; j++){
		if(div[j].className == classname){
			var input = div[j].getElementsByTagName('input');
			for(var i=0; i<input.length; i++){
				if(input[i].type == 'text' || input[i].type == 'password'){
					if(input[i].value == '' && input[i].name != 'fax'){
						var msg = 'No '+input[i].name;
						break;
					}
				}
			}
			break;
		}
	}
	if(msg){
		alert(msg);
		return false;
	}else{
		return true;
	}
}
function verifForm3(classname){
	var div = document.getElementsByTagName('div');
	for(var j=0; j<div.length; j++){
		if(div[j].className == classname){
			var input = div[j].getElementsByTagName('input');
			for(var i=0; i<input.length; i++){
				if(input[i].type == 'password'){
					if(input[i].value == ''){
						var msg = 'No '+input[i].name;
						break;
					}
				}
			}
			if(!msg){
				if(input[1].value.length<8){
					var msg = 'Your password must have 8 characters minimum';
				}else if(input[1].value != input[2].value){
					var msg = 'Passwords are not the same';
				}
			}
			break;
		}
	}
	if(msg){
		alert(msg);
		return false;
	}else{
		return true;
	}
}
function verifForm4(name){
	var textarea = document.getElementsByTagName('textarea');
	for(var i=0; i<textarea.length; i++){
		if(textarea[i].name == name && textarea[i].value == ''){
			var msg = 'No '+textarea[i].name;
			break;
		}
	}
	if(msg){
		alert(msg);
		return false;
	}else{
		return true;
	}
}
function show(name, lien){
	var div = document.getElementsByTagName('div');
	for(var i=0; i<div.length; i++){
		if(div[i].className == name){
			var images = div[i].getElementsByTagName('img');
			for(var j=0; j<images.length; j++){
				if(images[j].src == lien){
					images[j].style.display='block';
				}else{
					images[j].style.display='none';
				}
			}
			break;
		}
	}
}
function buildListe(id, deb, nbPage){
	var fin = (deb+5);
	if(fin>nbPage){
		fin=nbPage;
	}
	var div = document.getElementById(id);
	var html="";
	if(deb>1){
		html+="<b>&lt;&lt;</b>&nbsp;<a href=\"#"+(deb-5)+"\" onclick=\"buildListe('"+id+"', "+(deb-5)+", "+nbPage+");goPage('"+id+"', this.hash);\">previous</a>&nbsp;&nbsp;&nbsp;&nbsp;";
	}
	for(var i=deb; i<fin; i++){
		html+="<a href=\"#"+i+"\" class=\"lienBottom\" onclick=\"goPage('"+id+"', this.hash);\">"+i+"</a>";
		if(i!=fin-1){
			html+="&nbsp;-&nbsp;";
		}
	}
	if(fin<nbPage){
		html+="&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#"+fin+"\" onclick=\"buildListe('"+id+"', "+fin+", "+nbPage+");goPage('"+id+"', this.hash);\">next</a>&nbsp;<b>&gt;&gt;</b>&nbsp;&nbsp;"
	}
	div.innerHTML="<p style=\"text-align:center; margin-top:15px;\">"+html+"</p>";
}
function goPage(id, ancre){
	var numMontre = ancre.substr(1, ancre.length);
	var div = document.getElementsByTagName('div');
	for(var i=0; i<div.length; i++){
		if(div[i].className=='page'+numMontre && div[i].parentNode.style.display!='none'){
			div[i].style.display='block';
		}else if(div[i].className.substr(0, 4)=='page' && div[i].parentNode.style.display!='none'){
			div[i].style.display='none';
		}
	}
	document.location.href='#top';
	document.location.hash=ancre;
}
function searchPage(id, ancre, nbPage){
	var comment = document.getElementsByTagName('a');
	for(var i=0; i<comment.length; i++){
		if(comment[i].name==ancre.substr(1, ancre.length)){
			buildListe(id, parseInt(comment[i].parentNode.className.substr(4,comment[i].parentNode.className.length)), nbPage);
			goPage(id, '#'+comment[i].parentNode.className.substr(4,comment[i].parentNode.className.length), nbPage);
			document.location.hash=ancre;
			document.location.hash='#'+comment[i].parentNode.className.substr(4,comment[i].parentNode.className.length);
			break;
		}
	}
}
function popage(adresse, h, w){
	topy=(screen.height/2)-(h/2);
	leftx=(screen.width/2)-(w/2);
	var pop = window.open(adresse+".html", "titre", "toolbar=no, location=no, directories=no, status=no, scroll=no, resizable=no, copyhistory=no, top="+topy+", left="+leftx+", width="+w+", height="+h);
	if(pop.window.focus){
		pop.window.focus();
	}
}
function selectContinent(id){
	ajax('post', 'include/search_hotel.php', 'id_continent='+id, 'fonction_callback')
}
function ajax ( type, fichier, variables , fonction ){ 
	if ( window.XMLHttpRequest ) var req = new XMLHttpRequest();
	else if ( window.ActiveXObject ) var req = new ActiveXObject("Microsoft.XMLHTTP");
	else alert("ActiveX Error.");
	if ( arguments.length==4 ) var fonction = arguments[3];

	if (type.toLowerCase()=="post") {
		req.open("POST", fichier, true);
		document.getElementById('loader').style.display="block";
		document.getElementById('continent').style.display="none";
		req.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=iso-8859-1');
		req.send(variables);
	} else if (type.toLowerCase()=="get") {
		req.open('get', fichier+"?"+variables, true);
		req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=iso-8859-1');
		req.send(null);
	} else { 
		alert("Error data."); 
	}

	req.onreadystatechange = function()  { 
		if (req.readyState == 4 && req.responseText != null )
		{				
			if (fonction) eval( fonction + "('"+escape(req.responseText)+"')");
			
		} 
	}
}
function fonction_callback(r) {
	document.getElementById('loader').style.display="none";
	document.getElementById('continent').style.display="block";
	document.getElementById('continent').innerHTML=unescape(r);
}
function show_admin(id, div){
	var liste = document.getElementById(id).getElementsByTagName('div');
	for(var i=0; i<liste.length; i++){
		if(liste[i].id==div){
			liste[i].style.display='block';
		}else if(liste[i].id && liste[i].id.substr(0, 5)=='admin'){
			liste[i].style.display='none';
		}
	}
}
function show_user(id, div){
	var liste = document.getElementById(id).getElementsByTagName('div');
	for(var i=0; i<liste.length; i++){
		if(liste[i].id==div){
			liste[i].style.display='block';
		}else if(liste[i].id && liste[i].id.substr(0, 4)=='user'){
			liste[i].style.display='none';
		}
	}
}
function show_hotel(div){
	var numlist = div.substr(4, 1);
	var numhotel = div.substr(11, div.length);
	if(!document.divhotel){
		document.divhotel = new Array();
	}else{
		if(document.divhotel[numlist]){
			document.divhotel[numlist].style.display='none';
		}
	}
	var liste = document.getElementById('list'+numlist+'_hotel'+numhotel);
	liste.style.display='block';
	document.divhotel[numlist] = liste;
}
function show_hotel2(div){
	var num = div.substr(5, div.length);
	if(!document.divhotel){
		document.divhotel = new String();
	}else{
		if(document.divhotel){
			document.divhotel.style.display='none';
		}
	}
	var liste = document.getElementById(div);
	liste.style.display='block';
	document.divhotel = liste;
	if(!document.FCKarray){
		document.FCKarray = new Array();
	}
	var FCKexiste=false;
	for(var fck=0; fck<document.FCKarray.length; fck++){
		if(document.FCKarray[fck]=='FCKeditor'+num){
			FCKexiste=true;
			break;
		}
	}
	if(!FCKexiste){
		var oFCKeditor = new FCKeditor('FCKeditor'+num);
		oFCKeditor.BasePath = "include/fckeditor/";
		oFCKeditor.Height  = "200";
		oFCKeditor.ReplaceTextarea();
		document.FCKarray.push('FCKeditor'+num);
	}
}
function show_villes(id, select){
	var liste = document.getElementById(id).getElementsByTagName('select');
	for(var i=0; i<liste.length; i++){
		if(liste[i].name==select){
			liste[i].style.display='block';
		}else if(liste[i].name && liste[i].name.substr(0, 6)=='villes'){
			liste[i].style.display='none';
		}
	}
}
function show_contenu(id, div){
	var liste = document.getElementById(id).getElementsByTagName('div');
	for(var i=0; i<liste.length; i++){
		if(liste[i].id==div){
			liste[i].style.display='block';
		}else if(liste[i].id && liste[i].id.substr(0, 7)=='contenu'){
			liste[i].style.display='none';
		}
	}
	var num = div.substr(7, div.length);
	if(!document.FCKarray){
		document.FCKarray = new Array();
	}
	var FCKexiste=false;
	for(var fck=0; fck<document.FCKarray.length; fck++){
		if(document.FCKarray[fck]=='FCKeditor'+num){
			FCKexiste=true;
			break;
		}
	}
	if(!FCKexiste){
		var oFCKeditor = new FCKeditor('FCKeditor'+num);
		oFCKeditor.BasePath = "include/fckeditor/";
		oFCKeditor.Height  = "500";
		oFCKeditor.ReplaceTextarea();
		document.FCKarray.push('FCKeditor'+num);
	}
}
