function deleteconfirm(urladress) {
	if (window.confirm('Voulez-vous vraiment supprimer cet item?\nC\'est irréversible.')) {
		location.href=urladress;
	}
}

function deleteconfirm2(msg, urladress) {
	if (window.confirm(msg)) {
		location.href=urladress;
	}
}
function deleteconfirmPDF(urladress) {
	if (window.confirm('Voulez-vous vraiment supprimer ce PDF?\nC\'est irréversible.')) {
		location.href=urladress;
	}
}

function deleteconfirmIMAGE(urladress) {
	if (window.confirm('Voulez-vous vraiment supprimer cette image?\nC\'est irréversible.')) {
		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.getElementById('txtSub').value;
	gst = document.getElementById('txtGST').value;
	pst = document.getElementById('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{
		gst = gst.replace(/,/,".");
		if(isValidDec(gst)==false){
			alert('The GST Total must be a valid number!');
			return false;
		}	
	}
	if(pst==''){
		pst=0;
	}else{
		pst = pst.replace(/,/,".");
		if(isValidDec(pst)==false){
			alert('The PST Total must be a valid number!');
			return false;
		}	
	}
	total = parseFloat(subtotal) + parseFloat(gst) + parseFloat(pst);
	document.getElementById('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


//------------display hide form
	
	function viewImage(i, x) {
		var e = document.getElementById('bg');
		var image = document.getElementById('image');


		if (e && image) {
		
			if (x) {
				opened = 1;
				if (image.style.display == 'none') {				
					//image.style.top = document.documentElement.scrollTop+(444/2)+"px";
					
					 var viewportwidth;
					 var viewportheight;
					 
					 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
					 
					 if (typeof window.innerWidth != 'undefined')
					 {
						  viewportwidth = window.innerWidth,
						  viewportheight = window.innerHeight
					 }
					 
					// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
					
					 else if (typeof document.documentElement != 'undefined'
						 && typeof document.documentElement.clientWidth !=
						 'undefined' && document.documentElement.clientWidth != 0)
					 {
						   viewportwidth = document.documentElement.clientWidth,
						   viewportheight = document.documentElement.clientHeight
					 }
					 
					 // older versions of IE
					 
					 else
					 {
						   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
						   viewportheight = document.getElementsByTagName('body')[0].clientHeight
					 }
					
					
					
					
					
					
					image.style.top = document.documentElement.scrollTop+viewportheight/2-(419/2)+"px";
					image.style.left = (viewportwidth/2)-(360/2)+"px";				
				}
				
				
				
				
				if (image.style.display == 'none') { 
					image.style.display = 'block';					
					e.style.left = 0+"px";
					e.style.top = 0+"px";
					e.style.display = 'block';
					e.style.width = viewportwidth+"px";
					e.style.height = viewportheight+"px";		
					/*
					if (document.documentElement.scrollWidth > document.documentElement.offsetWidth) {
						e.style.width = document.documentElement.scrollWidth+"px";
					} else {
						e.style.width = document.documentElement.offsetWidth+"px";				
					}				
					*/	
					
					if (document.documentElement.scrollHeight > document.documentElement.offsetHeight) {
						e.style.height = document.documentElement.scrollHeight+"px";
					} else {
						e.style.height = document.documentElement.offsetHeight+"px";				
					}			
				}
			} else {
				opened = 0;
				e.style.display = 'none';							
				image.style.display = 'none';
			}								
		}
	}
	
	function validateForm(frm) {
		if (frm.from_name.value == '') { 
			alert('Veuillez entrer votre nom!');
		} else if ((frm.from_email.value == '') || (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.from_email.value)))) {
			alert('Votre adresse de courriel est invalide!');
		} else if (frm.to_name.value == '') { 			
			alert('Veuillez entrer le nom de votre ami(e)!');
		} else if ((frm.to_email.value == '') || (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.to_email.value)))) {
			alert('L\'adresse courriel de votre ami(e) est invalide!');
		} else {
			frm.submit();
			return true;
		}
		return false;
	}
	
	
		function validateForm_e(frm) {
		if (frm.from_name.value == '') { 
			alert('Please enter your name!');
		} else if ((frm.from_email.value == '') || (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.from_email.value)))) {
			alert('Your email address is invalid!');
		} else if (frm.to_name.value == '') { 			
			alert('Please enter your friend name!');
		} else if ((frm.to_email.value == '') || (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(frm.to_email.value)))) {
			alert('The email address of your friend is invalid!');
		} else {
			frm.submit();
			return true;
		}
		return false;
	}
//------------Fin
