function deleteconfirm(msg, urladress) {
	if (window.confirm(msg)) {
		location.href=urladress;
	}
}
function removedate(date_field){
	date_field.value = "";
}
// A replacement for ToFixed without the errors // http://www.merlyn.demon.co.uk/js-rndg1.htm#toF
Number.prototype.toFixxed = function(f) {
  f = parseInt(f/1 || 0)
  if (f<0 || f>20) // next line was throw ...
    alert("The number of fractional digits is out of range")
  if (isNaN(this)) return "NaN"
  var s = this<0 ? "-" : "", x = Math.abs(this)
  if (x>Math.pow(10,21)) return s + x.toString()
  var m = Math.round(x*Math.pow(10,f)).toString()
  if (!f) return s + m
  while (m.length<=f) m = "0" + m
  return s + m.substring(0,m.length-f)+"."+m.substring(m.length-f)
}
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;
}

var min=10;
var max=15;
function increaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}
function regulier() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      p[i].style.fontSize = "12px"
   }
}






function decreaseFontSize() {
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }   
}


function viewImage(i, x) {
	var e = document.getElementById('bg');
	var image = document.getElementById('image_bg');

	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 number_format( number, decimals, dec_point, thousands_sep ) {
    // Formats a number with grouped thousands  
    // 
    // version: 902.1517
    // discuss at: http://phpjs.org/functions/number_format
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // +    revised by: Luke Smith (http://lucassmith.name)
    // +     bugfix by: Diogo Resende
    // +     bugfix by: Rival
    // %        note 1: For 1000.55 result with precision 1 in FF/Opera is 1,000.5, but in IE is 1,000.6
    // *     example 1: number_format(1234.56);
    // *     returns 1: '1,235'
    // *     example 2: number_format(1234.56, 2, ',', ' ');
    // *     returns 2: '1 234,56'
    // *     example 3: number_format(1234.5678, 2, '.', '');
    // *     returns 3: '1234.57'
    // *     example 4: number_format(67, 2, ',', '.');
    // *     returns 4: '67,00'
    // *     example 5: number_format(1000);
    // *     returns 5: '1,000'
    // *     example 6: number_format(67.311, 2);
    // *     returns 6: '67.31'
    var n = number, prec = decimals;
    n = !isFinite(+n) ? 0 : +n;
    prec = !isFinite(+prec) ? 0 : Math.abs(prec);
    var sep = (typeof thousands_sep == "undefined") ? ',' : thousands_sep;
    var dec = (typeof dec_point == "undefined") ? '.' : dec_point;

    var s = (prec > 0) ? n.toFixxed(prec) : Math.round(n).toFixxed(prec); //fix for IE parseFloat(0.55).toFixed(0) = 0;

    var abs = Math.abs(n).toFixxed(prec);
    var _, i;
	
    if (abs >= 1000) {
        _ = abs.split(/\D/);
        i = _[0].length % 3 || 3;

        _[0] = s.slice(0,i + (n < 0)) +
              _[0].slice(i).replace(/(\d{3})/g, sep+'$1');

        s = _.join(dec);
    } else {
        s = s.replace('.', dec);
    }

    return s;
}