
function getXMLHTTP(){
  // retourne un objet xmlHttpRequest.
  // méthode compatible entre tous les navigateurs (IE/Firefox/Opera)
  var xhr=null;
  if(window.XMLHttpRequest) // Firefox et autres
  xhr = new XMLHttpRequest();
  else if(window.ActiveXObject){ // Internet Explorer
    try {
      xhr = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xhr = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e1) {
        xhr = null;
      }
    }
  }
  else { // XMLHttpRequest non supporté par le navigateur
    alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
  }
  return xhr;
}


function file_post(fichier_post,posting){
	xhr_object_post=getXMLHTTP()
	xhr_object_post.open("POST", fichier_post, true); 
	xhr_object_post.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr_object_post.onreadystatechange = function() {
		if ((xhr_object_post.readyState == 4 )&&(xhr_object_post.status == 200)) {
			return(xhr_object_post.responseText);
		}
	}
	xhr_object_post.send(posting); 
}

function file_get(fichier){
	xhr_object=getXMLHTTP()
	xhr_object.open("GET", fichier, false); 
	xhr_object.send(null); 
	if(xhr_object.readyState == 4) return(xhr_object.responseText);
	else return(false);
}

function swap_explorer(div){
   var d1=eval("document.getElementById('"+div+"1')");
   var d2=eval("document.getElementById('"+div+"0')");
   if ((d1.style.display=="none")||(d1.style.display==""))
   	{	
		d1.style.display="block";	
		d2.className="art_blc_on"
	}
   else
   	{
		d1.style.display="none";
		d2.className="art_blc_off"
	}
}
function swap_explorerOver(div){
	var d1=eval("document.getElementById('"+div+"1')");
   	var d2=eval("document.getElementById('"+div+"0')");
   	if ((d1.style.display=="none")||(d1.style.display==""))
   		{	
		d2.className="art_blc_offOver"
		}
   	else
   		{
		d2.className="art_blc_onOver"
		}
}
function swap_explorerOut(div){
  	var d1=eval("document.getElementById('"+div+"1')");
   	var d2=eval("document.getElementById('"+div+"0')");
   	if ((d1.style.display=="none")||(d1.style.display==""))
   		{	
		d2.className="art_blc_off"
		}
   	else
   		{
		d2.className="art_blc_on"
		}
}

function swapMenu(menuDiv){
   window.focus(); 
   var x = menuDiv.substring(4,5); 
   var d=eval("document.getElementById('"+menuDiv+"')");
   if ((d.style.display=="none")||(d.style.display==""))
   	{d.style.display="block";}
   else
   	{d.style.display="none";}
}
function swapMenu2(menuDiv,typ_blc){
   window.focus(); 
   var disp_adm=""
   if (typ_blc=="1") disp_adm="_adm"
   var dm=eval("document.getElementById('"+menuDiv+"')");
   if ((dm.style.display=="none")||(dm.style.display=="")){
		dm.style.display="block";
		document.getElementById(menuDiv+'_img').className="bloc_up"+disp_adm
		val=1
		}
   else {
		dm.style.display="none";
		document.getElementById(menuDiv+'_img').className="bloc_down"+disp_adm
		val=0
		}
	var la_date = new Date();
	var la_date_ms = la_date.getTime() + 3.15576e+10;
	var la_date_2 = new Date(la_date_ms);
	
	document.cookie = menuDiv+"="+ escape(val) + ";expires=" + la_date_2.toGMTString();
}
function forum_mp(tmp){
	window.open('../forum/new_mp.asp?idrec='+tmp,'','menubar=no, status=no, scrollbars=no');
}
function msg_modif(cle,table,page){
	window.open('../forum/msg_modif.asp?cle='+cle+'&table='+table+'&page='+page,'edition','menubar=no, status=no, scrollbars=no');
}

function modalDialogShow_IE(url,width,height) //IE
	{
	return window.showModalDialog(url,window,
		"dialogWidth:"+width+"px;dialogHeight:"+height+"px;edge:Raised;center:Yes;help:No;Resizable:Yes;Maximize:Yes");
	}
