// JavaScript Document

function submitForm(nbContact)
{
	var verif=true;
	var formValid = false;
	var i =1;
	var mailValid=true;
	
	
	if(document.sendEcard.prenom.value != ""){
		while(i<=nbContact && verif && mailValid){
			if(document.sendEcard["son_prenom_"+i].value == ""){
				verif=false;
				formValid = false;
						
			} else{ 
				mailValid=VerifForm(document.sendEcard["son_email_"+i].value);
			}
			i++;
			
		}
		if(mailValid){		
			if(verif){
				//alert("VALIDER");
					document.sendEcard.target="_self";
					document.sendEcard.action = "send.php?nb="+nbContact;
					document.sendEcard.submit();	
			} else{
				alert("Vous devez remplir tous les champs");	
			}
		} else{
			document.sendEcard["son_email_"+(i-1)].focus();
		}
	}
	else{
		alert("vous devez remplir tous les champs");
		document.sendEcard.message.focus();
	}		
}

function addCard(nbContact){
	document.sendEcard.target="_self";
	document.sendEcard.action = "ecard.php?nb="+nbContact;
	document.sendEcard.submit();
}

function deleteCard(nbContact){
	document.sendEcard.target="_self";
	document.sendEcard.action = "ecard.php?nb="+nbContact+"&del=ok";
	document.sendEcard.submit();
}

function getECard(nbContact){
	document.sendEcard.target="popsome";
	document.sendEcard.action = "apercuEcard.php?nb="+nbContact;
	
	document.sendEcard.submit();
	//window.open('apercuEcard.php?id=1','1','width=600','height=1200','toolbar=no','status=no');
}

function VerifForm(adresse)
	{
	var place = adresse.indexOf("@",1);
	var point = adresse.indexOf(".",place+1);

	if ((place > -1)&&(adresse.length >2)&&(point > 1)){		
		return(true);
	}
	else{
		alert('Entrez une adresse e-mail valide!!');
		return(false);
	}
}


function openPopup(url){
	window.open("./"+url,'AfpaJeunes','width=650,height=850,scrollbars=yes');
}

function changeImgToGreen(id){
	document.getElementById(id).src="images/footer_"+id+"_on.gif";
}

function changeImgToPink(id){
	document.getElementById(id).src="images/footer_"+id+".gif";
}


function changeSwfSize(height)
{
	document.getElementById("pub").style.clip = "rect(auto,auto,"+height+",auto)";
}
/*
function changeSwfToSmall()
{
	var media="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='468' height='60'>      <param name='movie' value='60' />			<param name='wmode' value='transparent' />      <param name='quality' value='high' />      <embed src='468x60expand400_01.swf' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='468' height='60'></embed>    </object>	</div>";
	document.getElementById("expandBar").innerHTML = media;
}
*/

///// TEST EXPAND BANNER





/*function constructFormContact()
{
	//alert("construction du formulaire");
	
	//for (var i=1; i<=nbContact; i++)
	//{		
		document.getElementById('tableForm').innerHTML += '<tr id="champsNom"><td class="greenTypo">Som nom</td><td><input type="text" name="son_nom_'+ nbContact +'" value="" /></td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champsSpace"><td colspan="3">&nbsp;</td></tr>'
		document.getElementById('tableForm').innerHTML += '<tr id="champsPrenom"><td class="greenTypo">Son pr&eacute;nom</td><td><input type="text" name="son_prenom_'+ nbContact +'" value="" /></td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champs	Space"><td colspan="3">&nbsp;</td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champsMail"><td class="greenTypo">Son e-mail</td><td><input type="text" name="son_email_'+ nbContact +'" value="" /></td></tr>';				
		document.getElementById('tableForm').innerHTML += '<tr id="champsSpace"><td colspan="3">&nbsp;</td></tr>';	
	//}
}

function addContact()
{
	//alert("ADD CONTACT: ");	
	if (nbContact < maxContact)
	{
		nbContact++;
		
		document.getElementById('tableForm').innerHTML += '<tr id="champsNom"><td class="greenTypo">Som nom</td><td><input type="text" name="son_nom_'+ nbContact +'" value="" /></td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champsSpace"><td colspan="3">&nbsp;</td></tr>'
		document.getElementById('tableForm').innerHTML += '<tr id="champsPrenom"><td class="greenTypo">Son pr&eacute;nom</td><td><input type="text" name="son_prenom_'+ nbContact +'" value="" /></td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champs	Space"><td colspan="3">&nbsp;</td></tr>';	
		document.getElementById('tableForm').innerHTML += '<tr id="champsMail"><td class="greenTypo">Son e-mail</td><td><input type="text" name="son_email_'+ nbContact +'" value="" /></td></tr>';				
		document.getElementById('tableForm').innerHTML += '<tr id="champsSpace"><td colspan="3">&nbsp;</td></tr>';	

	}
	
}

function deleteContact()
{
	//alert("ADD CONTACT: ");
	if (nbContact > 0)
	{
		nbContact--;	
		constructFormContact();
	}
}	*/	