function enviar(){
	form=document.frm_news;
	if(validaForm(form)!=false){
		form.submit();	
	}else{
		return false;	
	}
}
function enviar_mail(){
	form=document.frm_contact;
	if(validaForm(form)!=false){
		form.submit();	
	}else{
		return false;	
	}
}
function valkeys(){
	if(document.getElementById("txtKeys").value.length>3){
		
	}else{
		alert("Vous devez mettre minimum 4 caractères");
		document.getElementById("txtKeys").focus();
		return false;
	}
}
function prohibir_message(url){
	if(confirm("Vous souhaitez interdire à ce membre?")){
		location.href='./include/process_message.php?cmdProhibirMessage=1&'+url;
	}
}
function color_div(name,vari){
	//alert(name);
	//alert(vari);
	if(vari==0){
		document.getElementById(name).style.color='#CCCCCC';
		document.getElementById(name).style.textDecoration = "underline";
		
	}else{
		document.getElementById(name).style.color='#FFFFFF';
		document.getElementById(name).style.textDecoration = "underline";
		
	}
}
function color_div_1(name , vari){
	//alert(name);
	//alert(vari);
	if(vari==1){
		document.getElementById(name).style.color='#CCCCCC';
		document.getElementById(name).style.textDecoration = "none";
		
	}else{
		document.getElementById(name).style.color='#FFFFFF';
		document.getElementById(name).style.textDecoration = "none";
		
	}
}
function nextPage(url){
	location.href=url;
	}
function validarSimilarEmpresas(form,normal){
	if(normal==1){
		form.action="./include/process_similar_enterprises.php?normal=1";//
	}else{
		val=document.frmSimilarEnterprise.typePayment.value;
			//	alert('holsdd');
		if(val==1){
			//form.action="./include/pago.php";//ruta de la pasarela de pago
			form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";//ruta de la pasarela de pago
		}else{
			form.action="./include/process_similar_enterprises.php";//ruta de la pasarela de pago
		}
	}
 	
		return true;
		//form.submit();
}
function armar(valor){
 	val=document.frmSimilarEnterprise.comon.value;
	document.frmSimilarEnterprise.custom.value=val+"*"+valor.value;
}
function load_vars($url){	
	//location.href='inscription.php?cbomark='+document.frm_insc.cbomark.value;
	//$Alert==0;
	document.frm_insc.action=$url
	document.frm_insc.submit();
}
//solo numeros enteros
function validar(e) { // 1
    tecla = (document.all) ? e.keyCode : e.which; // 2
    if (tecla==8) return true; // 3
    patron = /\d/; // 4
    te = String.fromCharCode(tecla); // 5
    return patron.test(te); // 6
} 

function color(){
if(document.frm_insc.cboColor.value != 'Autre')
{ document.frm_insc.txtprecisez.disabled=true;

}

if(document.frm_insc.cboColor.value == 'Autre')
{ document.frm_insc.txtprecisez.disabled=false;
  document.frm_insc.txtprecisez.focus();
}

}
function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numérico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 


var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
var long = fecha.length; 
var dia; 
var mes; 
var ano; 

if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"/"+fecha.substr(3,7); primerslap=true; } 
else { fecha=""; primerslap=false;} 
} 
else 
{ dia=fecha.substr(0,1); 
if (IsNumeric(dia)==false) 
{fecha="";} 
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=fecha.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"/"+fecha.substr(6,4); segundoslap=true; } 
else { fecha=fecha.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=fecha.substr(6,4); 
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
} 

if (long>=10) 
{ 
fecha=fecha.substr(0,10); 
dia=fecha.substr(0,2); 
mes=fecha.substr(3,2); 
ano=fecha.substr(6,4); 
// Año no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"/"; } 
} 
return (fecha); 
} 



function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
 	else 
	countfield.value = maxlimit - field.value.length;
}

