function submitbutton(pressbutton) {
	submitform(pressbutton);
}

function submitform(pressbutton){
	document.adminForm.task.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

function changeDynaList( listname, source, key, orig_key, orig_val ) {
        var list = eval( 'document.adminForm.' + listname );

        // empty the list
        for (var i in list.options.length) {
                list.options[i] = null;
        }
        var i = 0;
        for (x in source) {
                if (source[x][0] == key) {
                        opt = new Option();
                        opt.value = source[x][1];
                        opt.text = source[x][2];

                        if ((orig_key == key && orig_val == opt.value) || i == 0) {
                                opt.selected = true;
                        }
                        list.options[i++] = opt;
                }
        }
        list.length = i;
}

function previewImage( list, image, base_path ) {
	var form = document.adminForm;
	var srcList = eval( "form." + list );
	var srcImage = eval( "document." + image );
	var fileName = srcList.options[srcList.selectedIndex].text;
	var fileName2 = srcList.options[srcList.selectedIndex].value;
	if (fileName.length == 0 || fileName2.length == 0) {
		srcImage.src = 'images/blank.gif';
	} else {
		srcImage.src = base_path + fileName;
	}
}

function showHide(k){
    var ki = "i"+k;
        if (document.images[ki].src.indexOf("image/+.gif") != -1){
                document.images[ki].src = "image/-.gif";
                document.getElementById(k).style.display='block';
        }else{
                document.images[ki].src = "image/+.gif";
                document.getElementById(k).style.display='none';
        }
}

function show(k,w,h){
        var sw  = document.body.clientWidth;
        var wbx = Math.round((sw-w)/2);
        var sh  = document.body.clientHeight;
        var wby = 90;
        document.getElementById(k).style.width=w;
        document.getElementById(k).style.height=h;
        document.getElementById(k).style.left=wbx;
        document.getElementById(k).style.top=wby;
        document.getElementById(k).style.display='block';
}

/*function show2(k,w,h,wby){
        sw  = document.body.clientWidth;
        wbx = Math.round((sw-w)/2);
        //wby = 90;
		sh  = document.body.clientHeight;
        
        document.getElementById(k).style.width=w;
        document.getElementById(k).style.height=h;
        document.getElementById(k).style.left=wbx;
        document.getElementById(k).style.top=wby;
        document.getElementById(k).style.display='block';
}*/

function show2(k,w,h,pos){
        var sw  = document.body.clientWidth;
        var wbx = Math.round((sw-w)/2);
        var sh  = document.body.clientHeight;
        var wby = Math.round((sh)/2 + pos)-(Math.round(h/2));
        document.getElementById(k).style.width=w;
        document.getElementById(k).style.height=h;
        document.getElementById(k).style.left=wbx;
        document.getElementById(k).style.top=wby;
        document.getElementById(k).style.display='block';
}

function Close(k){
        document.getElementById(k).style.display='none';
}

function getModalData(url, width, height) {
        var results = new Array();
        modalRes = window.showModalDialog(url, "", "dialogWidth: "+width+"px; dialogHeight: "+height+"px; font-family: Verdana, Arial; font-size: 10pt; status:0; scroll:0");
}


function setModalVal(form) {
  var modalArr = new Array;
  for (var i = 0; i < form.length; i++)
      with (form[i])
           if (name != "")
              modalArr[name] = value;
  window.returnValue = modalArr;
  event.returnValue = false;
  window.close();
}

function setimg(sel, UID){
    var obj = document.getElementById("previewimg");
    var hid = document.getElementById("imgid");
        if(sel.value == 0){
                obj.src = "../images/noimage.gif";
                hid.value = sel.value;
        }else{
                if(sel.value != "browse"){
                        obj.src = "../photos/"+imgs[sel.value].imgsrc;
                        hid.value = sel.value;
                }else{
                        getModalData("image.php", 580, 700);
                        if(modalRes["imgsrc"]!=0){
                                obj.src = "../photos/"+modalRes["imgsrc"];
                        }
                        if(modalRes["imgid"]!=0){
                                hid.value = modalRes["imgid"];
                        }
                }
        }
}

function aide() {
		window.open("aide/index.html","aide","width=770,height=550,left=80,top=40,copyhistory=no,directories=no,menubar=no,location=no,resizable=yes,scrollbars=yes,toolbar=no");
}

function content(id){
        window.open("editeur2/editeur.php?id="+id,"items","width=730,height=630,left=80,top=20,menubar=0,resizable=0,scrollbars=0,toolbar=0,status=0");
}

function groupe(id){
         window.open("objet/catalogue/edittype.php?idr="+id,"items","width=520,height=650,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}

function lieu(id){
         window.open("objet/catalogue/editlieu.php?idr="+id,"items","width=700,height=650,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}



function adresse(id){
         window.open("objet/carnet/adresse.php?idb="+id,"items","width=650,height=400,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}

function demande(id){
         window.open("objet/inscription/demande_inscription.php","items","width=700,height=450,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}

function traite_demande(id){
         window.open("objet/inscription/traitement_inscription.php?idi="+id,"items","width=700,height=450,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}

function traite_attente(id){
         window.open("objet/inscription/traitement_attente.php?idi="+id,"items","width=700,height=450,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}

function liremail(id){
         window.open("objet/inscription/lire_mail.php?id="+id,"items","width=500,height=450,left=80,top=20,menubar=0,resizable=0,scrollbars=1,toolbar=0,status=0");
}