/*
function affiche_licence()
{
	window.open('public/license.txt','popup','height=310,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=yes')
}	
*/

function affiche_protection_donnee()
{
	window.open('http://fr.mycvtheque.com/public/protection_donnee.html','popup','height=250,toolbar=no,location=no,directories=no,status=yes,width=500,resizable=no,scrollbars=yes')
}	

function affiche_identite_entreprise()
{
	window.open('public/identite_entreprise.html','popup','height=400,toolbar=no,location=no,directories=no,status=yes,width=500,resizable=no,scrollbars=yes')
}

function affiche_demo()
{
	window.open('http://demo.mycvtheque.com','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=no,scrollbars=yes')
}

function affiche_condition(langue)
{
	window.open('public/condition.php?langue='+langue+'','popup','height=310,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=yes')
}

function affiche_licence()
{
	window.open('public/licence_utilisation.txt','popup','height=310,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=yes')
}

function affiche_licence_start()
{
	window.open('public/licence_utilisation_start.txt','popup','height=310,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=yes')
}

function affiche_bon_commande()
{
	window.open('public/bon_de_commande.pdf','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=yes,scrollbars=yes')
}

function affiche_detail_produit(pack)
{
	window.open('public/description_produit_pack_'+pack+'.pdf','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=yes,scrollbars=yes')
}

function affiche_plaquette_produit(doc)
{
	window.open('public/'+doc+'','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=yes,scrollbars=yes')
}

function affiche_bon_commande_start()
{
	window.open('public/bon_de_commande_start.pdf','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=yes,scrollbars=yes')
}

function affiche_bon_commande_asp()
{
	window.open('public/bon_de_commande_asp.pdf','popup','height=600,toolbar=no,location=no,directories=no,status=yes,width=800,resizable=yes,scrollbars=yes')
}


function affiche_ecran(ecran,num,type_ecran)
{
	window.open('public/affiche_ecran.php?ecran='+ecran+'&num='+num+'&type_ecran='+type_ecran,'popup1','height=550,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=no')
}	

function affiche_ecran2(ecran,num,type_ecran)
{
	if(num==""){
		num=1;
	}
	//window.location.href('../public/affiche_ecran.php?ecran='+ecran+'&num='+num+'&type_ecran='+type_ecran,'popup1','height=470,toolbar=no,location=no,directories=no,status=yes,width=600,resizable=no,scrollbars=no')
	window.location.href('../public/affiche_ecran.php?ecran='+ecran+'&num='+num+'&type_ecran='+type_ecran)
}	


function update_prix(langue,id_cvtheque)
{
	var quantite = document.forms['EWP_275721'].elements['article[1][quantite]'].value;
	window.location.href="index.php?langue="+langue+"&page=acheter&quantite_produit="+quantite+"&id_cvtheque="+id_cvtheque;
}

function download(langue, nom_download, id_download, numero_version_cvtheque,type_download)
{
	window.location.href="prive/enregistrementDownload.php?langue="+langue+"&NOM_DOWNLOAD="+nom_download+"&id_download="+id_download+"&NUMERO_VERSION_CVTHEQUE="+numero_version_cvtheque+"&type_download="+type_download;
}


function verifCondition(pack)
{
	if(pack == "MYCV-PRO"){
		var condition 			= document.forms['EWP_275721'].lu_condition_client.checked;
	}
	var email_debiteur		= document.forms['EWP_275721'].email_debiteur.value;
	var tel_debiteur 		= document.forms['EWP_275721'].tel_debiteur.value;
	var name_debiteur 		= document.forms['EWP_275721'].name_debiteur.value;
	var adress_debiteur 	= document.forms['EWP_275721'].adress_debiteur.value;
	var result = true;
	if(pack == "MYCV-PRO" || pack == "MYCV-STA"){
		var licence 			= document.forms['EWP_275721'].lu_licence.checked;
	}
	
	if (verifEmail(email_debiteur))
	{
		result =  true;
	}
	else
	{
		result =  false;
	}	
	if(pack == "MYCV-PRO" || pack == "MYCV-STA"){
		if(licence==false){
			alert("Merci de prendre connaissance de la licence d'utilisation \n---\nThank you to take note of the licence of use");
			result =  false;
		}		
	}
	
	if(pack == "MYCV-PRO"){
		if(condition==false){
			alert("Merci de prendre connaissance des conditions de prestations \n---\nThank you to take note of the conditions of services");
			result =  false;
		}
	}
	if(tel_debiteur=="" ){
		alert("Champ obligatoire non rempli : Téléphone \n---\nObligatory field not filled :  Phone number");
		result =  false;
	}		
	if(name_debiteur=="" ){
		alert("Champ obligatoire non rempli : Prénom Nom \n---\nObligatory field not filled :  First name, Last name");
		result =  false;
	}
	if(adress_debiteur=="" ){
		alert("Champ obligatoire non rempli : Adresse \n---\nObligatory field not filled :  address");
		result =  false;
	}
	
	return result;
}

function verifMail(){
	var type_demande;
	var sujet_demande 	= document.frm_envoi_mail.sujet_demande.value;
	var desc_demande 	= document.frm_envoi_mail.desc_demande.value;
	var result = true;
	
	for(var i=0; i<document.frm_envoi_mail.type_demande.length; i++)
	{
		if(document.frm_envoi_mail.type_demande.options[i].selected){
			type_demande = document.frm_envoi_mail.type_demande.options[i].value;
			break;
		}
	}	
	
	if(type_demande=="---" ){
		alert("Choisissez le type demande \n---\nChoose the type asks");
		result =  false;
	}
	if(sujet_demande=="" ){
		alert("Saisissez un sujet \n---\nSeize a subject");
		result =  false;
	}
	if(desc_demande=="" ){
		alert("Saisissez une description \n---\nSeize a description");
		result =  false;
	}	

	return result;
}