function modalDialogShow_Moz(url,width,height) //Moz
    {
    var left = screen.availWidth/2 - width/2;
    var top = screen.availHeight/2 - height/2;
    activeModalWin = window.open(url, "", "width="+width+"px,height="+height+",left="+left+",top="+top);
    window.onfocus = function(){
		if (activeModalWin.closed == false){
			activeModalWin.focus();
			
		};
	};
    }
var sActiveAssetInput;
function setAssetValue(v) //required by the asset manager
    {
    document.getElementById(sActiveAssetInput).value = v;
    }
function openAsset(Sinput,Srep,Sthumb,img_disp)

	{

	Height_asset=420
	width_asset=800
	//if (Sthumb==1)Height_asset=400
	//Sinput=input de retour - Srep:repertoir à ouvrir - Sthumb:1/0 selection de fichier - img_disp: retourne l'url dans l'image
	var tmp="../editor/assetmanager/assetmanager.asp?Srep="+Srep+"&Sthumb="+Sthumb
	if (Sinput=="open_only"){
		if(navigator.appName.indexOf('Microsoft')!=-1)
			modalDialogShow_IE("../editor/assetmanager/assetmanager.asp",width_asset,Height_asset); //IE	
		else
			modalDialogShow_Moz("../editor/assetmanager/assetmanager.asp",width_asset,Height_asset); //Moz	
		}
	else
		{
		sActiveAssetInput = Sinput

		if(navigator.appName.indexOf('Microsoft')!=-1)
			if (Sinput==''){
				modalDialogShow_IE(tmp,width_asset,Height_asset)
				}
			else{
				retmod=modalDialogShow_IE(tmp,width_asset,Height_asset); 
				document.getElementById(sActiveAssetInput).value=retmod
				}	
		else
			if (Sinput==''){
				modalDialogShow_Moz(tmp,width_asset,Height_asset); 
				}
			else{
				retmod=modalDialogShow_Moz(tmp,width_asset,Height_asset); 
				document.getElementById(sActiveAssetInput).value=retmod
			}	
		}
	if (document.getElementById(img_disp)){
		document.getElementById(img_disp).src=retmod
	}
}
function csspicker(Sinput)
	{
	var Height_asset=520
	var Upval=document.getElementById(Sinput).value
	var tmp="../extern/csspicker.asp?Upval="+Upval
	sActiveAssetInput = Sinput
	if(navigator.appName.indexOf('Microsoft')!=-1){
		tmp=modalDialogShow_IE(tmp,450,Height_asset); //IE
		if ((tmp!="~")&&(tmp!=undefined)) {
			document.getElementById(sActiveAssetInput).value=tmp; 
			document.getElementById(sActiveAssetInput+"_div").innerHTML=tmp; 
		}
	}	
	else{
		tmp=modalDialogShow_Moz(tmp,450,Height_asset)//Moz
	}
}
function pagepicker(Sinput)
	{
	var Height_asset=520
	var Upval=document.getElementById(Sinput).value
	var tmp="../extern/pagepicker.asp?Upval="+Upval
	sActiveAssetInput = Sinput
	if(navigator.appName.indexOf('Microsoft')!=-1){
		tmp=modalDialogShow_IE(tmp,450,Height_asset); //IE
		}	
	else{
		tmp=modalDialogShow_Moz(tmp,450,Height_asset)//Moz
		}
	if (tmp!="~") document.getElementById(sActiveAssetInput).value=tmp; 
}
function boxpicker(Sinput)
	{
	var Height_asset=520
	var Upval=document.getElementById(Sinput).value
	var tmp="../extern/boxmodel_show.asp?Upval="+Upval
	sActiveAssetInput = Sinput
	if(navigator.appName.indexOf('Microsoft')!=-1){
		tmp=modalDialogShow_IE(tmp,450,Height_asset); //IE
		}	
	else{
		tmp=modalDialogShow_Moz(tmp,450,Height_asset)//Moz
		}
	if (tmp!="~") document.getElementById(sActiveAssetInput).value=tmp; 
}	
function gal_popup(id_photo,num,order){
	window.open('../galerie/galerie_popup2.asp?id_photo='+id_photo+'&num='+num+'&order='+order+'','Galerie','status=yes,resizable=yes,scrollbars=yes');
}

function open_panier(tmp){
	window.open('../panier/panier_vu.asp?ajout='+tmp,'Mon_panier','menubar=no, status=no, scrollbars=yes');
}
