// JavaScript Document
<!--
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->

function confirmer(msg,url) { //v1.0
  	   if (confirm(msg)){
			window.location.href =url;
			}

}

function confirm_and_submit(msg,formulaire) { //v1.0
  	   if (confirm(msg)){
			document.getElementById(formulaire).submit();
			}

}





function isValideExtension(ext,name){

	var name,i,error;
	error=1 ;
	exten=name.substring(name.lastIndexOf('.')+1);
	if(exten!=""){
		for(i=0;i<ext.length;i++){
			if(exten==ext[i]){
				error=0;
			}
		}
		
		if(error==1){
			alert ('Cette extension de fichier n\'est pas autorisé [ '+exten+' ].' );
		}
	}
		
}






function OpenSimpleLayer(id){
		document.getElementById(id).style.display = "block" ;
}
function CloseSimpleLayer(id){
		document.getElementById(id).style.display = "none" ;
}



function OpenLayer(id,plus,moin){
	   if(document.getElementById(id).style.display == "block") {
		document.getElementById(id).style.display = "none" ;
		document.getElementById('plus'+id).src=plus;
	   } else {
		document.getElementById(id).style.display = "block" ;
		document.getElementById('plus'+id).src=moin;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function validateForm() { //v4.0

  var i,p,q,nm,test,num,min,max,errors='',args=validateForm.arguments;
  
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.id; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' يجب أن يحتوي على عنوان بريد إلكتروني صحيح.<br>';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' doit contenir un entier.<br>'; 
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit contenir un entier entre '+min+' et '+max+'.<br>';
    } } } else if (test.charAt(0) == 'R'){ errors += '- '+nm+' حقل إجباري.<br>'; } } 
  //  } } } else if (test.charAt(0) == 'R'){ errors += '- '+nm+' est un champs obligatoire.<br>'; document.getElementById(nm).style.backgroundColor = "#FFCACA";} } 
 
 } 
 
  if (errors){  OpenSimpleLayer('Erreur'); document.getElementById('Erreur').innerHTML ='<table width="100%" border="0" dir="rtl" cellspacing="0" cellpadding="4" class="texte"><tr><td width="3%" bgcolor="#FFCACA"><div align="left"><img src="images/error.gif" /></div></td><td width="97%" bgcolor="#FFCACA">&nbsp;<b>خطأ :</b></td></tr><tr><td bgcolor="#FFCACA">&nbsp;</td><td bgcolor="#FFCACA">'+errors; +'</td></tr></table>';
  document.MM_returnValue = (errors == '');}else{ this.submit(); }
  //alert('Erreur(s) :\n'+errors); 
}
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->



function SUBMIT_FORM(id_form){
	document.getElementById(id_form).submit();
	}

function SET_VALUE(this_id,id){
		if(document.getElementById(this_id).value!=''){
			document.getElementById(id).value=document.getElementById(this_id).value;	
			}
	}

<!-- Begin

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null; 
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1]; 
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
   }
}
//  End -->
