// JavaScript Document
function showHideLayers() { 
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length); i+=1) if ((obj=document.getElementById(args[i]))!=null) { 
    if (obj.style) { 
		obj=obj.style;
		if (args[i+1]=='hide') {
			obj.display="none";
		} else {
			obj.display="block";
		}
		/*if (obj.display=='block') {
			obj.display="none";
		} else {
			obj.display="block";
		}*/
	}
  }
}
function confirm_delete(titre,contenu) {
	Shadowbox.open({
        title:      titre,
		player:		'html',
        content:    contenu,
        height:     50,
        width:      400,
		options:{ 
			handleOversize:     'resize',
	        displayNav:         false,
			enableKeys:			false,
			listenOverlay:		false,
        	modal:     			true,
			resizeDuration:		0.1,
			fadeDuration:		0.1
		}
    });
}
function envoi_validate(titre,contenu) {
	Shadowbox.open({
        title:      titre,
		player:		'html',
        content:    contenu,
        height:     90,
        width:      400,
		options:{ 
			handleOversize:     'resize',
	        displayNav:         false,
			enableKeys:			false,
			listenOverlay:		false,
        	modal:     			true,
			resizeDuration:		0.1,
			fadeDuration:		0
		}
    });
}
function check_next(thisid,nextid) {
	me=$(thisid).checked;
	if(me) {
		//$(nextid).checked=true;
	} else {
		$(nextid).checked=false;
	}
}
function delete_img(id,no,form,div) {
	a=new Ajax.Request('libs/lib.ajax_forms.php', {
		parameters: {
			id: id, 
			no: no,
			form_name:form
		},
		onComplete: function() {
			new Effect.BlindUp(div, {
				afterFinish: function(effect) {
					$(div).remove();
				}
			});
		}
	});
}
function delete_oeuvre(id,form,div) {
	a=new Ajax.Request('libs/lib.ajax_forms.php', {
		parameters: {
			id: id, 
			form_name:form
		},
		onComplete: function() {
			new Effect.Fade(div, {
				afterFinish: function(effect) {
					$(div).remove();
				}
			});
		}
	});
}
function delete_line(id,form,div) {
	a=new Ajax.Request('libs/lib.ajax_forms.php', {
		parameters: {
			id: id,
			form_name:form
		},
		onComplete: function() {
			new Effect.BlindUp(div, {
				afterFinish: function(effect) {
					$(div).remove();
				}
			});
		}
	});
}
function order_o(dv,admin_id,frm,handl) {
	Sortable.create(dv, {
		 tag:'div',overlap:'horizontal',constraint: false, handle:handl, containment:dv,
		  onUpdate:function() {
			params=Sortable.serialize(dv);
			new Ajax.Request('libs/lib.ajax_forms.php', {
				parameters: {
					ordre:params,
					form_name:frm,
					sv:admin_id
				}
			});
		  }
	});
}
function sendform(form) { //envoie un formulaire
	document.getElementById(form).submit();
}
function departements(x) {
	
	var ddfr="dept_div_"+x+"fr";
	var ddde="dept_div_"+x+"de";
	var dden="dept_div_"+x+"en";
	var ddes="dept_div_"+x+"es";
	var ddit="dept_div_"+x+"it";
	var pd="pays_dept"+x;
	if (x != '') {
		var paysx="pays_"+x;
		var add=0;
	} else {
		var paysx="pays";
		var add=0;
	}
	$(ddfr).style.display='none';
	$(ddde).style.display='none';
	$(dden).style.display='none';
	$(ddes).style.display='none';
	$(ddit).style.display='none';
		
	switch ($(paysx).selectedIndex+add) {
	case 5: // ALLEMAGNE
		Effect.BlindDown(ddde, {duration: 0.3});
	    $(pd).value='de';
		$(ddfr).selectedIndex=0;
		$(dden).selectedIndex=0;
		$(ddes).selectedIndex=0;
		$(ddit).selectedIndex=0;
		break; 
	case 69: // ESPAGNE
		Effect.BlindDown(ddes, {duration: 0.3});
	    $(pd).value='es';
		$(ddfr).selectedIndex=0;
		$(ddde).selectedIndex=0;
		$(dden).selectedIndex=0;
		$(ddit).selectedIndex=0;
		break;
	case 77: // FRANCE
		Effect.BlindDown(ddfr, {duration: 0.3});
	    $(pd).value='fr';
		$(ddde).selectedIndex=0;
		$(dden).selectedIndex=0;
		$(ddes).selectedIndex=0;
		$(ddit).selectedIndex=0;
		myfoc=$(ddfr)
		myfoc.focus(); 
		break; 
	case 110: // ITALIE
		Effect.BlindDown(ddit, {duration: 0.3});
	    $(pd).value='it';
		$(ddfr).selectedIndex=0;
		$(ddde).selectedIndex=0;
		$(dden).selectedIndex=0;
		$(ddes).selectedIndex=0;
		break; 
	case 182: // ANGLETERRE (Royaume Uni)
		Effect.BlindDown(dden, {duration: 0.3});
	    $(pd).value='en';
		$(ddfr).selectedIndex=0;
		$(ddde).selectedIndex=0;
		$(ddes).selectedIndex=0;
		$(ddit).selectedIndex=0;
		break; 
	default:
		$(ddfr).selectedIndex=0;
		$(ddde).selectedIndex=0;
		$(dden).selectedIndex=0;
		$(ddes).selectedIndex=0;
		$(ddit).selectedIndex=0;
		Effect.BlindUp(ddfr, {duration: 0.3});
		Effect.BlindUp(ddde, {duration: 0.3});
		Effect.BlindUp(dden, {duration: 0.3});
		Effect.BlindUp(ddes, {duration: 0.3});
		Effect.BlindUp(ddit, {duration: 0.3});
		$(pd).value='';
	}
	return false;
}
function clearField($champ) {
	document.getElementById($champ).value='';
}

