var last_id = null;
var fx0403d=400;
var tim=(new Date()).getTime();
var formType = '';

function APonMouseOver (id)
{
	if (last_id != null) APonMouseOut (last_id);

	APChangeClass ("tr_"+id, "row_03_on");
	APChangeClass ("td_"+id, "row_03_on");
	APChangeClass ("pointeur_"+id, "pointeur_on");
	APChangeClass ("a_"+id, "texte_03_on");
	APChangeClass (id, "img_03_02_on");
	
	last_id = id;
}

function APonMouseOut (id)
{
	APChangeClass ("tr_"+id, "row_03_off");
	APChangeClass ("td_"+id, "row_03_off");
	APChangeClass ("pointeur_"+id, "pointeur_off");
	APChangeClass ("a_"+id, "texte_03");
	APChangeClass (id, "img_03_02");
}

function setSelected (href)
{
	$S('a.texte_03_selected').each (
		function(el) {
			el.className = 'texte_03';
		}
	);
	
	$S('a.texte_03').each (
		function(el) {
			var bChange = false;
			var target = el.href.match(/\?.*chemin=([a-zA-Z-0-9/_]*)/);
			if (target)	bChange = (target [1] == href);
			else {
				target = el.href.match(/^.*\/(fr|en|es)\/([^-.]*)\.html$/);
				if (target)	bChange = (target [2] == href);
			}
			
			if (bChange) el.className = 'texte_03_selected';
		}
	);
}

function initAnchor03 ()
{
	$S('a.texte_03', 'a.texte_03_selected').each (
		function(el){
			el.onclick=function () {
				if (fx0403.timer == null) {
					var param = '';
					var s = this.href.match(/^.*\/(fr|en|es)\/([^-.]*)(-([0-9]+))?\.html$/);
					if (s) {
						if (s[1]) param += '&lang='+s[1];
						if (s[2]) param += '&chemin='+s[2];
						if (s[4]) param += '&page='+s[4];
					}
					else {
						s = this.href.match(/.*index_(fr|en|es)\.php\?(.*)/);
						if (s) {
							if (s[1]) param += '&lang='+s[1];
							if (s[2]) param += '&'+s[2];
						}
					}
					
					fx0403.toggle ();
					
					var p = 'ajax.php?tim='+tim+'&target=site&type=partie_04&action=get'+param; 
					setTimeout("ajax0403 ('"+p+"')", fx0403d+100);
				}
				return false;
			}
		}
	);
}

function ajax0403 (p) {
	new Ajax.Updater('partie_04', p, {method:"get", asynchronous:true, evalScripts:true, onComplete: function(request){fx0403.toggle ();} });
}

function formValidate (o)
{
	var T = Array ('nom', 'societe', 'prenom', 'email', 'texte')
	var bError = false;
	var bEmailValid = true;
	
	for (i=0; i<T.length; i++) {
		var input = o.elements [T[i]];
		if (input != undefined) {
			if (input.value.trim () == "") {bError = true;break;}
			if (input.name == 'email') {
				var bEmailValid = checkMail (input.value);
				bError |= !bEmailValid;
				if (!bEmailValid) alert ('L\'adresse email semble incorrecte.');
			}
		}
	}
	
	if (bError && bEmailValid) {
		alert ('Formulaire incomplet.\nUn des champs est vide.');
	}

	return !bError;	
}

function showFormParticulier () {
	if (formType != 'par') {formType = 'par';formpanelFx.hide ();}
	var fxScroll = new fx.Scroll({duration: 200, transition: fx.sineOut, onComplete: function(){formShow ('formpanel', {fx: formpanelFx, url:'ajax.php?target=site&type=formpar&action=get'});}});
	fxScroll.scrollTo ($S ('#top'));
	//formShow ('formpanel', {fx: formpanelFx, url:'ajax.php?target=site&type=formpar&action=get'});
}

function showFormProfessionnel () {
	if (formType != 'pro') {formType = 'pro';formpanelFx.hide ();}
	var fxScroll = new fx.Scroll({duration: 200, transition: fx.sineOut, onComplete: function(){formShow ('formpanel', {fx: formpanelFx, url:'ajax.php?target=site&type=formpro&action=get'});}});
	fxScroll.scrollTo ($S ('#top'));
	//formShow ('formpanel', {fx: formpanelFx, url:'ajax.php?target=site&type=formpro&action=get'});
}

function postFormulaire (form) {
	formPost ('formpanel',form);
}

