function checkSubmit()
{
	if($('formNom').value == '')
	{
		alert('Vous n\'avez pas remplis le champ Nom');
		return false;
	}
	
	if(document.getElementById('formPrenom').value == '')
	{
		alert('Vous n\'avez pas remplis le champ Prenom');
		return false;
	}

	
	
	if($('formMessage').value == '')
	{
		alert('Vous n\'avez pas remplis le champ Message');
		return false;
	}
	
	if($('formTel').value == '' && $('formEmail').value == '')
	{
		alert('Vous devez indiquer soit votre numéro de téléphone soit votre e-mail');
		return false;
	}

	return true;

}

function icf_font(sens)
{
	var taille = ["smallerx","smaller","normal","larger", "largerx"];
	var cle;
	var classN;
	body = $('mybody');

	classN = body.className;
	if( (cle = taille.indexOf(classN)) >= 0 )
	{
		if(sens > 0 && cle < 4)
		{
			icf_changeFont(taille[cle + 1]);
		}
		else if(sens < 0 && cle > 0)
		{
			icf_changeFont(taille[cle - 1])
		}
	}
	
}

var icf_changeFont = function(plus) {
	var body;
	body = $('mybody');
	if (body) {
		var className = plus;
		$(body).removeClassName(body.className);
		$(body).addClassName(className);
		//@todo...
		//
		//$(body).toggleClassName(className);
		icf_writeCookie('icf_changeFont', className);
	}
};


function icf_readCookie(name) {
 var nameEQ = name + "=";
 var ca = document.cookie.split(';');
 for(var i=0;i < ca.length;i++) {
   var c = ca[i];
   while (c.charAt(0)==' ') c = c.substring(1,c.length);
   if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
 }
 return null;
}

function icf_writeCookie(name,value) {
 document.cookie = name+"="+value+"; path=/";
}

document.observe("dom:loaded", function() {
	var className = icf_readCookie('icf_changeFont');
	if (className) {
		icf_changeFont(className);
	}
});

function imprimer()
{

	if(window.print)
		window.print();
	
}

function favoris()
{
	try
	{
		window.external.addfavorite('http://www.icf.fr', 'Entreprise de conseil en gestion de patrimoine - Cabinet indépendant')
	}
	catch(err)
	{
		alert('Votre navigateur n\'accepte pas l\'ajout automatique dans les favoris. Si vous utilisez Firefox, vous pouvez utiliser le racourci clavier CTRL + D.');
	}
}

/*
* Gestion du simulateur
*/

function simu_choix( num )
{
	var i = 1;
	while(i <= 4)
	{	
		if(i == num)
		{
			$('simuElement' + i).style.display = 'none';
		}
		else
		{
			$('simuElement' + i).style.display = 'block';
		}
		i++;
	}
	$('choixConnu').value = num;
}

function simu_check()
{
	var i = 1;
	var tab = ['','formCapital','formDuree','formTaux', 'formMensu'];
	var nom = ['','le capital','la duree','le taux', 'les mensualités'];

	while(i <= 4)
	{	
		$(tab[i]).value = parseFloat($(tab[i]).value);
		if(i != $('choixConnu').value && $(tab[i]).value == "NaN")
		{
			 alert("Vous n'avez pas correctement rempli champ concernant "+nom[i]);
			 $(tab[i]).value = "";
			 return false;
		}
		
		i++;
	}
	return true;
}


/*
Fonctions lire la suite
*/

function deroule() {
	$('page-content').removeClassName('page-content-small');
	$('page-content').style.height = '';
	if($('page-sidebar-bottom'))
	{
		$('page-sidebar-bottom').style.bottom = '0px';
	}
	resizeAll();
}

function enroule() {
	$('page-content').addClassName('page-content-small');
	resizeAll();
}

function resizeAll() {
	if($('page-bottom'))
		var h = $('page-bottom').getHeight();
	else
		var h = 0;

	if($('page-sidebar-top').getHeight() + $('page-sidebar-bottom').getHeight() - 60 >= $('page-main').getHeight())
	{
		$('page-content').style.height = ($('page-sidebar-top').getHeight() + $('page-sidebar-bottom').getHeight()-h-85) +'px';
		
	}
	else
	{
		
	}
}

// call deroule on "small" page-content
Event.observe(window, 'load', function(){
	return;
	//@fixme ATTENTION, il y adéjà beaucoup de problèmes dans deroule, enroule, resizeAll...
	resizeAll();
	var elm = $('page-content');
	if (elm) {
		var oldH = elm.getHeight();
		$('page-content').removeClassName('page-content-small');
		$('page-content').style.height = '';
		resizeAll();

		var autoH = elm.getHeight();
		$('page-content').addClassName('page-content-small');
		$('page-content').style.height = oldH + 'px';
		resizeAll();
			
		if (autoH <= oldH) {
			deroule();
			$('liresuite').style.display='none';
			$('hautpage').style.display='block';
		}
	}
});
