﻿
/* à appeller à partir du onLoad de la page enfant */
function resizeIframe(iframeID) {
	if(self==parent) 
		return false; /* Checks that page is in iframe. */
	else if(document.getElementById)
	{
		/* framePage is the ID of the framed page's BODY tag.  */
		/* "iframeID" is the ID of the inline frame in the parent page. */
		
		//parent.document.getElementById(iframeID).style.height="200px";//document.body.scrollHeight+"px";
		if( document.all ) //IE
			FramePageHeight = document.body.scrollHeight + 50;
		else // FireFox
			FramePageHeight = document.body.offsetHeight + 50;
			
		parent.document.getElementById(iframeID).style.height=FramePageHeight+"px";
		
	}
} 

function resizeIframeFixe(iframeID, height) {
	if(self==parent) 
		return false; /* Checks that page is in iframe. */
	else if(document.getElementById)
	{
		/* nécessaire juste si on rappel plusieurs fois la fonction */
		parent.document.getElementById(iframeID).style.height=height + "px";
	}
} 

function resizeIframePlus(iframeID) {
	var FramePageHeight;
	if(self==parent) 
		return false; /* Checks that page is in iframe. */
	else if(document.getElementById)
	{
		/* framePage is the ID of the framed page's BODY tag.  */
		/* "iframeID" is the ID of the inline frame in the parent page. */

		//parent.document.getElementById(iframeID).style.height="100px";//document.body.scrollHeight+"px";
		if( document.all ) //IE
			FramePageHeight = document.body.scrollHeight + 600;
		else // FireFox
			FramePageHeight = document.body.offsetHeight + 600;
			
		parent.document.getElementById(iframeID).style.height=FramePageHeight+"px";
		
	}
} 

function formatNr(nr)
{
	thousands = parseInt(nr/1000);
	hundreds = parseInt(nr - thousands*1000);
	decimals = parseInt((nr - parseInt(nr)) * 100);
	return (thousands > 0 ? thousands + ' ' : '') + (nr > 1000 & hundreds < 100 ? '0' : '') + (nr > 1000 & hundreds < 10 ? '0' : '') + hundreds + ',' + (decimals > 0 ? decimals : '00');
}

function isNumeric(sText){
	var ValidChars = "0123456789.";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length; i++)
	{
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1)
		{
			IsNumber = false;
		}
	}
	return IsNumber;
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

function pop(page) {
  Hwnd = window.open( page, "pop", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=420,height=220,top=200,left=300" );
  Hwnd.focus();
}

function EmailValide (szEmail){
	var bVal, caractInvalides, a, caract;
	bVal = true;
	caractInvalides = " /:,;";

	if( szEmail.length < 5 ){
		bVal = false;
	}
	for( a=1; a <= caractInvalides.length; a++ ){
		caract = caractInvalides.charAt(a)
		if( szEmail.indexOf(caract) > 0 ){
			bVal = false;
		}
	}
	if( szEmail.indexOf("@") < 1 || szEmail.indexOf("@") == szEmail.length ){
		bVal = false;
	}
	if( szEmail.indexOf(".") < 1 || szEmail.indexOf(".") == szEmail.length ){
		bVal = false;
	}
	return bVal;
}
