//divers.js 
extArray = new Array("jpg");

function LimitAttach(file,form) {
	var allowSubmit = false;
	var lang = "fr";
	
	if (!file) {

		return;
	}
	var Length = file.length;
	var Ext = file.slice(Length - 3,Length); 
	var ext = Ext.toLowerCase();

	for (var i = 0; i < extArray.length; i++) {
	    if (extArray[i] == ext) { allowSubmit = true; }
	}

	if (allowSubmit) {
		form.submit()
		
	} else {
	if (lang == "fr") {
		   var message="S.V.P. utilisez seulement les fichiers de types suivants: " + (extArray.join("  "));
	   } else {
		   var message="Please only use file of the folllowing types: " + (extArray.join("  "));
		  }
	alert(message);
		    
	}
}

function SubmitForm(form) {
    form.submit();
}

function SetPaswordChange(form,value) {
    form.newpw.value= value;
}

function CheckIfAcceptDelete(Id,Name,Table) {
    if (confirm("Do you really want to delete " + Name + "?")) { 
	LoadPage("delete_element.php","table",Table,"index",Id)
    } else {
	LoadPage("opcancelled.php");
      }	
}

function LoadPage() {
    var args = LoadPage.arguments;
    var size = LoadPage.arguments.length;
    var pagename = LoadPage.arguments[0];
    var index = 1;
    var PageString = pagename;
    size = size - 1;
    while (index <= size) {
	if (index == 1) {
	    PageString += "?";
	}
	PageString += LoadPage.arguments[index]    	
	if (index %2) {
	    PageString += "=";	
	} else {
	    if (index != size) PageString += "&";
	  }
	
	index++;
    }
    location.href = PageString;
}