
function getCssValue(tagRef,element) {
	var aClass = tagRef
	if(navigator.appName.indexOf('Microsoft')!=-1){
		cssRules = 'rules';
	}
	else{
		cssRules = 'cssRules';
	}
	for (var sSheet=0; sSheet < document.styleSheets.length; sSheet++){
		for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++) {
			var currentClass = document.styleSheets[sSheet][cssRules][rule].selectorText.substring(1);
			if (currentClass == aClass) {
				return document.styleSheets[sSheet][cssRules][rule].style[element];
			}
		}
	}
}

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);
}
var mod_tab = new Array();
function swap_mod_onglet(tmp){
	if (mod_tab[tmp]==true){
		for (var a=0; a<nbong+1;a++){
			var d1=eval("document.getElementById('proong_"+a+"')")
			var t1=eval("document.getElementById('mod_tab"+a+"')")
			if(d1){
				if (mod_tab[a]==true){
					d1.className="profil_onglet_off"
				}
				else{
					d1.className="profil_onglet_desactivated"
				}
				t1.style.display="none"
			}
		}
		var d1=eval("document.getElementById('proong_"+tmp+"')")
		var t1=eval("document.getElementById('mod_tab"+tmp+"')")
		d1.className="profil_onglet_on"
		t1.style.display=""
	}
}
function swap_grp(tmp,tmp2){
	var d1=document.getElementById('grp_'+tmp)
	var d2=document.getElementById('tmp_'+tmp2)
	if(d1){
		if(d2.type=="select-one"){
			if(d2.selectedIndex!=0){
				d1.style.display=""
				for (var i=0;i<20;i++) {
					var d3=document.getElementById('grp_'+tmp+'_'+i)
					if (d3){
						if(i==d2.selectedIndex-1){
							d3.style.display=""	
						}
						else{
							d3.style.display="none"
						}
					}
				}
			}
			else {
				d1.style.display="none"
			}
		}
	}
}
function check_typ(typ,nbchx,txt_false){
	var all_datas=''
	var val
	for(a=0;a<nbchx;a++){
		var d=eval("document.getElementById('tmp_"+a+"')")
		if(d){
			val=d.value
		}
		else{
			val="-"
		}
		all_datas=all_datas+''+val
		all_datas=all_datas+'[§]'+a
		if (a<nbchx-1) all_datas=all_datas+'[§§]'
	}
	return_txt = file_get('../mod/mod_check_post.asp?all_datas='+escape(all_datas)+'&typ='+typ+'')
	return_txt=unescape(return_txt)
	return_txtT=return_txt.split("[§§]");
	all_ok=true
	//-----test if all ok--------
	results=return_txtT[0].split(";")
	for(a=0;a<results.length;a++){
		if(results[a]!=1) all_ok=false
	}
	//---------------------------
	if(all_ok==true){
		return(true)
	}
	else{
		libT=return_txtT[1].split("[§]");
		lib_to_fill=""
		for(a=0;a<libT.length;a++){
			lib_to_fill=lib_to_fill+libT[a]+'\n'
		}
		alert(txt_false+'\n--------------------\n\n'+lib_to_fill)
		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"))
   		{	
		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"))
   		{	
		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=="block")||(d.style.display==""))
   	{d.style.display="none";} //block
   else
   	{d.style.display="";}
}
function swapMenu2(menuDiv,typ_blc,force_close){
	
   window.focus(); 
   var disp_adm=""
   if (typ_blc=="1") disp_adm="_adm"
   var dm=eval("document.getElementById('"+menuDiv+"')");
   if ((dm.style.display=="block")||(dm.style.display=="")||(force_close==true)){
		dm.style.display="none";
		document.getElementById(menuDiv+'_img').className="bloc_down"+disp_adm
		val=0
		}
   else {
		dm.style.display="";
		document.getElementById(menuDiv+'_img').className="bloc_up"+disp_adm
		val=1
		}
	if (force_close==false){
		dm.style.display="";
		document.getElementById(menuDiv+'_img').className="bloc_up"+disp_adm
		val=1
	}
	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,id){
	window.open('../forum/msg_modif.asp?cle='+cle+'&table='+table+'&page='+page+'&id='+id,'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 return_value_modal(sinput,width_asset,height_asset,url_asset) 
	{
	var Upval=document.getElementById(sinput).value
	var tmp=url_asset+"?Upval="+Upval  
	sActiveAssetInput = sinput
	if(navigator.appName.indexOf('Microsoft')!=-1){
		tmp=modalDialogShow_IE(tmp,width_asset,height_asset); //IE
		if ((tmp!="~")&&(tmp!=undefined)) {
			document.getElementById(sActiveAssetInput).value=tmp; 
			var d=document.getElementById(sActiveAssetInput+"_div")
			if(d) d.innerHTML=tmp; 
		}
	}	
	else{
		tmp=modalDialogShow_Moz(tmp,width_asset,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,gal_version){
	if(gal_version==0){
		window.open('../galerie/galerie_popup2.asp?id_photo='+id_photo+'&num='+num+'&order='+order+'','Galerie','status=yes,resizable=no,scrollbars=yes');
	}
	else{
		window.open('../galerie/galerie_popup3.asp?id_photo='+id_photo+'&num='+num+'&order='+order+'','Galerie','status=yes,resizable=no,scrollbars=yes');
	}
}

function go_item(num,back_to_list){
	//go only if caddie is hide
	if(document.getElementById("shop_popup").style.display == "none"){
		location.href='../racine/default.asp?num='+num+back_to_list
	}
}

function swap_class(id_item,class_item){
	var bouton = document.getElementById(id_item)
	if(bouton.className==class_item+'_off'){
		bouton.className=class_item+'_on'
	}
	else{
		bouton.className=class_item+'_off'
	}
}
function swap_display(div){
   div=eval("document.getElementById('"+div+"')");
   if (div.style.display=="none")
   	{div.style.display="";}
   else
   	{div.style.display="none";}
}
function check_date(tmp){
	if (tmp.length != 10) return(false);
	dateContent = tmp.split("/");
	if (dateContent.length != 3) return(false);
	if ((dateContent[1]>12) || (dateContent[1]<1)) return(false);
	if ((dateContent[0]>31) || (dateContent[0]<1)) return(false);
}
function disp_edit(tmp){
	var d
	d=eval("document.getElementById('bloc_edit_ico_"+tmp+"')");
	if ((d.style.display=="")||(d.style.display=="none")){
		d.style.display="block";
		d=eval("document.getElementById('bloc_"+tmp+"')");
		d.className="bloc_edit_on"
	}
	else{
		d.style.display="none";
		d=eval("document.getElementById('bloc_edit_ico_"+tmp+"')");
		d=eval("document.getElementById('bloc_"+tmp+"')");
		d.className="bloc_edit_off"
	}
}
function shop_open_popup(num){
	var disp=document.getElementById("shop_popup").style.display
	if((disp=="none")||(disp=='')){
		var scroll_top = document.body.scrollTop;
		var scroll_left = document.body.scrollLeft;
		var clientWidth = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
		var clientHeight = document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
		popup_height=getCssValue("shop_popup","height").replace('px','')
		popup_width=getCssValue("shop_popup","width").replace('px','')
		pos_left = scroll_left + (clientWidth/2) - popup_width/2;
		pos_top = scroll_top + (clientHeight/2) - popup_height/2;
		document.getElementById("shop_popup").style.top = pos_top
		document.getElementById("shop_popup").style.left = pos_left
		txt=file_get('../extern/shop_read_item.asp?shop_add='+num+'&num='+num)
		txt=txt.split("[item]");
		document.getElementById("shop_popup").innerHTML=unescape(txt[0])
		var panier_items=document.getElementById("panier_items")
		if(panier_items) panier_items.innerHTML=txt[1]	
		document.getElementById("shop_popup").style.display="block"
	}
}

function shop_close_popup(){
	document.getElementById("shop_popup").style.display="none"
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}