function demo() {		
	var mywidth=700;
	var myheight=400;
  		var mytop=(screen.height-myheight)/2;
  		var myleft=(screen.width-mywidth)/2;
	window.open('/demo.html','demo','width='+mywidth+',height='+myheight+',top='+mytop+',left='+myleft+',resizable=no,scrollbars=no');
}
function blueland() {		
	var mywidth=680;
	var myheight=550;
  		var mytop=(screen.height-myheight)/2;
  		var myleft=(screen.width-mywidth)/2;
	window.open('/blueland/','Blue Land','width='+mywidth+',top='+mytop+',left='+myleft+',resizable=yes,scrollbars=yes');
}
function more(page) {
	mywidth=450;
	myheight=500;
	myleft=(window.screen.width - mywidth)/2;
	mytop=(window.screen.height - myheight)/2;
	window.open(page,'more','width='+mywidth+',height='+myheight+',left='+myleft+',top='+mytop+',resizable=yes,scrollbars=yes');
}
function etat(etat,id,height) {
	var mywidth = 280;
	var myheight = (height > 0 ? height : 120);
	var myleft = (window.screen.width - mywidth)/2;
	var mytop = (window.screen.height - myheight)/2;
	window.open('/etat.php?etat='+etat+'&id='+id,'etat','width='+mywidth+',height='+myheight+',left='+myleft+',top='+mytop+',resizable=yes,scrollbars=yes');
}

function isEmail(str) {
	// are regular expressions supported?
	var supported = 0;
	if (window.RegExp) {
		var tempStr = 'a';
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
	}
	if (!supported) return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
	var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,4}|[0-9]{1,4})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

function MM_findObj(n, d) { //v4.0
  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 && document.getElementById ) x=document.getElementById(n);
  return x;
}


function update_liste_projets() {
	var ref = MM_findObj('ref');
	window.location='/projets/liste/'+ref.value;
	return false;
}
function update_liste2_projets() {
	var ref = MM_findObj('ref');
	window.location='/projets/liste2/'+ref.value;
	return false;
}

function annuler_operation(id) {
	self.opener.location='/compte/annuler/'+id;
	self.close();
}

function check_montant(my_montant,my_devise) {
	var montant = MM_findObj(my_montant).value > 0 ? parseInt(MM_findObj(my_montant).value,10) : 0;
	var montant_max = MM_findObj('montant_max_1').value > 0 ? parseInt(MM_findObj('montant_max_1').value,10) : 0;
	var pass = true;
	if ( montant < 0 ) {
		pass = false;
		alert('Vous devez faire une attribution >= 0 '+my_devise);
	}
	if ( montant > montant_max ) {
		pass = false;
		alert('Vous devez faire une attribution <= '+montant_max+' '+my_devise);
	}
	return pass;
}