function validaForm(ruta){

var propControl = new Array();
debecontar=0;
contar=0;
validar=0;
validarmail=0;
vacios=0;
	for(var i=0; i<ruta.elements.length; i++){
		controlAct=ruta.elements[i];
		if(ruta.elements[i].title.indexOf("*")!=-1){//si existe * entonces valida datos del control actual
			propControl = ruta.elements[i].title.split("*");
			//alert(propControl[1]);
			if(propControl[1].indexOf("r")!= -1){//si es diferente de -1 entonces es un control requerido
				if(controlAct.value=="" || controlAct.value=="0"){
					alert("Le champ \""+propControl[0]+"\" est obligatoire");
					controlAct.focus();
					return false;
					break;
				}
			}
			if(propControl[1].indexOf("m")!= -1){//si es diferente de -1 entonces se debe validar el email
				if(emailCheck(controlAct.value)==0){
					alert("Votre email n'est pas valide");
					controlAct.focus();
					return false;
					break;
				}
			}
			if(propControl[1].indexOf("c")!= -1){
				debecontar=1;
				contar=contar+1;
				if(controlAct.value==""){
					vacios=vacios+1;
					if(contar==1){
						kontrol=controlAct;
						nombreKontrol=propControl[0];
					}
				}				
			}			
			if(propControl[1].indexOf("f")!= -1){
				if(checkDecimals(controlAct)==0){
					alert("Le champ "+propControl[0]+" ne doit pas contenir de caractères alphanumériques");
					controlAct.focus();
					controlAct.select();
					return false;
					break;
				}else{
					num=roundOff(controlAct.value, 2);
					//alert(num);
				}				
			}
			if(propControl[1].indexOf("p1")!= -1){//hay un "campo password"
				password1=controlAct.value;
			}
			if(propControl[1].indexOf("p2")!= -1){//hay un campo "repetir password"
				password2=controlAct.value;
				validar=1;
				ctrlRep=controlAct;
			}
			if(propControl[1].indexOf("m1")!= -1){//hay un "campo email"
				email1=controlAct.value;
			}
			if(propControl[1].indexOf("m2")!= -1){//hay un campo "repetir email"
				email2=controlAct.value;
				validarmail=1;
				ctrlRep=controlAct;
			}
			if(propControl[1].indexOf("chk")!= -1){//si es diferente de -1 indica que se debe hacer check
				if(controlAct.checked==false){
					alert("Le champ \""+propControl[0]+"\" est obligatoire");
					controlAct.focus();
					return false;
					break;
				}
			}
		}
	}
	if(validarmail==1){
		if(email1!=email2){
			alert('Vous n\’avez pas retapé correctement votre email');
			ctrlRep.focus();
			ctrlRep.select();
			return false;
		}
	}
	if(validar==1){
		if(password1!=password2){
			alert('Vous n\’avez pas retapé correctement votre mot de passe');
			ctrlRep.focus();
			ctrlRep.select();
			return false;
		}
	}
	if(debecontar==1){
		if(contar==vacios){
			alert('Les champs "'+nombreKontrol+'" ne peuvent être vides ');
			kontrol.focus();
			return false;
		}
	}
}

function roundOff(value, precision){
value = "" + value //convert value to string
precision = parseInt(precision);
var whole = "" + Math.round(value * Math.pow(10, precision));
var decPoint = whole.length - precision;

	if(decPoint != 0){
		result = whole.substring(0, decPoint);
		result += ".";
		result += whole.substring(decPoint, whole.length);
	}else{
		result = whole;
	}
	return result;
}


function checkDecimals(fieldName) {
decallowed = 2;  // cuantos decimales se desea
fieldValue=fieldName.value;
	if(fieldValue.length>=1){
		if (isNaN(fieldValue) || fieldValue == "") {
			/*alert("OJO! No has introducido un numero. Vuelve a intentarlo");
			fieldName.select();
			fieldName.focus();*/
			return 0;
		}
		else {
			if (fieldValue.indexOf('.') == -1) 
				fieldValue += ".";
			dectext = fieldValue.substring(fieldValue.indexOf('.')+1, fieldValue.length);
	
			if (dectext.length > decallowed){
				/*alert ("OJO!! Introduce un numero con " + decallowed + " decimales.  Intentalo de nuevo.");
				fieldName.select();
				fieldName.focus();*/
				return 0;
	      	}else {
			//alert ("OK!! Numero correcto.");
			return 1;
	      	}
		}
	}else{
		return 1;
	}
}


function emailCheck (emailStr) {
	if(emailStr.length>=1){
		var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom=validChars + '+'
		var word="(" + atom + "|" + quotedUser + ")"
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
			return 0;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		if (user.match(userPat)==null) {
			return 0;
		}
	
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			for (var i=1;i<=4;i++) {
				if(IPArray[i]>255){
					return 0;
				}
			}
			return 1;
		}
	
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			return 0;
		}
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		   return 0;
		}
	
		if (len<2) {
		   return 0;
		}
		
	}else{
		return 1;
	}

}



