function pageWidth() {
  return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
 }
 
 function pageHeight() {
  return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
 }

function checkName(n) {
		var  strTemp = n ;
		var htlName = strTemp.replace("'", "\'");
		return htlName;
}
function checkNameInv(n) {
		var  strTemp = n ;
		var htlName = strTemp.replace("\'", "'");
		return htlName;
}

 function checkSize() {
	document.location.reload();
 }	

function roll(id) {
	for (var i=0; i<5;i++) {
		document.getElementById("drlv"+i).style.display = "none";
	}
	document.getElementById(id).style.display = "inline";
}

function closeChilds(strDivs) {
	var aTab = new Array(11,12,13,21,22,23,41,42);
	for (var i=0; i < aTab.length; i++) {
		document.getElementById(Number(aTab[i])).style.display = "none";
	}	
}

function viewChilds(id,nb) {
	closeChilds();
	var strDivs = "";
	for (var i=1; i<=nb; i++) {
		if (document.getElementById((Number(id)+i)).style.display  == "none") {
			document.getElementById((Number(id)+i)).style.display  = "inline";
			if (strDivs == "") {
				strDivs +=	(Number(id)+i) ;
			} else {
				strDivs += "|" + (Number(id)+i) ;
			}
		} else {
			document.getElementById((Number(id)+i)).style.display  = "none";
		}
	}
	//alert("strDivs = " + strDivs) ;	
}

function delNode(idNode, url) {
	var check = confirm("Confirmez-vous la suppression de ce bloc ?");
	if (check == true) {		
		document.location.href = String(url) + idNode ;
	}
}

function checkDiv(divName, p_top) {
	ie4=document.all
	ns6=document.getElementById&&!document.all
	ns4=document.layers

	if (ie4) {eval(divName).style.pixelTop=document.body.scrollTop+p_top}
	else if (ns6) {document.getElementById(divName).style.top=window.pageYOffset+p_top}
	else if (ns4) {eval(document.eval(divName).top=eval(window.pageYOffset+p_top));}
	if(ie4 || ns6 || ns4)
	setTimeout("checkDiv('"+String(divName)+"', "+p_top+")",1);	
}

function checkMail() {
			//var email = form.email.value;
			var email = document.getElementById("email").value;
			var aroba = email.indexOf("@");
			//test si @ est présent
			//si il n'est pas présent, l'adresse n'est pas valide
			if (aroba == -1) {
			  document.getElementById("email").style.backgroundColor = "#FFFFD1";
			  alert("L'adresse email n'est pas valide...\nIl n'y a pas de caractere @\nUne adresse mail valide est du type \"adresse@domaine.com\"");
			   document.getElementById("email").focus();
			  return false;
			}
			//vérifie si il y a un . après @ et qu'il ne se trouve pas juste derrière ("adresse@.com" non valide)
			var point = email.indexOf(".", aroba);
			if (point == -1)  {
			  document.getElementById("email").style.backgroundColor = "#FFFFD1";
			  alert("L'adresse email n'est pas valide...\nIl n'y a pas de point après @\nUne adresse mail valide est du type \"adresse@domaine.com\"");
			   document.getElementById("email").focus();
			  return false;
			} else if (point == (aroba + 1)) {
              document.getElementById("email").style.backgroundColor = "#FFFFD1";	
			  alert("L'adresse email n'est pas valide...\nIl ne peut pas y avoir un point (.) juste après @\nUne adresse mail valide est du type \"adresse@domaine.com\"");
			  document.getElementById("email").focus();
			  return false;
			}			
			//vérifie si il y a au moins 1 caractère après le point
			//point + 1 car indexOf commence à 0.
			//Si l'index est 4 et la longueur de la chaîne 5, erreur
			var point = email.lastIndexOf(".");
			if ((point + 1) == email.length) {
			   document.getElementById("email").style.backgroundColor = "#FFFFD1";	
			  alert("L'adresse email n'est pas valide...\nL'adresse mail ne peut pas finir par un point (.)\nUne adresse mail valide est du type \"adresse@domaine.com\"");
			   document.getElementById("email").focus();
			  return false;
			}
			//vérifie s'il n'y a pas deux . qui se suivent
			point = email.indexOf("..")
			if (point != -1) {
			  document.getElementById("email").style.backgroundColor = "#FFFFD1";		
			  alert("L'adresse email n'est pas valide...\nL'adresse mail ne peut pas contenir 2 points (.) qui se suivent.\nUne adresse mail valide est du type \"adresse@domaine.com\"");
		      document.getElementById("email").focus();
			  return false;
			}			
			return true;
		}



function filterNews(xsl, val, lng) {
	document.location.href = "./portalNews.php?x="+xsl+"&l="+lng+"&f="+val;
}

function filterSH(val, lng) {
	document.location.href = "./portalSH.php?x=SH&l="+lng+"&f="+val;
}


function delPic(pic, name, token) {
	var check = confirm("Confirmez-vous la suppression de l'image \""+ name +"\" ?");
	if (check == true) {
		document.location.href = "./update.php?tkn="+token+"&x=HOME&pic="+pic+"&del";
	}
}

function delTdg(pic, cust,  name, token) {
	var check = confirm("Confirmez-vous la suppression de la TDG \""+ name +"\" ?");
	if (check == true) {
		document.location.href = "./update.php?tkn="+token+"&x=HOME&pic="+pic+"&cust="+cust+"&del";
	}
}

function delNews(news, cust,  name, img1, img2, token) {
	var check = confirm("Confirmez-vous la suppression de la News \""+ name +"\" ?");
	if (check == true) {
		document.location.href = "./update.php?tkn="+token+"&x=HOME&news="+news+"&custID="+cust+"&img1="+img1+"&img2="+img2+"&del";
	}
}

function delAwd(awd, cust,  name, custName, token) {
	var check = confirm("Confirmez-vous la suppression de la récompense "+ name +" pour \""+custName+"\" ?");
	if (check == true) {
		document.location.href = "./update.php?tkn="+token+"&x=AWARDS&awdID="+awd+"&custID="+cust+"&del";
	}
}

function closeInfos() {
	document.getElementById("AcoInfos").style.display="none";
}

