function deleteconfirm(urladress) {
	if (window.confirm('Voulez-vous vraiment supprimer cet élément?\nIl est impossible de revenir en arrière.')) {
		location.href=urladress;
	}
}

function assign(urladress) {
	if (window.confirm('Do you really want to assign this instructor?\nAn e-mail will be sent to him saying that he has been assigned.')) {
		location.href=urladress;
	}
}

function unassign(urladress) {
	if (window.confirm('Do you really want to unassign this instructor?\nAn e-mail will be sent to him saying that he has been unassigned.')) {
		location.href=urladress;
	}
}
function confirmmessage(message) {
	if (window.confirm(message)) {
		return true;
	}else{
		return false;	
	}
}
//----------Formulaires à bascules
function Deplacer(l1,l2){
for(i=l1.options.length;i>=0; i--){
        if(l1.options.selectedIndex!=-1) {
            o=new Option(l1.options[l1.options.selectedIndex].text,l1.options[l1.options.selectedIndex].value);
            l2.options[l2.options.length]=o;
            l1.options[l1.options.selectedIndex]=null;
        }
    }
}

function SelectOnSend(l2){
	var source = document.getElementById(l2);
	source.setAttribute("multiple","multiple");
	var i = 0
	while(source.getElementsByTagName("option")[i]){
		source.getElementsByTagName("option")[i].selected = "selected";
		i++;
	}
}
//------------Fin
//------------Display - Hide <div>

function OpenCloseSlide(laslideTitre, laslide)
{
	if(document.getElementById(laslide).style.display=='block')
	{	
		document.getElementById(laslideTitre).innerHTML='Modify';
		document.getElementById(laslide).style.display='none';
		
	}else{
		document.getElementById(laslideTitre).innerHTML='Close';
		document.getElementById(laslide).style.display='block';
	}
	
	
}
function calculTotal()
{
	subtotal = document.formExam.txtSub.value;
	gst = document.formExam.txtGST.value;
	pst = document.formExam.txtPST.value;
	
	if(subtotal==''){
		subtotal=0;
	}else{
		subtotal = subtotal.replace(/,/,".");
		if(isValidDec(subtotal)==false){
			alert('The Sub Total must be a valid number!');
			return false;
		}	
	}
	if(gst==''){
		gst=0;
	}else{
		if(isValidDec(gst)==false){
			alert('The GST Total must be a valid number!');
			return false;
		}	
	}
	if(pst==''){
		pst=0;
	}else{
		if(isValidDec(pst)==false){
			alert('The PST Total must be a valid number!');
			return false;
		}	
	}
	total = parseFloat(subtotal) + parseFloat(gst) + parseFloat(pst);
	document.formExam.txtTotal.value = total.toFixed(2); ;
	
	
}
function isValidDec(fieldValue)
{		
		var sDecimalSep = "\.";
		var sDecimalPattern = "/^[-]?\\d*[" + sDecimalSep + "]?\\d*$/";
		var sDecimalSep2 = "\,";
		var sDecimalPattern2 = "/^[-]?\\d*[" + sDecimalSep2 + "]?\\d*$/";

		if(eval("fieldValue.search(" + sDecimalPattern + ")") == -1 && eval("fieldValue.search(" + sDecimalPattern2 + ")") == -1)
		{    	
			return (false);
		}
		
		return (true);
}

function checkDecimals(mnt) {
	var mnt = ""+mnt;
	var mntlength = mnt.length;
	var pos =  mnt.indexOf('.');
	if (pos == -1) 
	{
		mnt += ".00";
	} 
	else if ( mntlength - pos == 2) 
	{
		mnt += "0";
	} 
	else if (mntlength - pos == 0) 
	{
		mnt += "00";
	} 
	return mnt;
}
//------------Fin



