	
	ajaxPage = new sack();	
	pf=0;
	
	function prefillEmail()
	{
		mailing()
		/*
		pf=1;
		loadPage("members");
		*/
	}
	
	function load_option_fill()
	{
			if ( pf==1)
			{
				document.getElementById("email").value=	document.getElementById("login_name").value
			}
			pf=0;
	}
	
	function loadPage(p)
	{
					ajaxPage.resetData();
					ajaxPage.resetFunctions();
					
					x="common_inc/pages/"+p+".php"
					ajaxPage.requestFile= x;
					
					ajaxPage.setVar("isLogged",document.getElementById("isLogged").value );
					
					ajaxPage.method="POST";
					ajaxPage.element="content_page";
				
					// ajaxPage.onCompletion=load_option_fill;

					ajaxPage.runAJAX();	
					
					if ( p=="news" )
					{
						document.getElementById("leftblock").style.display="";
					}
					else
					{
						document.getElementById("leftblock").style.display="none";
					}
	}
	
	function mailing()
	{
					ajaxPage.resetData();
					ajaxPage.resetFunctions();
				
					x="common_inc/pages/members.php"
					ajaxPage.requestFile= x;
					
					em=document.getElementById("loginName").value;
					ajaxPage.setVar("email", em);
					
					ajaxPage.method="POST";
					ajaxPage.element="content_page";
				
					ajaxPage.runAJAX();	
	}
	
	err = 0;
	elm="";

form_error_common="Ne peut pas être vide"
from_error_make_a_choice="faites un choix";
form_error_email="Format invalide"

