/**
 * Fonction Ajax par d�faut, load le contenu d'une url dans un element ID
 * @author Elbou Elbechir
 * @param url : url du fichier � executer
 * @param wait : image d'attente
 * @param elt : id du div dans lequel on affiche les infos
 * @param method : indique les paramatres si la m�thode choisie est POST
 * @param func : javascript a appeler apr�s la fin 
 */
function ajax(url, elt, wait,method,func)
{
        var xmlhttp=false;
        /*@cc_on @*/
        /*@if (@_jscript_version >= 5)
        // JScript gives us Conditional compilation, we can cope with old IE versions.
        // and security blocked creation of the objects.
          try {
          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (e) {
           try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
           } catch (E) {
                xmlhttp = false;
           }
          }
        @end @*/

        
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
          xmlhttp = new XMLHttpRequest();
        }       
        var okelt;
        if(elt!=""){
            var element = document.getElementById(elt);
            if(document.getElementById(elt)) okelt=1;
            else { okelt=0; return 0; }
        }
        
        if (wait != "" && okelt==1 ) {
                element.innerHTML = wait;
        }
        
        if(method!=""){
                xmlhttp.open("POST", url);
                xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        }else{
                xmlhttp.open("GET", url);
        }

    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                if(elt!=""){                    
                        //alert(xmlhttp.responseText);
                        element.innerHTML = xmlhttp.responseText;
                        
                }
                if (func!="") { eval(func); }
      } else if (xmlhttp.readyState != 1 && xmlhttp.readyState != 3 && xmlhttp.readyState != 2) {
                element.innerHTML = "Erreur (ERROR STATUS " + xmlhttp.status + ") '" + url + "' dans l'element '" + elt + "'";  
          }
    }
        
        if(method!=""){
                xmlhttp.send(method);
        }else{
                xmlhttp.send(null);
        }
} // fin

// retourne la selection d'un input check
function valeurChek(nom)
{
	if(document.getElementById(nom)){
		if(document.getElementById(nom).checked)
			return 1;
		else
			return 0;
	}else{
		return 0;
	}
}

// retourne la selection d'un input check radio
function valeurRadio(nom)
{
	
	if(document.getElementById(nom)){
		if(document.getElementById(nom).checked)
			return document.getElementById(nom).value;
		else
			return 0;
	}else{
		return 0;
	}
}
// retourne la valeur d'un input text
function valeurText(nom)
{
	if(document.getElementById(nom))
		return document.getElementById(nom).value;
	else
		return "";
}

var win1=null;
function openfenetre(mypage,myname,w,h,scroll,resizable,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable='+resizable+'';
win1=window.open(mypage,myname,settings);
win1.focus(myname);
}	

// affichage d'un formulaire en div
function displayDivForm(chacheId,formId,startExplode,jsFunction)
{

	if(document.getElementById(formId))
	{
		dojo.lfx.explode(startExplode, formId, 10).play();
	}
	else
	alert("Erreur : formId");
	
	if(document.getElementById(chacheId))
	{
		document.getElementById(chacheId).style.height=getWindowHeight()+"px";
		document.getElementById(chacheId).style.display='block';
	}
	else
	alert("Erreur : chacheId");
	
	// on cache les elements qui passent au dessus du div
	//hideTagsForDiv(1);
	eval(jsFunction);
	 
}


// annulation du formulaire en div
function hideForm(chacheId,formId,startExlode)
{
	
		if(document.getElementById(chacheId))
		document.getElementById(chacheId).style.display='none';
		else
		alert("Erreur : chacheId");
		
		if(document.getElementById(formId)){
			dojo.lfx.implode(formId, startExlode, 400).play();
			document.getElementById(formId).innerHTML="";
		}
		else
		alert("Erreur : formId");

	// on remet les elements effacs 
	// hideTagsForDiv(0);
}

function voirvideo(id,top,lang) {
post="id="+id;
post=post+"&act=voirVideo";
post=post+"&lang="+lang;
document.getElementById("videoVoyage").style.top=top+"px";
ajax('action.php','videoVoyage','<div class=page_list_loader><img src="images/1-1.gif" alt="Loading..." /></div>',post,'');
}