function change_ln(langue,pre) {
	showHideLayers(pre+'fr','hide',pre+'en','hide',pre+'de','hide',pre+'it','hide',pre+'es','hide');
	showHideLayers(pre+langue,'show');
}

window.addLoadEvent = function(func) {
   var oldonload = window.onload;
   if (typeof window.onload != 'function') {
      window.onload = func;
   } else {
      window.onload = function() {
         if (oldonload) {
            oldonload();
         }
         func();
      }
   }
}
// MENUS
/*
function addLoadEvent(func) {
	window.alert(func);
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}
*/
var menuids=["menuul"] //Enter id(s) of SuckerTree UL menus, separated by commas

function cach(el) {
	//el=$('menu_artistes');
	//window.alert(el.id);
	el.style.visibility="hidden";
	el.style.display="none";
}
function buildsubmenus_horizontal(){
	for (var i=0; i<menuids.length; i++){
	
		//var div = document.createElement('div');
		//var span = document.createElement('span');
		var litags = document.getElementsByTagName("li");
				
		for (l=0,j=0; l<litags.length; l++) {
			if(litags[l].className.match('niveau_0_')) {
				
				litags[l].id="menuli"+(j+1);
				

				j++;
			}
		}
		
		var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
		for (var t=0; t<ultags.length; t++){
			if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
				ultags[t].style.top=ultags[t].parentNode.offsetHeight-1+"px"; //dynamically position first level submenus to be height of main menu item
				//ultags[t].style.position='absolute';
				//ultags[t].style.zIndex=10000;
				//ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
				//ultags[t].parentNode.id="men"+t
				//window.alert("men+"+t);
			}
			else{ //else if this is a sub level menu (ul)
			  //ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
			//ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
			}
			ultags[t].parentNode.onmouseover=function(){
				// window.alert('over '+test+' niveau_1_');
				//monid=this.getElementsByTagName("ul")[0].id;
				//a=new Effect.Appear(monid);
				
				/*$$('input').each( function() {
					this.style.display="none";
				});*/
										   
										   
				this.getElementsByTagName("ul")[0].style.display="block";
				this.getElementsByTagName("ul")[0].style.visibility="visible";
			}
			ultags[t].parentNode.onmouseout=function(){
				//test=this.id;
				//monid=this.getElementsByTagName("ul")[0].id;
				//window.alert(monid);
				//new Effect.Fade(monid);
				//el=this.getElementsByTagName("ul")[0];
				//ele=cach(el.id);
				//window.setTimeout(ele, 100);
				this.getElementsByTagName("ul")[0].style.display="none";
				this.getElementsByTagName("ul")[0].style.visibility="hidden";
			}
		}
	}
}
/*
if (window.addEventListener)
	window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
	window.attachEvent("onload", buildsubmenus_horizontal)
	*/