function checkForm(elm)
{
	
	elmId = new Array();
	elmType = new Array();
	
	elmId[0]="formFirstName";	elmType[0]="classic";			
	elmId[1]="formLastName";	elmType[1]="classic";			
	elmId[2]="formStates";		elmType[2]="classic";		
	elmId[3]="formAdress";		elmType[3]="classic";			
	elmId[4]="formNum";			elmType[4]="classic";			
	elmId[5]="formCity";			elmType[5]="classic";		
	elmId[6]="formZip";				elmType[6]="classic";			
	elmId[7]="formEmail";			elmType[7]="email";			
	
	err=0;

	for(i=0;i<elmId.length;i++)
	{		
			if ( elm=="all" || elm==elmId[i] )
			{
			
						if ( elmType[i]=="classic")
						{
									if ( $(elmId[i]).value=="")
									{	
											$(elmId[i]+"Err").innerHTML=form_error_common;
											err=err+1;
									}
									else
									{
											$(elmId[i]+"Err").innerHTML="";									
									}														
						}
			
						if ( elmType[i]=="email")
						{			
									if ( $(elmId[i]).value=="" )
									{
											$(elmId[i]+"Err").innerHTML=form_error_common;
											err=err+1;
									}
									else
									{			
											oo=$(elmId[i]).value;
											oo=oo.toLowerCase();
											$(elmId[i]).value=oo;
				
											r=check_email( $(elmId[i]).value )
	
											if ( r==false )
											{
													$(elmId[i]+"Err").innerHTML=form_error_email;
													err=err+1;
											}
											else
											{																					
													$(elmId[i]+"Err").innerHTML="";
											}							
									}										
						}
			}
	}
		
	if ( elm=="all")
	{

		if ( err==0 )
		{
					ajaxPage.resetData();
					ajaxPage.resetFunctions();
				
					x="common_inc/pages/members_action.php"
					ajaxPage.requestFile= x;
					
					ajaxPage.setVar("formFirstName",document.getElementById("formFirstName").value );
					ajaxPage.setVar("formLastName",document.getElementById("formLastName").value );
					ajaxPage.setVar("formStates",document.getElementById("formStates").value );
					ajaxPage.setVar("formAdress",document.getElementById("formAdress").value );
					ajaxPage.setVar("formNum",document.getElementById("formNum").value );
					ajaxPage.setVar("formBox",document.getElementById("formBox").value );
					ajaxPage.setVar("formCity",document.getElementById("formCity").value );
					ajaxPage.setVar("formZip",document.getElementById("formZip").value );
					ajaxPage.setVar("formCountry",document.getElementById("formCountry").value );
					ajaxPage.setVar("formEmail",document.getElementById("formEmail").value );
					ajaxPage.setVar("formWeb",document.getElementById("formWeb").value );
					
					if ( document.getElementById("formContact1").checked==true )
					{
						ajaxPage.setVar("formContact1","1" );
					}
					else
					{
						ajaxPage.setVar("formContact1","0" );
					}
					
					if ( document.getElementById("formContact2").checked==true )
					{
						ajaxPage.setVar("formContact2","1" );
					}
					else
					{
						ajaxPage.setVar("formContact2","0" );
					}
						
					ajaxPage.setVar("formMembersList",document.getElementById("formMembersList").value );
					
					ajaxPage.setVar("appearMail",document.getElementById("appearMail").value );
					ajaxPage.setVar("appearWeb",document.getElementById("appearWeb").value );
					
					ajaxPage.method="POST";
					ajaxPage.element="content_page";
				
					ajaxPage.runAJAX();					
		}	
		
	}
		
}	

	function login()
	{
					ajaxPage.resetData();
					ajaxPage.resetFunctions();
				
					x="common_inc/pages/login.php"
					ajaxPage.requestFile= x;
					
					ajaxPage.setVar("login_name",document.getElementById("login_name").value );
					ajaxPage.setVar("login_pwd",document.getElementById("login_pwd").value );
					
					ajaxPage.method="POST";
					ajaxPage.element="content_page";
				
					ajaxPage.onCompletion=check_login;

					ajaxPage.runAJAX();	
	}
	
	function check_login()
	{
			if ( $("isLoggedTmp").value==1 )
			{
					$("isLogged").value=1
					// $("loginForm").innerHTML="";
					$("loginForm").style.display="none";
					$("loginOk").style.display="";
			}
	}
	
	function logout()
	{
					$("isLogged").value=0;
					// $("loginForm").innerHTML="";
					$("loginForm").style.display="";
					$("loginOk").style.display="none";			
	}
	
	function showHide(elm,a)
	{
			if ( a=="max" )
			{
					$("elm"+elm+"_minimal").style.display="none";
					$("elm"+elm+"_full").style.display="";
			}
			else
			{
					$("elm"+elm+"_minimal").style.display="";
					$("elm"+elm+"_full").style.display="none";				
			}
	}
	
	function formNewPassword()
	{
			err=0;
			
			$("newPasswordErr").innerHTML="&nbsp;";
			$("newPassword2Err").innerHTML="&nbsp;";
			
			if( $("newPassword").value=="" )
			{
				$("newPasswordErr").innerHTML="Ne peut pas être vide";
				err=1;
			}
			else if( $("newPassword2").value=="" )
			{
				$("newPassword2Err").innerHTML="Ne peut pas être vide";
				err=1;
			}
			else
			{
				if ( $("newPassword").value!=$("newPassword2").value )
				{
					$("newPasswordErr").innerHTML="Les mots de passe ne sont pas identique";
					err=1;
				}
			}

			if (err==0)
			{
					ajaxPage.resetData();
					ajaxPage.resetFunctions();
					
					x="common_inc/pages/update_profile_action.php"
					ajaxPage.requestFile= x;
					
					ajaxPage.setVar("newPassword",document.getElementById("newPassword").value );
					ajaxPage.setVar("oldPassword",document.getElementById("oldPassword").value );
					ajaxPage.setVar("oldEmail",document.getElementById("oldEmail").value );
					
					ajaxPage.method="POST";
					ajaxPage.element="content_page";
				
					ajaxPage.runAJAX();					
			}			
	}