function isValidDate(sText) {
	var reDate = /(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/; 
	return reDate.test(sText);
}

function popup(img, ww, hh){
  derecha=(screen.width-ww)/2;
  arriba=(screen.height-hh)/2;
  string="titlebar='no',toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+ww+",height="+hh+",left="+derecha+",top="+arriba+"";
  fin=window.open(img,this.target,string);
}	

function reload_father(){
	document.location.reload();
}

/*************************Funciones ekivo*****************************/
function checkLogin(){
	form=document.frmLogin;
	if(validaForm(form)!=false){
		login=form.txtLogin.value;
		password=form.txtPassword.value;
		cadena=login+","+password;
		jsrsExecute("./include/check_login.php",end_CheckLogin,"confirmar",cadena);
	}
}
function end_CheckLogin(ok){
	form=document.frmLogin;
	if(ok==1){//todo ok
		form.submit();	
	}else{
		alert(form.txtLogin_incorrect.value);
		form.txtLogin.select();
	}
}
function checkInscription(){
	form=document.frmInscription;
	if(validaForm(form)!=false){
		cpostal=document.getElementById("txtCpostal").value;
		if(cpostal.length <5){
			alert("Code postal incorrect!");
			document.getElementById("txtCpostal").select();
			return false;
		}else{
     		cadena=form.txtEmailCont.value+","+form.txtCpostal.value;
			jsrsExecute("./include/check_inscription.php",end_CheckInscription,"confirmar",cadena);
  		}
	}
}
function end_CheckInscription_old(cadena){
	cadena=cadena.split(",");
	existemail=cadena[0];
	premium=cadena[1];
	contactId=cadena[2];
	form=document.frmInscription;
	if(existemail==1){//ok
		form.action="include/process_user.php";
		if(premium==2){
			if(!contactId){//Si no existe sesión de usuario
				if(form.chkPremium.checked==true){ //Premium
					typepayment=type_payment();
					if(typepayment==1){ //pago con tarjeta
						form.action="http://www.pasarela.com";//ruta de la pasarela de pago
					}
				}
			}
		}
		form.submit();
	}else{
		alert("Email existe deja");
		form.txtEmailCont.select();
	}
}
function valider_payment(){
	form=document.frmPayment;
	if(validaForm(form)!=false){
		special=total_check_special();
		if(special>0){
			form.action="include/process_payment.php"
		}else{
			typepayment=type_payment();
			form.action="include/process_payment.php"
			if(typepayment==1){ //pago con tarjeta
				form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";//ruta de la pasarela de pago
			}
		}
	
		form.submit();
	}
}

function validate_payment(){
	form=document.frmPayment;
	premium=document.getElementById("cboSubscription").value;
	verifyEnt=document.getElementById("verifyEnt").value;
	
	if(premium!=0){
		if(validaForm(form)!=false){	
			form.action="include/process_payment.php"
			typepayment=type_payment();
			if(typepayment==1){ //pago con tarjeta
				document.getElementById("custom").value=document.getElementById("custom").value+"*"+premium+"*"+document.getElementById("txtDescription").value+"*"+verifyEnt;
				form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";//Pasarela de pago
			}
			form.submit();
		}
	}else{
		alert("Vous devez choisir une option");
		return false;
	}
}

function end_validate_payment(cadena){
	cadena=cadena.split("|");
	var ok=cadena[0];
	var new_ent_id=cadena[1];
	//form=document.frmPayment;
	form=document.getElementById("frmPayment");
	if(ok==1){//Si se insertó una empresa en el anuario
		document.getElementById("txtEntAnnuaire").value=new_ent_id;
		var val=document.getElementById("custom").value;
		document.getElementById("custom").value=val+"*"+new_ent_id;
		typepayment=type_payment();
		document.getElementById("frmPayment").action="include/process_payment.php";
		if(typepayment==1){ //pago con tarjeta
			form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";//ruta de la pasarela de pago
			//form.action="./include/pago.php";//ruta de la pasarela de pago
			
		}
	}else{
		form.action="include/process_payment.php";
	}	
	form.submit();
}

function valider_payment_old(){
	form=document.frmPayment;
	if(validaForm(form)!=false){
		typepayment=type_payment();
		form.action="include/process_payment.php"
		if(typepayment==1){ //pago con tarjeta
			form.action="https://www.sandbox.paypal.com/cgi-bin/webscr";//ruta de la pasarela de pago
		}
		form.submit();
	}
}
function end_CheckInscription(cadena){
	cadena=cadena.split(",");
	existemail=cadena[0];
	premium=cadena[1];
	contactId=cadena[2];
	cpostal_correct=cadena[3];
	form=document.frmInscription;
	if(existemail==1){//ok
		if(cpostal_correct==1){
			form.action="include/process_user.php";
			form.submit();
		}else{
			alert("Code postal incorrect!");
			form.txtCpostal.select();
		}
	}else{
		alert("Email existe dejà");
		form.txtEmailCont.select();
	}
}
//Función que retorna el tipo de pago seleccionado por el usuario
function type_payment(){
	total=document.getElementById("totalTypepayment").value;
	for(i=0;i<total;i++){
		if(document.getElementById("optTypepayment"+i).checked==true){
			typepayment=document.getElementById("optTypepayment"+i).value;
			break;
		}
	}
	return typepayment;
}
function check_recovery_password(){
	form=document.frmRecovery;
	if(validaForm(form)!=false){
		cadena=form.txtEmail.value;
		jsrsExecute("./include/check_password_recovery.php",end_check_recovery_password,"confirmar",cadena);
	}
}
function end_check_recovery_password(cadena){
	form=document.frmRecovery;
	if(cadena==1){//ok
		form.submit();
	}else{
		alert("Email incorrect!");	
	}
}
function closePopUp(){
	setTimeout("window.close();",5000);
}
function changeState_announce(url,est){
	if(est==1){
		aviso="Vous souhaitez ne pas publier cette annonce ?";
	}else{
		aviso="Vous souhaitez publier cette annonce ?";
	}
	if(confirm(aviso)){
		location.href='./include/process_announce.php?cmdShowAnnounce=1&show_announceSt='+est+'&'+url;
	}
}
function delete_announce(url){
	if(confirm("Etes-vous sûr de vouloir supprimer cet enregistrement?")){
		location.href='./include/process_announce.php?cmdDeleteAnnounce=1&'+url;
	}
}
/***mostrar div de anuncio premium****/
function show_div_announce_premium(){
	if(document.getElementById("chkPremium").checked==true){
		document.getElementById("chkPremium").value=1;
		document.getElementById("divPremium").style.display='';
	}else{
		document.getElementById("chkPremium").value=0;
		document.getElementById("divPremium").style.display='none';
	}
}
/***mostrar div de anuncio premium****/
function show_div_type_payment(){
	if(document.getElementById("chkPremium").checked==true){
		document.getElementById("chkPremium").value=1;
		document.getElementById("divType_payment").style.display='';
	}else{
		document.getElementById("chkPremium").value=0;
		document.getElementById("divType_payment").style.display='none';
	}
}
function check_type_announce(control){
	if(control==1){// texto
		document.getElementById("txtText").disabled=false;
		document.getElementById("fileLogo").disabled=true;
	}else{ //logo
		document.getElementById("txtText").disabled=true;
		document.getElementById("fileLogo").disabled=false;
	}	
}
/**** Transferir actividades, funciones y regiones de lista a lista *************/
//Tipo :
// 1.-Disponibles a temporal ó Disponibles a tabla real
// 2.-Temporal a disponible ó tabla real a disponibles
function transfer_list(tipo,lst,announceId,route){
	if(lst=="activities"){
		lista=(tipo==1?"lstActivityDisp":"lstActivitySel");
	}else if(lst=="fonctions"){
		lista=(tipo==1?"lstFunctionDisp":"lstFunctionSel");
	}else if(lst=="regions"){
		lista=(tipo==1?"lstRegionDisp":"lstRegionSel");
	}
	total=document.getElementById(lista).length;
	j=0;
	cadena="";
	for(i=0;i<total;i++){
		if(document.getElementById(lista).options[i].selected==true){
			sep=(j==0?"":",");
			//alert(sep);
			cadena+=sep+document.getElementById(lista).options[i].value;
			j++;
		}
	}
	if(j!=0){
		var tipo=(tipo==1?"1":"2");
		if(route==1){//web
			jsrsExecute("./include/transfer_list.php",end_transfer_list,"confirmar",Array(cadena,tipo,lst,announceId));
		}else{//admin
			jsrsExecute("../../include/transfer_list.php",end_transfer_list,"confirmar",Array(cadena,tipo,lst,announceId));
		}
	}
}
function end_transfer_list(result){
	form=document.frmAnnounce;
	cadena=result.split("|");
	list=cadena[0];
	act_temp_id=cadena[1].split(",");
	act_temp_name=cadena[2].split(",");
	act_disp_id=cadena[3].split(",");
	act_disp_name=cadena[4].split(",");
	
	if(list=="activities"){
		listaDisp="lstActivityDisp";
		listaSel="lstActivitySel";
	}else if(list=="fonctions"){
		listaDisp="lstFunctionDisp";
		listaSel="lstFunctionSel";
	}else if(list=="regions"){
		listaDisp="lstRegionDisp";
		listaSel="lstRegionSel";
	}
	//LLeno la lista de actividades seleccionadas
	total_act_temp=act_temp_id.length;
	total_eliminar1=document.getElementById(listaSel).length;
	for(i=0;i<total_eliminar1;i++){
		document.getElementById(listaSel).options[0]=null;
	}
	for(i=0;i<total_act_temp;i++){
		otraopcion=new Option(act_temp_name[i],act_temp_id[i]);
		document.getElementById(listaSel).options[i]=otraopcion;
	}
	//LLeno la lista de actividades disponibles
	total_act_disp=act_disp_id.length;
	total_eliminar=document.getElementById(listaDisp).length;
	for(i=0;i<total_eliminar;i++){
		document.getElementById(listaDisp).options[0]=null;
	}
	for(i=0;i<total_act_disp;i++){
		otraopcion=new Option(act_disp_name[i],act_disp_id[i]);
		document.getElementById(listaDisp).options[i]=otraopcion;
	}
}
//Función que limpia una lista
function clean_list(list_name){
	total=document.getElementById(list_name).length;
	for(i=0;i<total;i++){
		document.getElementById(list_name).options[0]=null;
	}
}
//Cargar lista de miembros según filtro
function charger_membres(){
	activity=document.getElementById("cboActivity").options[document.getElementById("cboActivity").selectedIndex].value;
	fonction=document.getElementById("cboFunction").options[document.getElementById("cboFunction").selectedIndex].value;
	region=document.getElementById("cboRegion").options[document.getElementById("cboRegion").selectedIndex].value;
	if((activity==0)&&(fonction==0)&&(region==0)){
		clean_list("lstMembresDisp");
	}else{
		cadena=activity+","+fonction+","+region;
		jsrsExecute("./include/charger_membres.php",end_charger_membres,"confirmar",cadena);
	}
}
function end_charger_membres(cadena){
	//document.getElementById("txtText").value=cadena;
	//Limpio la lista actual
	clean_list("lstMembresDisp");
	//lleno la lista
	membres=cadena.split("|");
	membre_id=membres[0].split(",");
	membre_name=membres[1].split(",");
	total_membres=membre_id.length;
	for(i=0;i<total_membres;i++){
		option=new Option(membre_name[i],membre_id[i]);
		document.getElementById("lstMembresDisp").options[i]=option;
	}
}
/*activity=document.getElementById("cboActivity").options[document.getElementById("cboActivity").selectedIndex].value;
	fonction=document.getElementById("cboFunction").options[document.getElementById("cboFunction").selectedIndex].value;
	region=document.getElementById("cboRegion").options[document.getElementById("cboRegion").selectedIndex].value;*/

/**** Transferir miembros de lista a lista *************/
// Tipo :
// 1.-Disponibles a temporal
// 2.-Temporal a disponible
// input_output_all :
// 1.-Ingresar todo
// 2.-Quitar todo
function transfer_membres(input_output_all,tipo){
	//activity=document.getElementById("cboActivity").value;
	name=document.getElementById("txtContact").value;
	fonction=document.getElementById("txtFonction").value;
	//region=document.getElementById("cboRegion").value;
	cadena=name+","+fonction;
	contacts="";
	if((input_output_all==1)||(input_output_all==2)){
		if((name!=0)||(fonction!=0)){
			tipo="";
			var input_output_all=(input_output_all==1?"1":"2");
			jsrsExecute("./include/transfer_membres.php",end_transfer_membres,"confirmar",Array(cadena,contacts,input_output_all,tipo));	
		}
	}else{
		alert('entro aca');
		lista=(tipo==1?"lstMembresDisp":"lstMembresSel");
		alert(lista);
		total=document.getElementById(lista).length;
		alert(total);
		j=0;
		for(i=0;i<total;i++){
			if(document.getElementById(lista).options[i].selected==true){
				sep=(j==0?"":",");
				contacts+=sep+document.getElementById(lista).options[i].value;
				j++;
			}
		}
		var tipo=(tipo==1?"1":"2");
		input_output_all="";
		if(j!=0){
			jsrsExecute("./include/transfer_membres.php",end_transfer_membres,"confirmar",Array(cadena,contacts,input_output_all,tipo));
		}
	}
}
function end_transfer_membres(result){
	cadena=result.split("|");
	membres_temp_id=cadena[0].split(",");
	membres_temp_name=cadena[1].split(",");
	membres_disp_id=cadena[2].split(",");
	membres_disp_name=cadena[3].split(",");

	//LLeno la lista de miembros seleccionadas
	clean_list("lstMembresSel");
	total_membres_temp=membres_temp_id.length;
	for(i=0;i<total_membres_temp;i++){
		otraopcion=new Option(membres_temp_name[i],membres_temp_id[i]);
		document.getElementById("lstMembresSel").options[i]=otraopcion;
	}
	//LLeno la lista de miembros disponibles
	clean_list("lstMembresDisp");
	total_membres_disp=membres_disp_id.length;
	for(i=0;i<total_membres_disp;i++){
		otraopcion=new Option(membres_disp_name[i],membres_disp_id[i]);
		document.getElementById("lstMembresDisp").options[i]=otraopcion;
	}
}

function validate_extension(ext,name_control,message){
	cadena=document.getElementById(name_control).value;
	ext_file=cadena.split(".");
	
	for(i=0;i<2;i++){
		if(form.optPremium.checked==true){
			//form	
		}	
	}
}
function delete_categorie(url){
	if(confirm("Etes-vous sûr de vouloir supprimer cet enregistrement?")){
		location.href='./include/process_categorie.php?cmdDeleteCategorie=1&'+url;
	}
}
function changeState_categorie(url,est){
	if(est==1){
		aviso="Vous souhaitez désactiver cette catégorie ?";
	}else{
		aviso="Vous souhaitez activer cette catégorie ?";
	}
	if(confirm(aviso)){
		location.href='./include/process_categorie.php?cmdShowCategorie=1&levelSt='+est+'&'+url;	
	}
}
function delete_club(url){
	if(confirm("Etes-vous sûr de vouloir supprimer cet enregistrement?")){
		location.href='./include/process_club.php?cmdDeleteClub=1&'+url;
	}
}
function delete_message(url){
	if(confirm("Etes-vous sûr de vouloir supprimer cet message?")){
		location.href='./include/process_message.php?cmdDeleteMessage=1&'+url;
	}
}
function changeState_message(url,est){
	if(est==1){
		aviso="Vous souhaitez désactiver cette message ?";
	}else{
		aviso="Vous souhaitez activer cette message ?";
	}
	if(confirm(aviso)){
		location.href='./include/process_message.php?cmdShowMessage=1&showSt='+est+'&'+url;	
	}
}
function accept_invitation(url){
	aviso="Vous souhaitez accepter cette invitation ?";
	if(confirm(aviso)){
		location.href='./include/process_inviter_membre.php?cmdAcceptInvitation=1&'+url;
	}
}
function delete_invitation(url){
	if(confirm("Etes-vous sûr de vouloir supprimer cette invitation?")){
		location.href='./include/process_inviter_membre.php?cmdDeleteInvitation=1&'+url;
	}
}
//Validar código postal
function validate_cpostal(){
	cpostal=document.getElementById("txtCpostal").value;
	if(cpostal.length <5){
		alert("Code postal incorrect!");
		document.getElementById("txtCpostal").select();
		return false;
	}else{
     	jsrsExecute("./include/validate_cpostal.php",end_validate_cpostal,"confirmar",cpostal);
  	}
}
function end_validate_cpostal(ok){
	form=document.frmInscription;
	cpostal=document.getElementById("txtCpostal").value;
	if(ok==1){
		form.action="include/process_user.php";
		form.submit();
	}else{
		alert("Code postal incorrect!");
		document.getElementById("txtCpostal").select();
		return false;
	}
}
function validate_inscription_cpostal(){
	form=document.frmInscription;
	if(validaForm(form)!=false){
		validate_cpostal();
	}
}

function validate_enterprise_cpostal(){
	form=document.frmDetail;
	if(validaForm(form)!=false){
		validate_cpostal_ent();
	}	
}

function validate_enterprise_cpostal_crm(){
	form=document.frmDetail;
	if(validaForm(form)!=false){
		validate_cpostal_ent_crm();
	}	
}

function validate_mail(){
	form=document.formcontact;
	if(validaForm(form)!=false){
		validate_mail_contact();
	}
}

function validate_mail_contact(){
	if(document.formcontact.txtEmail.value!=""){
			if(validarEmail(document.formcontact.txtEmail.value)){
			//return true;
			}else{
				alert("Le champ Email incorrect!");
				document.formcontact.txtEmail.focus();
				return false;
			}
			
//////////////////////////////////////////////////////	
////////////////////////////////////////////////////////////////////////////
			
	}
			document.formcontact.submit();
}
	
function validate_mail_contact_files(){
	//alert(document.frmContact.txt_email.value);
	//alert(document.getElementById('txt_email').value);
	if(document.getElementById("cboCivilite").value==0){
		alert("Le champ Civilite est obligatoire");
		document.getElementById("cboCivilite").focus();
		return false;
	}
	if(document.getElementById('txt_email').value!=""){
		//alert(document.getElementById('txt_email').value);
		if(validarEmail(document.getElementById('txt_email').value)){
			//return true;
		}else{
			alert("Le champ Email incorrect!");
			document.getElementById('txt_email').focus();
			return false;
		}
	}
	//alert("hola");
	document.frmContact.submit();
}
function validate_cpostal_ent(){
	cpostal=document.getElementById("txtcode").value;
	if(cpostal.length <5){
		alert("Code postal incorrect!");
		document.getElementById("txtcode").select();
		return false;
	}else{
     	jsrsExecute("./include/validate_cpostal.php",end_validate_cpostal_ent,"confirmar",cpostal);
  	}
}
function end_validate_cpostal_ent(ok){
	form=document.frmDetail;
	cpostal=document.getElementById("txtcode").value;
	if(ok==1){
		//document.frmDetail.action="include/process_entreprisescontact.php";
		document.frmDetail.submit();
	}else{
		alert("Code postal incorrect!");
		document.getElementById("txtcode").select();
		return false;
	}
}
//Funciones 
function show_price_subscription(){
	subscriptionId=document.getElementById("cboSubscription").value;
	verifyEnt=document.getElementById("verifyEnt").value;
	//alert(verifyEnt);
	if(subscriptionId!=0 && verifyEnt==0){
		document.getElementById("txtDescription").title=" Description de la entreprise *r";
	}else{
		document.getElementById("txtDescription").title="";
	}
	specialId=0;
	for(i=0;i<document.frmPayment.elements.length;i++){
		if(document.frmPayment.elements[i].type == "checkbox"){
			if(document.frmPayment.elements[i].checked == 1){
				specialId=document.frmPayment.elements[i].value;
			}
		}
	}
	cadena=subscriptionId+","+specialId+","+verifyEnt;
	jsrsExecute("./include/show_price_subscription.php",end_show_price_subscription,"confirmar",cadena);
}
function end_show_price_subscription(cadena){
	form=document.frmPayment;
	cadena=cadena.split("|");
	var total_ht=cadena[0];
	var total_ttc=cadena[1];
	show_div_normal=cadena[2];
	show_div_special=cadena[3];
	var name_subs_normal=cadena[4];
	var name_subs_special=cadena[5];
	
	if(document.getElementById("divPayment").style.display=='none'){
		document.getElementById("divPayment").style.display='';
	}
	var show_normal=(show_div_normal==1?"":"none");
	//alert(show_normal);
	// divSubsNormal tiene q ser none si la empresa es premium y visible si no lo es
	document.getElementById("divSubsNormal").style.display=show_normal;
	//////
	document.getElementById("subs_normal").innerHTML=name_subs_normal;
	
	var show_special=(show_div_special==1?"":"none");
	document.getElementById("divSubsSpecial").style.display=show_special;
	document.getElementById("subs_special").innerHTML=name_subs_special;

	document.getElementById("total_ht").innerHTML=total_ht+" €";
	document.getElementById("total_ttc").innerHTML=total_ttc+" €";
	//paypal
	document.frmPayment.amount.value=total_ttc;

}
function show_div_field_special(control){
	if(control.checked==true){
		document.getElementById("divSpecial").style.display='';
		document.getElementById("txtDescription").title=" Présentation de l'entreprise  *r";
		document.getElementById("special").value=1;
	}else{
		document.getElementById("divSpecial").style.display='none';
		document.getElementById("txtDescription").title="";
		document.getElementById("special").value=0;
	}
	
}

function unmark_all(form){
	for(i=0;document.getElementById(form).elements.length;i++){
		if(document.getElementById(form).elements[i].type=="checkbox"){
			document.getElementById(form).elements[i].checked=0;
		}
	}
}
function activate_cbo_subscription(control){
	if(control.checked==true){
		document.getElementById("cboSubscription").title="Abonnement *r";
		document.getElementById("cboSubscription").disabled=false;
	}else{
		document.getElementById("cboSubscription").title="";
		document.getElementById("cboSubscription").selectedIndex=0;
		document.getElementById("cboSubscription").disabled=true;
		subscriptionId=0;
		specialId=0;
		
		for(i=0;i<document.frmPayment.elements.length;i++){
			if(document.frmPayment.elements[i].type == "checkbox"){
				if(document.frmPayment.elements[i].checked == 1){
					specialId=document.frmPayment.elements[i].value;
				}
			}
		}
		cadena=subscriptionId+","+specialId;
		jsrsExecute("./include/show_price_subscription.php",end_show_price_subscription,"confirmar",cadena);
		
	}
}
//Función que indica si se marcó alguna suscripción especial
function total_check_special(){
	total_check=0;
	total_special=document.getElementById("totalSpecial").value;
	for(i=1;i<=total_special;i++){
		if(document.getElementById("chkSpecial"+i).checked == 1){
			total_check++;
		}
	}
	return total_check;
}
//funcion q permite validar q l 2caracter sea letra
function validate_code_alphanumeric(e,comodin){
	tecla = (document.all) ? e.keyCode : e.which;
	if(comodin==1){
		//ajouter_enterprise.php
		cpostal="txtCodpost";
	}else if(comodin==2){
		cpostal="txtCpostal";
	}else if(comodin==3){
		cpostal="txtcode";
	}
		
	if(document.getElementById(cpostal).value.length==0){
	if ((tecla>=48 && tecla<=57) || (tecla==8)) return true;
	alfa = /[A-Z]\D/; 
	text = String.fromCharCode(tecla);	
	return alfa.test(text);
	}else if(document.getElementById(cpostal).value.length==1){
			
			if ((tecla>=65 && tecla<=122) || (tecla>=48 && tecla<=57)) return true;
			alfa = /[A-Z]\D/; 
			text = String.fromCharCode(tecla);	
			return alfa.test(text);
			
	}else if(document.getElementById(cpostal).value.length==2){
			if (tecla>=48 && tecla<=57) return true;
				alfa = /[A-Z]\D/; 
				text = String.fromCharCode(tecla);	
				return alfa.test(text);
	}else if(document.getElementById(cpostal).value.length==3){
			if (tecla>=48 && tecla<=57) return true;
				alfa = /[A-Z]\D/; 
				text = String.fromCharCode(tecla);	
				return alfa.test(text);
	}else if(document.getElementById(cpostal).value.length==4){
			if (tecla>=48 && tecla<=57) return true;
				alfa = /[A-Z]\D/; 
				text = String.fromCharCode(tecla);	
				return alfa.test(text);
	}
	
}

function activate_button_valider(){
	document.getElementById("cmdValider").disabled=false;
}

///////////////////////////////////////////////////////////////////////
function validate_code_numeric(e,valor){
	tecla = (document.all) ? e.keyCode : e.which;
	if(valor==1){
		cpostal="txtPhoneEnt";
	}else{
		cpostal="txtFaxEnt";	
	}
	
	if(document.getElementById(cpostal).value.length>=0){
	if ((tecla>=48 && tecla<=57) || (tecla==8)) return true;
	alfa = /[A-Z]\D/; 
	text = String.fromCharCode(tecla);	
	return alfa.test(text);
	}
}