
function popup(page,w,h,toscroll){	
	l=(screen.width)?(screen.width-w)/4:100;
	t=(screen.height)?(screen.height-h)/2:100;
	params='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars='+toscroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(page,"Annikids",params);
} 
function popup_target(page,w,h,toscroll,targetname){
	l=(screen.width)?(screen.width-w)/4:100;
	t=(screen.height)?(screen.height-h)/2:100;
	params='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars='+toscroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(page,targetname,params);
} 
function popup_tnt(page,w,h){
	l=(screen.width)?(screen.width-w)/4:100;
	t=(screen.height)?(screen.height-h)/2:100;
	params='width='+w+',height='+h+',top='+t+',left='+l+',scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
	win=window.open(page,"AnnikidsPointRelais",params);
} 
function showdiv(mydiv){
	x = document.getElementsByTagName('div')
	for (a=0;a<x.length;a++)
		if (x[a].id.indexOf("bulle") != -1) {x[a].style.visibility="hidden";x[a].style.zIndex = -1;}
	thediv = document.getElementById(mydiv);
	thediv.style.visibility="visible"; 
	thediv.style.zIndex =1001;
}
function showlogin(){		
	x= document.getElementById("bullelog");
	l=(document.body.clientWidth-226)/2;
	t=(document.body.clientHeight-150)/2;
	x.style.left = l+'px';x.style.top = t+'px';
	document.getElementById("framelogin").src = HTTP_SERVER_PATH+"include/iframe_login.php";
	showdiv("bullelog");
}
function hidediv(mydiv){
	thediv = document.getElementById(mydiv);	
	thediv.style.visibility="hidden"; 
	thediv.style.zIndex = -1;
}
function preloadImages() {
	var d=document; if(d.images){ if(!d.p) d.p=new Array();
	var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function ismaxlength(obj)
{
	/***********************************************
    * Textarea Maxlength- © Jooria Refresh Your Site (www.jooria.com)
    * This notice must stay intact for legal use.
    * Visit http://www.jooria.com
    ***********************************************/
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

//enveloppe
function load_enveloppe(obj){
	//alert("load_img_enveloppe");
	myDiv_biblio.style.top = document.body.scrollTop + 190;
	myDiv_biblio.style.left = (screen.width/2)-270; 
	myDiv_biblio.style.visibility='visible';
	mylibframe_biblio.location.href="include/iframe_enveloppe.php?obj=" + obj ;	
}
function add_enveloppe(img,obj){
	suppr_enveloppe2(obj);
	//alert("js - add_img");
	var mylist = document.monform.elements[obj];
	var oOption = document.createElement("OPTION");
	
	oOption.text = img;
	oOption.value = img;
	mylist.options.add(oOption);
	mylist.selectedIndex = mylist.length-1;
	refresh_enveloppe(obj);
	parent.unload_img();
}
function refresh_enveloppe(obj){
	//alert("klm"+img);
	var mylist = document.monform.elements[obj];
	var img_show = document.monform.elements[obj + "_show"];
	if (mylist.length >= 1){
	img = mylist.options[mylist.selectedIndex].value;
	img_show.src = 'include/min_image.php?w=15&path_img=../'+img;
	}
	else
	img_show.src = 'images/spacer.gif';
}
function suppr_enveloppe(obj){
	var mylist = document.monform.elements[obj];
	mylist.remove(mylist.selectedIndex);
	if (mylist.length > 0)
	mylist.selectedIndex = mylist.length-1;
	refresh_enveloppe(obj);
}
function suppr_enveloppe2(obj){	
	var mylist = document.monform.elements[obj];
	// alert(mylist.length);
	if (mylist.length > 0 )
	mylist.remove(mylist);
}

function encode( cible ){
	var newcible = cible;
	tag_e = newcible.indexOf("é");	
	if(tag_e >= 0){
	debut = newcible.substring(0,tag_e);
	fin = newcible.substring(tag_e+1 );
	//alert(tag_e + "- " + debut + " - " + fin );
	newcible = debut+"%e9"+fin;
	}
	return newcible;
}

//carte_perso
function valide_form2(){
	var mylist = document.monform.elements["list_image[]"];
	var myimg = document.monform.elements["image"];
	tmp = "";
	for (a=0;a<mylist.length;a++)
	tmp = tmp + "|src=" + mylist.options[a].value + "|" + "\n";
	document.monform.image.value = tmp;
	document.monform.description.value = myframe.document.body.innerHTML;
	var mylist = document.monform.elements["list_image2[]"];
	var myimg = document.monform.elements["image2"];
	tmp = "";
	for (a=0;a<mylist.length;a++)
	tmp = tmp + "|src=" + mylist.options[a].value + "|" + "\n";
	document.monform.image2.value = tmp;
    document.monform.description2.value = myframe2.document.body.innerHTML;
	return true;
}
