window.onload = function() {
  if (typeof(PageInitialization) != 'undefined') {
    PageInitialization.each(function (fct) { fct(); });
  }
  if (typeof(InitGmap) == 'function') { InitGmap(); }
  if (typeof(InitEmailMessage) == 'function') { InitEmailMessage(); }
  if (typeof(InitPaiement) == 'function') { InitPaiement(); }
}

function loupe(el){
    if(el.tagName=='IMG'){
		ctl00_loupe.showMessage();			
		$('photozoom').src = el.src.replace('.jpg','_z.jpg');
		$('chargement').style.display="none";	
		$("photozoom").onload = function(){
			$('chargement').style.display="block";
		}
	}
}

function zoomImage(ClickedElement) {
  ctl00_Message_zoom.message.update();
  var newElement = ClickedElement.next().cloneNode(true);
  newElement.observe('click', function () {
    ctl00_Message_zoom.hideMessage();
  });
  newElement.show();
  var newDiv = new Element('div').setStyle({textAlign: 'center'});
  newDiv.insert(newElement)
  newDiv.insert('<br/><em>cliquez sur l\'image pour fermer</em>');
  ctl00_Message_zoom.message.insert(newDiv);
  ctl00_Message_zoom.showMessage();
}

function AddInitFunction(fct) {
  if (typeof(PageInitialization) == 'undefined') {
    window.PageInitialization = new Array();  
  }  
  PageInitialization.push(fct);
}

//ANIMATIONS FLASH
function CreateFlash(id, chemin, width, height, vars){
	var d;
	if(document.getElementById(id)){d = document.getElementById(id)} else {return}
    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 ($('ctl00_ContentPlaceHolder1_typeZone').value == 'fr')
	{
	  if ($('ctl00_ContentPlaceHolder1_typeFR').value == 1)
	  {
	    if (!VerifChamps($('ctl00_ContentPlaceHolder1_departement'))) { isOk = false; }
	  }
	}
	else if ($('ctl00_ContentPlaceHolder1_typeZone').value == 'wo')
	{
	  if (!VerifChamps($('ctl00_ContentPlaceHolder1_pays'))) { isOk = false; }
	}
	else { isOk = false; }		
	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;
	}
}

function coinsarrondis(id,tag){
	settings = {tl: { radius: 8 },tr: { radius: 8 },bl: { radius: 8 },br: { radius: 8 },antiAlias: true,autoPad: true,validTags: ['a']}
     //var divObj01 = $(id);
	 var cornersObj = new curvyCorners(settings, $('tempsl'));
	 cornersObj.applyCornersToAll();
}
	
function changeonglet(sender, el){
    var objs = $('ongletscontenu').select('DIV#div1, DIV#div2, DIV#div3, DIV#div4')
    objs.each(function(node){if (node) {node.hide()}})
    $('div'+ el.value).show();
	alert(el.value)
}

function choixSecteurFlash(el){
	//alert(el);
	if(el){
		if(el=='est') e = $('ctl00_colcontenu_CheckBox_Est');
		if(el=='ouest') e = $('ctl00_colcontenu_CheckBox_Ouest');
		if(el=='interieur') e = $('ctl00_colcontenu_CheckBox_Interieure');
		if(e.checked == true){e.checked = false}else{e.checked = true};
	}
}

function afficheAgence(n){
	if(n){
		$('agenceinfo').style.display = 'none';
		for(i=0;i<3;i++){
			$('agence'+i).style.display = 'none';
		}
		$('agence'+n).style.display = 'block';
	}
}