function verifMailPublic(){
	var type_demande;
	var sujet_demande 	= document.frm_envoi_mail.sujet_demande.value;
	var desc_demande 	= document.frm_envoi_mail.desc_demande.value;
	var email_public 	= document.frm_envoi_mail.email_public.value;
	var nom 	= document.frm_envoi_mail.nom.value;
	var prenom 	= document.frm_envoi_mail.prenom.value;
	var telephone 	= document.frm_envoi_mail.telephone.value;
	var result = true;
	
	
	for(var i=0; i<document.frm_envoi_mail.type_demande.length; i++)
	{
		if(document.frm_envoi_mail.type_demande.options[i].selected){
			type_demande = document.frm_envoi_mail.type_demande.options[i].value;
			break;
		}
	}	
	if (verifEmail(email_public))
	{
		result =  true;
	}
	else
	{
		result =  false;
	}	
	if(type_demande=="---" ){
		alert("Choisissez le type demande \n---\nChoose the type asks");
		result =  false;
	}
	if(sujet_demande=="" ){
		alert("Saisissez un sujet \n---\nSeize a subject");
		result =  false;
	}
	if(desc_demande=="" ){
		alert("Saisissez une description \n---\nSeize a description");
		result =  false;
	}	
	if(nom=="" ){
		alert("Saisissez un nom \n---\nSeize a lastname");
		result =  false;
	}		
	if(prenom=="" ){
		alert("Saisissez un prénom \n---\nSeize a firstname");
		result =  false;
	}		
	if(telephone=="" ){
		alert("Saisissez un téléphone \n---\nSeize a phone number");
		result =  false;
	}			

	return result;
}

function verifCompteClient(){
	var email_client 		= document.frm_enreg_compt.email_client.value;
	var telephone_client 	= document.frm_enreg_compt.telephone_client.value;
	var adresse_client 		= document.frm_enreg_compt.adresse_client.value;
	var passe_client 		= document.frm_enreg_compt.passe_client.value;
	var conf_passe_client 	= document.frm_enreg_compt.conf_passe_client.value;
	var result				= true;
	
	if (verifEmail(email_client))
	{
		result =  true;
	}
	else
	{
		result =  false;
	}
	if(telephone_client==""){
		alert("Saisissez un téléphone \n---\nSeize a phone number");
		result =  false;
	}
	if(adresse_client==""){
		alert("Saisissez une adresse \n---\nSeize an address");
		result =  false;
	}
	if(conf_passe_client != passe_client){
		alert("La confirmation de votre mot de passe est différente \n---\nThe confirmation of your password is different");
		result =  false;
	}		
	return result;	
}

function verifEmail(a) 
{
	testm = false ;
	for (var j=1 ; j<(a.length) ; j++) 
	{
		if (a.charAt(j)=='@') 
		{ 
			if (j<(a.length-4))
			{ 
				for (var k=j ; k<(a.length-2) ; k++) 
				{ 
					if (a.charAt(k)=='.') testm = true; 
				} 
			} 
		} 
	} 
	
	if (testm==false) alert('Votre adresse e-mail est incorrecte. \n---\nYour address e-mail is incorrect'); 
	
	return testm ; 
}
function verifieMail() {
	var email = document.form.email.value;
	var aroba = email.indexOf("@");
	if (aroba == -1) {
	alert("Adresse e-mail non valide !");
	return false;
	}
	var point = email.indexOf(".", aroba);
	if ((point == -1) || (point == (aroba + 1))) {
	alert("Adresse e-mail non valide !");
	return false;
	}
	var point = email.lastIndexOf(".");
	if ((point + 1) == email.length) {
	alert("Adresse e-mail non valide !");
	return false;
	}
	var point = email.indexOf("..")
	if (point != -1) {
	alert("Adresse e-mail non valide !");
	return false;
	}
	//alert("Adresse e-mail valide !");
	return true;
}

function verif_checkbox(){
	var charte=document.service.charte.checked;
	var module=document.service.module.checked;
	var autre=document.service.autre.checked;
	var site=document.service.site.checked;

	if(charte==true||module==true||autre==true||site==true )
	{
		return true;
	}else{
		alert("Choisissez au moins un formulaire...\n---\nChoose at least a form");
		return false;		
	}
}

function verif_formulaire(){
var nom=document.formulaire.nom.value;
var prenom=document.formulaire.prenom.value;
var email=document.formulaire.email.value;
var adresse=document.formulaire.adresse.value;
var zipcode=document.formulaire.zipcode.value;
var ville=document.formulaire.ville.value;
var pays=document.formulaire.pays.value;

var chainealert="vous n'avez pas rempli le champ obligatoire :\n---\nYou did not fill the obligatory field :";
var test=0;

		if(nom==""||prenom==""||adresse==""||zipcode=="" ||ville==""||pays=="")
		{
			alert("vous n'avez pas rempli tous les champs obligatoires\n---\nYou did not fill all the obligatory fields");
			return false;
		}
		else 
		{
			if (verifMail(email))
			{
				return true;
			}
			else
			{
				return false;
			}
		}

}