var GAUCHE
var CENTER
var DROITE 
var CONTENANT
var MINHEIGHT= 3000

function loadPage()
{
    GAUCHE = (document.getElementById('colgauche'))?document.getElementById('colgauche'):null
    CENTER = (document.getElementById('colcentrale'))?document.getElementById('colcentrale'):null
    DROITE = (document.getElementById('coldroite'))?document.getElementById('coldroite'):null
    CONTENANT = (document.getElementById('contenu'))?document.getElementById('contenu'):null   
    // calcul de la hauteur minimale de la colonne centrale 
    var h = CENTER.clientHeight
    h = (h <= GAUCHE.clientHeight)?GAUCHE.clientHeight:h
    if(DROITE) {h = (h <= DROITE.clientHeight)?DROITE.clientHeight:h}
    if(MINHEIGHT>=h){MINHEIGHT=h} 
    setPosition();
    trame(); 
    init(); 
}

function setPosition()
{
  var h = GAUCHE.clientHeight
  h = (h < CENTER.clientHeight)?CENTER.clientHeight:h
  h = (h < DROITE.clientHeight)?DROITE.clientHeight:h
  if(h<MINHEIGHT)h=MINHEIGHT  
  GAUCHE.style.height = h + 'px'
  DROITE.style.height = h + 'px'
  CENTER.style.height = h + 'px' 
  CONTENANT.style.height = 40 + h + 'px'
}

window.onresize = function()
{
  trame(); 
}

function trame()
{
  if (!document.getElementById('trame')) { return; }
  var el = document.getElementById('trame');
  if(typeof window.pageYOffset == 'number')
  {
    el.style.height = parseInt(window.innerHeight) + 'px';
  }
  else
  {
    var p = document.documentElement;
    el.style.height = parseInt(p.clientHeight) + 'px';
	}
}

function centreanim()
{
  if(!document.getElementById('divanim')) { return; }
  var el = document.getElementById('divanim');
  //var el2 = document.getElementById('divtalon');
  if(typeof window.pageYOffset == 'number')
  {
    el.style.top = parseInt(window.pageYOffset) + parseInt(window.innerHeight)/2 - el.offsetHeight/2 + 'px';
    el.style.left = parseInt(window.pageXOffset) + parseInt(window.innerWidth)/2 - el.offsetWidth/2 + 'px';
    
	  //el2.style.top = parseInt(window.pageYOffset) + parseInt(window.innerHeight)/2 - el.offsetHeight/2 + el.offsetHeight + 'px';
	  //el2.style.left = el.style.left;
  }
  else
  {
    var p = document.documentElement;
    el.style.top = parseInt(p.scrollTop) + parseInt(p.clientHeight)/2 - el.offsetHeight/2 + 'px';
    el.style.left = parseInt(p.scrollLeft) + parseInt(p.clientWidth)/2 - el.offsetWidth/2 + 'px';
    
	  //el2.style.top = parseInt(p.scrollLeft) + parseInt(p.clientWidth)/2 - el.offsetWidth/2 + el.offsetHeight + 'px';
	  //el2.style.left = el.style.left;
  }
}

function CreateFlash(id, chemin, width, height, vars)
{
  //id : id de l'element dans lequel on va ecrire le flash    
  var d = document.getElementById(id);
  var flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '">' +
  '<param name="movie" value="' + chemin + '" />' +
  '<param name="quality" value="high" />' +
  '<param name="wmode" value="transparent" />' +
  '<param name="flashvars" value="' + vars + '">' +
  '<embed src="' + chemin + '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="' + vars + '" width="' + width + '" height="' + height + '"></embed></object>';
  d.innerHTML = flash;
}

// formulaires
var _nom, _prenom, _mail

function VerifForm()
{
	var isOk = true;
	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_nom'))) { isOk = false; }
	
	if (!VerifChamps($('ctl00_ContentPlaceHolder1_prenom'))) { isOk = false; }
	
	if (!VerifMail($('ctl00_ContentPlaceHolder1_email'))) { isOk = false; }
	
	return isOk;
}

function VerifChamps(c)
{
	if (!c.value)
	{
		c.className = 'champcontacterreur';
		return false;
  }
	else
	{
		c.className = 'champcontact';
		return true;
	}
}

function FocusChamps(c)
{
	c.className = 'champfocus';
}

function changeClass(o, c)
{
	o.className = c;
}

function BlurChamps(c)
{
	c.className = 'champcontact';
}

function VerifMail(c)
{
	if (!c.value)
	{
		c.className = 'champcontacterreur';
		return false;
	}
	else if (c.value.search(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/) == -1)
	{
		c.className = 'champcontacterreur';
		return false;
	}
	else
	{
		c.className = 'champcontact';
		return true;
	}
}