function get_Bandes_Annonces_video_unite(){	
	location.href='videos_unite.php?videoId='+document.form.partenaire.value+'&link06=on&linktit01=on&end&asesino=1';
}
function get_Bandes_Annonces_video(){	
	location.href='tousvideos.php?videoId='+document.form.partenaire.value+'&link05=on&linktit01=on&end&asesino=1';
}
function get_Bandes_Annonces(){	
	location.href='index.php?videoId='+document.form.partenaire.value+'&link02=on&linktit01=on&end&asesino=1';
}
function ver_lugares2(){
		//Nota esta funcion esta funcionando en dos partes del Admin 
		cadena=document.getElementById("subscription").value;
		jsrsExecute("../../include/remoting_lugares.php",end_ver_lugares2,"confirmar",cadena);
}
function end_ver_lugares2(result){
	cadena=result.split("*");
	document.getElementById("places").value=cadena[0];
	document.getElementById("per").value=cadena[1];
	document.getElementById("abo").value=cadena[2];
	document.getElementById("per").readOnly=true;
	document.getElementById("abo").readOnly=true;
	if (document.getElementById("subscription").value==4){
		document.getElementById("per").readOnly=false;
		document.getElementById("abo").readOnly=false;
	}
}
function ver_lugares(){
		//Nota esta funcion esta funcionando en dos partes del Admin 
		cadena=document.getElementById("subscription").value;
		jsrsExecute("../../include/remoting_lugares.php",end_ver_lugares,"confirmar",cadena);
}	
String.prototype.trim = function() {
    return this.replace(/^\s*|\s*$/g,"");
}
function end_ver_lugares(result){
	//extraer datros enviados del remoting
	cadena=result.split("*");
	document.getElementById("capa5").style.display = "block";
	document.getElementById("capa6").style.display = "block";
	document.getElementById("txtper").style.display = "block";
	document.getElementById("valper").style.display = "block";
	
	document.getElementById("num_ofe").value=cadena[0];
	document.getElementById("places").value=cadena[2];
	
	document.getElementById("per").value=cadena[1];	
	document.getElementById("dureeAbono").value=cadena[1];
	
	document.getElementById("per").disabled=true;
	document.getElementById("places").readOnly=true;
	if (document.getElementById("subscription").value==4){
		document.getElementById("per").disabled=false;
		document.getElementById("places").readOnly=false;
	}
	/*if (result.trim()=="**"){
	document.getElementById("capa5").style.display = "none";
	document.getElementById("capa6").style.display = "none";
	document.getElementById("txtper").style.display = "none";
	document.getElementById("valper").style.display = "none";
	}	*/

}

function litar_user(){
		//Nota esta funcion esta funcionando en dos partes del Admin 
		cadena=document.getElementById("partnerId").value;
		jsrsExecute("../../include/remoting_partner.php",end_listar_user2,"confirmar",cadena);
}
function end_listar_user2(result){
	cadena=result.split("|");
	document.getElementById("capa1").innerHTML=cadena[0]; 
	document.getElementById("capa2").innerHTML=cadena[1]; 
	document.getElementById("capa3").innerHTML=cadena[2]; 
	document.getElementById("capa4").innerHTML=cadena[3]; 
	document.getElementById("capa").style.display = "block";
	if (cadena[0]=='' && cadena[1]==''){
		document.getElementById("capa").style.display = "none";
	}
	//document.getElementById("capa4").innerHTML=cadena[4]; 
	//alert(cadena[1]);
	
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function Permut (flag,img) {
   if (document.images) {
        if (document.images[img].permloaded) {
            if (flag==1) document.images[img].src = document.images[img].perm.src
            else document.images[img].src = document.images[img].perm.oldsrc
        }
   }
}
function preloadPermut (img,adresse) {
   if (document.images) {
        img.onload = null;
        img.perm = new Image ();
        img.perm.oldsrc = img.src;
        img.perm.src = adresse;
        img.permloaded = true;
   }
}


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();
}

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;
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("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(validar==1){
		var exp = new RegExp("^[a-zA-Z0-9]{4,12}$","g");
		if(!exp.test(password1)){
			alert('Nous vous rappelons que seul les caractères alphanumériques non accentués sont autorisés : minimum 4 et maximun 12');			ctrlRep.focus();
			ctrlRep.select();
			return false;
		}
		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 total_options(form){
	total=0;
	for(i=0;i<document.getElementById(form).elements.length;i++){
		if(document.getElementById(form).elements[i].type=="radio"){
			total++;
		}
	}
	return total;
}
function checkAbonnement(origen){
	//total=document.frmAbonnement.totAbonnement.value;
	total=total_options("frmAbonnement");
	totCheck=0;
	for(i=0;i<total;i++){
		if(document.getElementById("optAbonnement"+i).checked==false){
			totCheck++;
		}else{
			abonneId=document.getElementById("optAbonnement"+i).value;	
		}
	}
	if(total==totCheck){
		alert("Merci de bien vouloir choisir un abonnement");
		return false;
	}else{
		if(origen==1){
			if(document.frmAbonnement.txtCodepartner.value!=""){
				//cadena=document.frmAbonnement.txtCodepartner.value+","+abonneId;
				cadena=document.frmAbonnement.txtCodepartner.value;
				jsrsExecute("./include/check_abonnement.php",end_checkAbonnement,"confirmar",cadena);
			}else{
				document.frmAbonnement.submit();
			}
		}else{
			document.frmAbonnement.submit();
		}
	}
}
function end_checkAbonnement(cadena){
	if(cadena=="no"){
		alert("Code partenaire incorrect!!!")
		document.frmAbonnement.txtCodepartner.select();
		return false;
	}else if(cadena=="ok"){
		document.frmAbonnement.submit();
	}/*else{
		alert(cadena);	
	}*/
}
function checkAdmin(){
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Nom\" est obligatoire");
		document.getElementById("txtName").focus();
		return false;
	}
	if(document.getElementById("txtEmail").value==""){
		alert("Le champ \"Email\" est obligatoire");
		document.getElementById("txtEmail").focus();
		return false;
	}
	if(emailCheck(document.getElementById("txtEmail").value)==0){
		alert("Votre email n'est pas valide");
		document.getElementById("txtEmail").focus();
		return false;
	}
	if(document.getElementById("txtLogin").value==""){
		alert("Le champ \"Identification\" est obligatoire");
		document.getElementById("txtLogin").focus();
		return false;
	}
	if(document.getElementById("txtPassword").value==""){
		alert("Le champ \"Mot de passe\" est obligatoire");
		document.getElementById("txtPassword").focus();
		return false;
	}
	email=document.getElementById("txtEmail").value;
	login=document.getElementById("txtLogin").value;
	adminId=document.getElementById("adminId").value;
	cadena=email+","+login+","+adminId;
	jsrsExecute("./check_admin.php",end_checkAdmin,"confirmar",cadena);
}
function end_checkAdmin(cadena){
	if(cadena==1){ //login existe
		alert("Identification existe déjà");
		document.getElementById("txtLogin").focus();
		return false;
	}else if(cadena==2){ //email existe
		alert("Email existe déjà");
		document.getElementById("txtEmail").focus();
		return false;
	}else{
		document.frmRegister.submit();
	}
}
//Finalizar pedido
function end_order(){
	form=document.frmPanier;
	total=form.totaltypePayment.value;
	totCheck=0;
	for(i=0;i<total;i++){
		if(document.getElementById("optTypepayment"+i).checked==false){
			totCheck++;
		}else{
			typepayment=document.getElementById("optTypepayment"+i).value;
		}
	}
	if(total==totCheck){
		alert("Merci de bien vouloir choisir un type de payment");
		return false;
	}else{
		if(typepayment==1){//tarjeta de credito PAYBOX
			//form.action="https://tpeweb.paybox.com/cgi/MYchoix_pagepaiement.cgi";
			form.action="buy_target.php?page=8";
		}else{//cheque
			//form.action="abonnement_etat.php?page=3";
			form.action="payment_cheque.php?page=3";
		}
		form.submit();
	}
}

/*
funcion para la validación del formulario para los banners
Fecha: 29-DIC-2006
*/
function checkBanner(page){
	oForm=document.forms[0];

	if(document.getElementById('optDim1').checked==false && document.getElementById('optDim2').checked==false){
		alert("Le champ \"dimensions du banner\" est obligatoire");
		document.getElementById("size").focus();
		document.getElementById('size').style.background="#FFFF99";
		return false;
	}

	if(document.getElementById('rbfile1').checked==true){
		
		if((page=="1") || (page=="2" && oForm.txtfile.value=="TEXT HTML")){
			if(document.getElementById("upfile").value==""){
				alert("Le champ \"file\" est obligatoire");
				document.getElementById("upfile").focus();
				document.getElementById("upfile").style.background="#FFFF99";
				//limpiamos el color amarillo por si hubo error en al campo anterior
				document.getElementById("txtHtml").style.background="#FFFFFF";			
				return false;
			}
		}
	}
	if(oForm.rbfile[1].checked==true){
		var height=document.getElementById("txtHeight").value;
		if(height=="" || height==0){
			alert("Le champ \"Haut du Html\" est obligatoire");
			document.getElementById("txtHeight").focus();			
			//limpiamos el color amarillo por si hubo error en al campo anterior
			document.getElementById("upfile").style.background="#FFFFFF";
			return false;
		}
		if(document.getElementById("txtHtml").value==""){
			alert("Le champ \"HTML\" est obligatoire");
			document.getElementById("txtHtml").focus();			
			//limpiamos el color amarillo por si hubo error en al campo anterior
			document.getElementById("upfile").style.background="#FFFFFF";
			return false;
		}
	}

}

function checkFormPress(page){
	
	form=document.frmRegister;
	
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Nom du press\" est obligatoire");
		document.getElementById("txtName").focus();			
		document.getElementById("txtName").style.background="#FFFF99";
		return false;
	}else{
		form.submit();	
	}
	
/*	if(page==1){
		if(document.getElementById("image").value==""){
			alert("Le champ \"Nom du press\" est obligatoire");
			document.getElementById("image").focus();			
			document.getElementById("image").style.background="#FFFFFF";
			return false;
		}		
	}*/
}

function checkFormArticle(page){
	form=document.frmRegister;
	
	flag=1;
	
	if(document.getElementById("cbo_Media").value==0){
		alert("Le champ \"Media\" est obligatoire");
		document.getElementById("cbo_Media").focus();			
		document.getElementById("cbo_Media").style.background="#FFFF99";
		return false;
		flag=0;
	}
	if(document.getElementById("cbo_Spectacle").value==0){
		alert("Le champ \"Spectacle\" est obligatoire");
		document.getElementById("cbo_Spectacle").focus();			
		document.getElementById("cbo_Spectacle").style.background="#FFFF99";
		return false;
		flag=0;
	}
	/*if(document.getElementById("txtTitle").value==""){
		alert("Le champ \"Titre\" est obligatoire");
		document.getElementById("txtTitle").focus();			
		document.getElementById("txtTitle").style.background="#FFFF99";
		return false;
		flag=0;
	}*/
	if(document.getElementById("txtDescription").value==""){
		alert("Le champ \"Description\" est obligatoire");
		document.getElementById("txtDescription").focus();			
		document.getElementById("txtDescription").style.background="#FFFF99";
		return false;
		flag=0;
	}
	
	if(flag==1){
		form.submit();
	}
}

function checkInscription(){
	form=document.frmInscription;
	if(validaForm(form)!=false){
		if(form.hidOrigen.value=="web"){
			codepartner=form.txtCodepartner.value;	
		}else{
			codepartner='';
		}
		//codepartner='';
		//login=form.txtnickUser.value;
		login='';
		email=form.txtemailUser.value;
		idUser=form.hidsessionUser.value;
		cadena=codepartner+","+login+","+email+","+idUser;
		if(form.hidOrigen.value=="web"){ //si se invoca desde la web
			jsrsExecute("./include/check_inscription.php",end_CheckInscription,"confirmar",cadena);
		}else{ //si se invoca desde el admin
			jsrsExecute("../../include/check_inscription.php",end_CheckInscription,"confirmar",cadena);
		}
	}
}
function end_CheckInscription(param){
	form=document.frmInscription;
	if(param==4){//todo ok
		form.submit();	
	}else{
		if(param==1){//partner inexistente
			alert("Code partenaire incorrect!");
			form.txtCodepartner.select();
		}else if(param==2){//login existente
			alert("Login existe deja");
			form.txtnickUser.select();
		}else{//3.-email existente
			alert("Email existe deja");
			form.txtemailUser.select();
		}
	}
}

function setFocus(){
	document.form1.txtLog.focus();	
}


function checkReserverPouceSpect(idProd,idDate,idHour,numReser){
	cadena=idProd+","+idDate+","+idHour+","+numReser;
	jsrsExecute("check_ReserverPouceSpect.php",endcheckReserverPouceSpect,"confirmar",cadena);
}

function endcheckReserverPouceSpect(param){
	data=param.split("|");	
	ok=data[0];	
	if(ok==1){
		cuatropm=data[6];
		idProd=data[1];
		idDate=data[2];
		idHour=data[3];
		numReser=data[4];		
		flag=data[5];		
		//alert(flag);
		if(flag==1 && cuatropm==1){			
			location.href='reserver_pouce.php?idProduct='+idProd+'&idDate='+idDate+'&idHour='+idHour+'&reserver='+numReser;
		}else{
			if(cuatropm==0){
				alert("Nous sommes désolés, vous ne pouvez pas réserver pour cette date après 16H. Merci pour votre compréhention.");
				flag=2; /*Solo para desactivarlo y no salga doble mensaje*/	
			}
			if(flag==0){
				alert("Nous sommes désolés, vous avez déjà une réservation pour cette date");	
			}
		}
	}else{
		alert("Nous sommes désolés, vous avez déjà réservé d'invitations bonus pour ce spectacle");	
	}
}

function checkInvitation(){
	
	form=document.frmInvitation;
	if(validaForm(form)!=false){

		if(form.txtEmail0.value != ""){
			email=1;
		}

		if(form.txtEmail1.value != ""){
			email=2;
		}

		if(form.txtEmail2.value != ""){
			email=3;
		}

		if(form.txtEmail3.value != ""){
			email=4;
		}

		if(form.txtEmail4.value != ""){
			email=5;
		}

		cadena=form.txtEmail0.value+","+email;
		if(form.txtEmail0.value!=""){
		jsrsExecute("./include/check_invitation.php",end_checkInvitation1,"confirmar",cadena);}
		cadena=form.txtEmail1.value+","+email;
		if(form.txtEmail1.value!=""){
		jsrsExecute("./include/check_invitation.php",end_checkInvitation2,"confirmar",cadena);}
		cadena=form.txtEmail2.value+","+email;
		if(form.txtEmail2.value!=""){
		jsrsExecute("./include/check_invitation.php",end_checkInvitation3,"confirmar",cadena);}
		cadena=form.txtEmail3.value+","+email;
		if(form.txtEmail3.value!=""){
		jsrsExecute("./include/check_invitation.php",end_checkInvitation4,"confirmar",cadena);
		}
		cadena=form.txtEmail4.value+","+email;
		if(form.txtEmail4.value!=""){
		jsrsExecute("./include/check_invitation.php",end_checkInvitation5,"confirmar",cadena);}
	}
}
function end_checkInvitation(param){
	form=document.frmInvitation;
	if(param==1){
		form.submit();	
	}else{
		alert("Cette personne est déjà membre du Club des Spectacles");	
	}
}

function end_checkInvitation1(param){
	
	form=document.frmInvitation;
	data=param.split("|");
	if(data[0]==1){
		if(data[1]==1){
		form.submit();
		}		
	}else{
		
		alert("Cette email : "+form.txtEmail0.value+" est déjà membre du Club des Spectacles");
		form.txtEmail0.value="";	
	}
}

function end_checkInvitation2(param){
	form=document.frmInvitation;
	data=param.split("|");
	if(data[0]==1){
		if(data[1]==2){
		form.submit();
		}	
	}else{
		
		alert("Cette email : "+form.txtEmail1.value+" est déjà membre du Club des Spectacles");
		
		form.txtEmail2.value="";	
	}
}

function end_checkInvitation3(param){
	form=document.frmInvitation;
	data=param.split("|");
	if(data[0]==1){
		if(data[1]==3){
		form.submit();
		}	
	}else{
		
		alert("Cette email : "+form.txtEmail2.value+" est déjà membre du Club des Spectacles");
		
		form.txtEmail3.value="";	
	}
}

function end_checkInvitation4(param){
	form=document.frmInvitation;
	data=param.split("|");
	if(data[0]==1){
		if(data[1]==4){
		form.submit();
		}	
	}else{
		
		alert("Cette email : "+form.txtEmail3.value+" est déjà membre du Club des Spectacles");
		
		form.txtEmail4.value="";	
	}
}

function end_checkInvitation5(param){
	form=document.frmInvitation;
	data=param.split("|");
	if(data[0]==1){
		if(data[1]==5){
		form.submit();
		}	
	}else{
		
		alert("Cette email : "+form.txtEmail4.value+" est déjà membre du Club des Spectacles");
		form.txtEmail5.value="";	
	}
}

function checkFormVenue(){
	
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Nom la Lieu\" est obligatoire");
		document.getElementById("txtName").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtName").style.background="#FFFF99";
		return false;
	}
	/*if(document.getElementById("cbo_typeVenue").value=="0"){
		alert("Le champ \"Type la salle\" est obligatoire");
		document.getElementById("cbo_typeVenue").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("cbo_typeVenue").style.background="#FFFF99";
		return false;
	}*/
	if(document.getElementById("txtAddress").value==""){
		alert("Le champ \"Adresse\" est obligatoire");
		document.getElementById("txtAddress").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtAddress").style.background="#FFFF99";
		return false;
	}
	/*if(document.getElementById("txtPostal").value==""){
		alert("Le champ \"Code postal\" est obligatoire");
		document.getElementById("txtPostal").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtPostal").style.background="#FFFF99";
		return false;
	}*/
	if(document.getElementById("txtCity").value==""){
		alert("Le champ \"City\" est obligatoire");
		document.getElementById("txtCity").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtCity").style.background="#FFFF99";
		return false;
	}
	
	/*if(document.getElementById("txtMetro").value==""){
		alert("Le champ \"Metro\" est obligatoire");
		document.getElementById("txtMetro").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtMetro").style.background="#FFFF99";
		return false;
	}*/
	
	if(document.getElementById("txtFono").value==""){
		alert("Le champ \"Téléphone 1\" est obligatoire");
		document.getElementById("txtFono").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtFono").style.background="#FFFF99";
		return false;
	}
	
/*	if(document.getElementById("txtEmail").value==""){
		alert("Le champ \"Email\" est obligatoire");
		document.getElementById("txtEmail").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtEmail").style.background="#FFFF99";
		return false;
	}*/	
	if(document.getElementById("txtEmail").value!=""){
		if(emailCheck(document.getElementById("txtEmail").value)==0){
			alert("Votre email n'est pas valide");
			document.getElementById("txtEmail").focus();
			document.getElementById("txtEmail").style.background="#FFFF99";
			return false;
		}
	}	
/*	if(document.getElementById("txtKey").value==""){
		alert("Le champ \"Key\" est obligatoire");
		document.getElementById("txtKey").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtKey").style.background="#FFFFFF";
		return false;
	}	

	if(document.getElementById("txtCapacite").value==""){
		alert("Le champ \"Capacité\" est obligatoire");
		document.getElementById("txtCapacite").focus();			
		//limpiamos el color amarillo por si hubo error en al campo anterior
		document.getElementById("txtCapacite").style.background="#FFFFFF";
		return false;
	}*/
}

function checkFormVisiomag(){
	
	if(document.getElementById("cbo_typeVisiomag").value=="0"){
		alert("Le champ \"Type de critique\" est obligatoire");
		document.getElementById("cbo_typeVisiomag").focus();					
		document.getElementById("cbo_typeVisiomag").style.background="#FFFF99";
		return false;
	}
	
	var esp = document.getElementById("cbo_Spectacle").value;
	var def = document.getElementById("cbo_Person").value
	
	if(esp==0 && def==0){
		alert("Sélectionner un \"Genre traité dans l'article\"\n et/ou un spectacle");
		return false;
	}
	
	/*if(document.getElementById("cbo_Spectacle").value=="0"){
		alert("Sélectionner un artiste et/ou un spectacle");
		document.getElementById("cbo_Spectacle").focus();							
		return false;
	}*/
	
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Titre de L’article\" est obligatoire");
		document.getElementById("txtName").focus();	
		document.getElementById("txtName").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("txtarticulos").value==""){
		alert("Le champ \"Sous-titre de l'article\" est obligatoire");
		document.getElementById("txtarticulos").focus();
		document.getElementById("txtarticulos").style.background="#FFFF99";
		return false;
	}
	
	/*if(document.getElementById('txtarea1').value==""){
		alert("describir caracteristicas");
		document.getElementById('txtarea1').focus();
		return false;
	}*/
	
	if(document.getElementById("txtContein").value==""){
		alert("Le champ \"Corps de l' article\" est obligatoire");
		document.getElementById("txtContein").focus();
		document.getElementById("txtContein").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("txtDate").value==""){
		alert("Le champ \"Date\" est obligatoire");
		document.getElementById("txtDate").focus();
		document.getElementById("txtDate").style.background="#FFFF99";
		return false;
	}	
	
	if(document.getElementById("txtDate").value!=""){
		if(!isValidDate(document.getElementById("txtDate").value)){
			alert("Format de date incorrect : JJ/MM/AAAA");
			document.getElementById("txtDate").focus();					
			document.getElementById("txtDate").style.background="#FFFF99";
			return false;
		}	
	}
	
	if(document.getElementById("txtAutor").value==""){
		alert("Le champ \"Auteur\" est obligatoire");
		document.getElementById("txtAutor").focus();
		document.getElementById("txtAutor").style.background="#FFFF99";
		return false;
	}	
	
	if(document.getElementById("txtEmailAutor").value!=""){
		if(emailCheck(document.getElementById("txtEmailAutor").value)==0){
			alert("Votre email n'est pas valide");
			document.getElementById("txtEmailAutor").focus();
			document.getElementById("txtEmailAutor").style.background="#FFFF99";
			return false;
		}
	}		
}

/*funcion para ingresar solamente 255 caracteres*/
	function limitlength(obj, length){
		var maxlength=length;
			if (obj.value.length>maxlength)
				obj.value=obj.value.substring(0, maxlength);
			}
/*fin de la funcion*/

function checkFormSpectacle(typepage){
	if(checkPartnerFlash()==false){
		return false;
	}
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Name du spectacle\" est obligatoire");
		document.getElementById("txtName").focus();					
		document.getElementById("txtName").style.background="#FFFF99";
		return false;
	}

	/*if(document.getElementById("cbo_typeVenue").value=="" || document.getElementById("cbo_typeVenue").value==0){
		alert("Le champ \"Salle\" est obligatoire");
		document.getElementById("cbo_typeVenue").focus();					
		document.getElementById("cbo_typeVenue").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("txtPrix").value==""){
		alert("Le champ \"Prix\" est obligatoire");
		document.getElementById("txtPrix").focus();					
		document.getElementById("txtPrix").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("txtPrix2").value==""){
		alert("Le champ \"Prix 2\" est obligatoire");
		document.getElementById("txtPrix2").focus();					
		document.getElementById("txtPrix2").style.background="#FFFF99";
		return false;
	}*/
	/*if(document.getElementById("txtDescription").value==""){
		alert("Le champ \"Description\" est obligatoire");
		document.getElementById("txtDescription").focus();					
		document.getElementById("txtDescription").style.background="#FFFF99";
		return false;
	}
	
		if(document.getElementById("textProductArtist").value==""){
		alert("Le champ \"Artistes\" est obligatoire");
		document.getElementById("textProductArtist").focus();					
		document.getElementById("textProductArtist").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("varProductDirector").value==""){
		alert("Le champ \"Mise en scène\" est obligatoire");
		document.getElementById("varProductDirector").focus();					
		document.getElementById("varProductDirector").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("varProductAutor").value==""){
		alert("Le champ \"Auteur\" est obligatoire");
		document.getElementById("varProductAutor").focus();					
		document.getElementById("varProductAutor").style.background="#FFFF99";
		return false;
	}*/
/*	if(document.getElementById("txtDescription2").value==""){
		alert("Le champ \"Synopsis 2\" est obligatoire");
		document.getElementById("txtDescription2").focus();					
		document.getElementById("txtDescription2").style.background="#FFFF99";
		return false;
	}*/
/*	if(document.getElementById("txtTime").value==""){
		alert("Le champ \"Durée du spectacle\" est obligatoire");
		document.getElementById("txtTime").focus();					
		document.getElementById("txtTime").style.background="#FFFF99";
		return false;
	}*/
/*	if(document.getElementById("txtDates").value==""){
		alert("Le champ \"Dates\" est obligatoire");
		document.getElementById("txtDates").focus();					
		document.getElementById("txtDates").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("txtDateBegin").value==""){
		alert("Le champ \"Date Première\" est obligatoire");
		document.getElementById("txtDateBegin").focus();					
		document.getElementById("txtDateBegin").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("txtDateEnd").value==""){
		alert("Le champ \"Date Dernière\" est obligatoire");
		document.getElementById("txtDateEnd").focus();					
		document.getElementById("txtDateEnd").style.background="#FFFF99";
		return false;
	}	
	*/
	/*
	Validando las fechas Inicial y final
	*/
	if(document.getElementById("txtDateBegin").value!=""){
		if(!isValidDate(document.getElementById("txtDateBegin").value)){
			alert("Format de date incorrect : JJ/MM/AAAA");
			document.getElementById("txtDateBegin").focus();					
			document.getElementById("txtDateBegin").style.background="#FFFF99";
			return false;
		}
	}
	if(document.getElementById("txtDateEnd").value!=""){
		if(!isValidDate(document.getElementById("txtDateEnd").value)){
			alert("Format de date incorrect : JJ/MM/AAAA");
			document.getElementById("txtDateEnd").focus();					
			document.getElementById("txtDateEnd").style.background="#FFFF99";
			return false;
		}		
	}
	
	var nodates=0;	
	if(document.getElementById("txtDateBegin").value=="" && document.getElementById("txtDateEnd").value==""){
		nodates=1;	
	}	
	/*if(isValidDate(document.getElementById("txtDateBegin").value) && isValidDate(document.getElementById("txtDateEnd").value)){
		if(document.getElementById("txtDateBegin").value > document.getElementById("txtDateEnd").value){
			alert("L\'heure de fin de représentation ne peut être antérieure à l\'heure de début");
			document.getElementById("txtDateBegin").focus();
			document.getElementById("txtDateBegin").style.background="#FFFF99";
			return false;
		}
	}*/
	
	/*
	Validando los check de los dias para las horas
	*/
	
	if(nodates==0){
	
	if(typepage!=2){
	
		var chkc=0;
		for(i=1; i<8; i++){
			if(document.getElementById("chk"+i).checked==false){
				chkc=chkc+1;
			}
		}
		if(chkc==7){
			alert("Veuillez sélectionner les jours");
			return false;
		}
		//--------------------------------------------
	
		for(j=1; j<8; j++){
			if(document.getElementById("chk"+j).checked==true){
				
				if(document.getElementById("cbo_Hr"+j).value=='0' && document.getElementById("cbo2_Hr"+j).value=='0'){
					alert("Vous devez entrer l\'heure de début du spectacle");
					document.getElementById("cbo_Hr"+j).focus();
					return false;
				}
				
				if(document.getElementById("cbo_Hr"+j).value!='0'){
				
					if(document.getElementById("txtQuotan"+j).value=="" || document.getElementById("txtQuota"+j).value=="" || document.getElementById("txtQuotai"+j).value==""){
						alert("Vous devez spécifier le nombre de places disponibles");
						document.getElementById("txtQuotan"+j).focus();
						return false;
					}
				}
				
				if(document.getElementById("cbo2_Hr"+j).value!='0'){
				
					if(document.getElementById("txtQuotan2"+j).value=="" || document.getElementById("txtQuota2"+j).value=="" || document.getElementById("txtQuotai2"+j).value==""){
						alert("Vous devez spécifier le nombre de places disponibles");
						document.getElementById("txtQuotan2"+j).focus();
						return false;
					}
				}
				
				if((document.getElementById("cbo_Hr"+j).value==document.getElementById("cbo2_Hr"+j).value) && (document.getElementById("cbo_Hr"+j).value!='0' && document.getElementById("cbo2_Hr"+j).value!='0')){
					alert("Attention : horaires identiques");
					return false;
				}
				
			}
		}
	} // End if
	
	} // End if de nodates
	
	page=document.getElementById("asoc_spectacle").value;	
	idProduct=document.getElementById("idProduct").value;
	
	if(typepage!=2){
				
		if(document.getElementById("chk1").checked==true){
			chckL=1;
		}else{
			chckL="";
		}
		if(document.getElementById("chk2").checked==true){
			chckM=1;
		}else{
			chckM="";
		}
		if(document.getElementById("chk3").checked==true){
			chckMi=1;
		}else{
			chckMi="";
		}
		if(document.getElementById("chk4").checked==true){
			chckJ=1;
		}else{
			chckJ="";
		}
		if(document.getElementById("chk5").checked==true){
			chckV=1;
		}else{
			chckV="";
		}
		if(document.getElementById("chk6").checked==true){
			chckS=1;
		}else{
			chckS="";
		}
		if(document.getElementById("chk7").checked==true){
			chckD=1;
		}else{
			chckD="";
		}
				
		dateB=document.getElementById("txtDateBegin").value;
		dateE=document.getElementById("txtDateEnd").value;
		
		cadena1=page+","+idProduct+","+typepage+","+dateB+","+dateE+","+chckL+","+chckM+","+chckMi+","+chckJ+","+chckV+","+chckS+","+chckD+",1000,"+nodates;
		
		// Esto verifica si en el rango de fecha se encuentra los dias seleccionados.
		jsrsExecute("check_date_spectacle.php",check_date_spectacle,"confirmar",cadena1);
	}else{
		cadena=page+","+idProduct+","+typepage;	
		jsrsExecute("check_spectacle.php",end_checkSpectacle,"confirmar",cadena);		
	}
	
}

function check_date_spectacle(param){
	form=document.frmRegister;
	
	data=param.split("|");
	//data=param;
	//person=data[0];
	spectacle=data[0];
	lieuVenue=data[1];
	
	var nodate=data[11];
	
	var msg=0;
	//alert(spectacle);
	//if(person==1 && spectacle==1){	
	//if(data[9]=="1000"){
	if(nodate==0){
		
		var lunes,martes,miercoles,jueves,viernes,sabado,domingo;		
		if(data[2]==1){
			lunes="Lundi, ";	
			msg=1;
		}else{
			lunes="";
		}
		if(data[3]==1){
			martes="Mardi, ";
			msg=1;
		}else{
			martes="";	
		}
		if(data[4]==1){
			miercoles="Mercredi, ";	
			msg=1;
		}else{
			miercoles="";	
		}
		if(data[5]==1){
			jueves="Jeudi, ";
			msg=1;
		}else{
			jueves="";	
		}
		if(data[6]==1){
			viernes="Vendredi, ";	
			msg=1;
		}else{
			viernes="";	
		}
		if(data[7]==1){
			sabado="Samedi, ";
			msg=1;
		}else{
			sabado="";	
		}
		if(data[8]==1){
			domingo="Dimanche, "; 
			msg=1;
		}else{
			domingo="";	
		}
		var dias;
		dias=lunes+martes+miercoles+jueves+viernes+sabado+domingo;
		
		
	}
		
		if(msg=="1"){
			var lendias=dias.length;
			dias=dias.substr(0,dias.length-2);
			alert("Pas de "+dias+" sur la période de quotas définie");
			return false;
		}else{
			page=document.getElementById("asoc_spectacle").value;	
			idProduct=document.getElementById("idProduct").value;	
			
			cadena=page+","+idProduct+","+data[9];	
			//alert(idProduct);
			jsrsExecute("check_spectacle.php",end_checkSpectacle,"confirmar",cadena);		
		}		
		
	
	
	
}

function end_checkSpectacle(param){

	form=document.frmRegister;
	
	data=param.split("|");
	//data=param;
	//person=data[0];
	spectacle=data[0];
	lieuVenue=data[1];
	flag=1;
	if(document.getElementById('chckHrBlock').checked==true){
		if(document.getElementById('txtHrBlock').value==""){
			alert("Vous devez entrer l\'heure");
			flag=0;
			return false;
		}
	}
	//alert(spectacle);
	//if(person==1 && spectacle==1){	
	
		if(spectacle==1 && lieuVenue==1 && flag==1){	
			//alert(document.getElementById('txtDescription').value);
			form.submit();
			//alert("enviar submit");
		}else{
			if(spectacle!=1){
				alert("Vous devez choisir une ou plusieurs catégories");
				return false;
			}
			if(lieuVenue!=1){
				alert("Vous devez choisir une Salle ou Lieu");
				return false;
			}
		}
	

}

function activarVideo(valor,idVideo){
	cadena=valor+","+idVideo;
	//alert(cadena);
	jsrsExecute("activarVideo.php",end_activarVideo,"confirmar",cadena);	
}
function end_activarVideo(param){
	data=param;
	if(data==1 || data==0){
		alert("opération effectuée");	
	}
}

function search_boutique(){
	
	month=document.getElementById("cboMonth").value;
	year=document.getElementById("cboYear").value;
	cadena=month+","+year;
	//alert(cadena);
	jsrsExecute("search_boutique.php",end_search_boutique,"confirmar",cadena);	
}
function end_search_boutique(param){
	data=param.split("|");
	
	if(data[1]!="" && data[0]!=0){
		document.getElementById("show_detail").style.display='';
		document.getElementById("fecha").innerHTML=data[2]+" "+data[3];
		document.getElementById("idMonto").innerHTML=data[1]+" &euro;";
	}else{
		document.getElementById("show_detail").style.display='none';	
	}
}

function putDurationAbo(type){
		
	day=document.getElementById("cboDay1").value;
	month=document.getElementById("cboMonth1").value;
	year=document.getElementById("cboYear1").value;
	
	//duration_bd=parseInt(document.getElementById("txtDuration_").value);
	duration_box=parseInt(document.getElementById("txtDuration").value);

	//if(duration_box >= duration_bd){
		
	if(type==0){	
		duration=document.getElementById("txtDuration").value;	
		cadena=type+","+duration+","+day+","+month+","+year;
	}else{
		if(type==1){
			dayE=document.getElementById("cboDayE").value;
			monthE=document.getElementById("cboMonthE").value;
			yearE=document.getElementById("cboYearE").value;
			
			cadena=type+","+day+","+month+","+year+","+dayE+","+monthE+","+yearE;
		}
	}
	
	jsrsExecute("putDuration_abonnement.php",end_putDurationAbo,"confirmar",cadena);
	
	/*}else{
		alert("ERROR: TYPE PARAMETER DURATION");
		document.getElementById("txtDuration").value=duration_bd;
	}*/
}

function end_putDurationAbo(param){
	data=param.split("|");
alert(data);
	duration_bd=parseInt(document.getElementById("txtDuration_").value);
	//De la caja de texto duration
	if(data[0]==0){
		day=data[1];
		month=data[2];
		year=data[3];
		// Limpiamos los combos para las fechas finales-----------------------
		for(x=0; x < 31; x++) {	
			document.getElementById("cboDayE").options[0]= null;
		}
		for(x=0; x < 13; x++) {	
			document.getElementById("cboMonthE").options[0]= null;
		}
		for(x=0; x < 6; x++) {	
			document.getElementById("cboYearE").options[0]= null;
		}
		//--------------------------------------------------------------------
		
		// Cargamos los dias 
		for(x=0; x <= 31; x++) {			
			if(x==0){
				val_day="Jour";
				id_day="0";
			}else{
				numday=(x<=9)?("0"+x):(x);
				val_day=numday;
				id_day=numday;
			}
			otraopcion=new Option(val_day,id_day);
			document.getElementById("cboDayE").options[x]= otraopcion;
			if(val_day==day){
				document.getElementById("cboDayE").options[x].selected=true;
			}
		}
		
		// Cargamos los meses
		for(x=0; x <= 12; x++) {
			if(x==0){
				val_month="Mois";
				id_month="0";
			}else{
				val_x=(x<=9)?("0"+x):(x);
				val_month=fun_month(String(val_x));
				id_month=val_x;			
			}
			otraopcion=new Option(val_month,id_month);
			document.getElementById("cboMonthE").options[x]= otraopcion;
			if(id_month==month){
				document.getElementById("cboMonthE").options[x].selected=true;	
			}
		}
		
		// Cargamos los anios
		otraopcion=new Option("Année","0000");
		document.getElementById("cboYearE").options[0]= otraopcion;	
		for(y=1; y<=5; y++) {
			
			val_year=parseInt(document.getElementById("anio_").value)+y-1;
			id_year=val_year;
			otraopcion=new Option(val_year,id_year);
			document.getElementById("cboYearE").options[y]= otraopcion;
			
			if(val_year==year){
				document.getElementById("cboYearE").options[y].selected=true;	
			}
		}
	}else{		
		if(data[0]==1){
			if(duration_bd<=data[1] && data[1]>0){
				document.getElementById("txtDuration").value=data[1];
			}else{
				alert("La date d\'expiration de l\'abonnement doit être ultirérieure à la date de fin actuelle");
				window.location.reload();
			}
		}else{
			alert("La date d\'expiration de l\'abonnement doit être ultirérieure à la date de fin actuelle");
			window.location.reload();
		}
	}
}
function typeabonoselect(){
	
	document.getElementById("monto").innerHTML="";
	document.getElementById("numplacesMonth").value="";
	document.getElementById("txtMonto").value="";
	document.getElementById("txtDuration").value="";
	document.getElementById("numplaces").value="";
	document.getElementById("txtMontoTotal").value="";
	document.getElementById("txtReduccion").value="";
	
	typeabono=document.getElementById("cboTypeAbono").value;
		
	day=document.getElementById("cboDay1").value;
	month=document.getElementById("cboMonth1").value;
	year=document.getElementById("cboYear1").value;
	cadena=typeabono+","+day+","+month+","+year;
	//alert(cadena);
	jsrsExecute("value_abonnement.php",end_typeabonoselect,"confirmar",cadena);
}

function end_typeabonoselect(param){
	
	data=param.split("|");
	day=data[1];
	month=data[2];
	year=data[3];
	
	price=data[4];
	// Limpiamos los combos para las fechas finales-----------------------
	for(x=0; x < 31; x++) {	
		document.getElementById("cboDayE").options[0]= null;
	}
	for(x=0; x < 13; x++) {	
		document.getElementById("cboMonthE").options[0]= null;
	}
	for(x=0; x < 6; x++) {	
		document.getElementById("cboYearE").options[0]= null;
	}
	//--------------------------------------------------------------------
	// Cargamos los dias 
	for(x=0; x <= 31; x++) {			
		if(x==0){
			val_day="Jour";
			id_day="0";
		}else{
			numday=(x<=9)?("0"+x):(x);
			val_day=numday;
			id_day=numday;
		}
		otraopcion=new Option(val_day,id_day);
		document.getElementById("cboDayE").options[x]= otraopcion;
		if(val_day==day){
			document.getElementById("cboDayE").options[x].selected=true;
		}
	}
	
	// Cargamos los meses
	for(x=0; x <= 12; x++) {
		if(x==0){
			val_month="Mois";
			id_month="0";
		}else{
			val_x=(x<=9)?("0"+x):(x);
			val_month=fun_month(String(val_x));
			id_month=val_x;			
		}
		otraopcion=new Option(val_month,id_month);
		document.getElementById("cboMonthE").options[x]= otraopcion;
		if(id_month==month){
			document.getElementById("cboMonthE").options[x].selected=true;	
		}
	}
	
	// Cargamos los anios
	otraopcion=new Option("Année","0000");
	document.getElementById("cboYearE").options[0]= otraopcion;	
	for(y=1; y<=5; y++) {
		
		val_year=parseInt(document.getElementById("anio_").value)+y-1;
		id_year=val_year;
		otraopcion=new Option(val_year,id_year);
		document.getElementById("cboYearE").options[y]= otraopcion;
		
		if(val_year==year){
			document.getElementById("cboYearE").options[y].selected=true;	
		}
	}
	
	document.getElementById("monto").innerHTML=price+" &#8364;";
	document.getElementById("numplacesMonth").value=data[0];
	document.getElementById("txtMonto").value=price;
	document.getElementById('txtMontoTotal').value=price;
	document.getElementById("txtDuration").value=data[0];
	document.getElementById("txtDuration_").value=data[0];
	document.getElementById("numplaces").value=data[5];
	
	if(document.getElementById("cboTypeAbono").value==0){
		document.getElementById("monto").innerHTML="";
		document.getElementById("numplacesMonth").value="";
		document.getElementById("txtMonto").value="";
		document.getElementById("txtDuration").value="";
		document.getElementById("txtDuration_").value="";
		document.getElementById("numplaces").value="";
	}else{
		if(document.getElementById("cboTypeAbono").value==4){
			document.getElementById("numplaces").readOnly=false;
			document.getElementById("txtDuration").readOnly=false;
			document.getElementById("txtMonto").readOnly=false;
		}else{
			document.getElementById("numplaces").readOnly=true;
			document.getElementById("txtDuration").readOnly=true;
			document.getElementById("txtMonto").readOnly=true;	
		}
	}

}

function typeabonoselect2(){
	typeabono=document.getElementById("cboTypeAbono").value;
	day=document.getElementById("cboDay1").value;
	month=document.getElementById("cboMonth1").value;
	year=document.getElementById("cboYear1").value;
	cadena=typeabono+","+day+","+month+","+year;
	//alert(cadena);
	jsrsExecute("value_abonnement.php",end_typeabonoselect2,"confirmar",cadena);
}

/*function changeDay(){
	typeabono=document.getElementById("cboTypeAbono").value;
	day=document.getElementById("cboDay1").value;
	month=document.getElementById("cboMonth1").value;
	year=document.getElementById("cboYear1").value;
	cadena=typeabono+","+day+","+month+","+year;
}*/

function end_typeabonoselect2(param){
	
	data=param.split("|");
	day=data[1];
	month=fun_month(data[2]);
	year=data[3];
	price=data[4];
		
	//alert(data[0]);	
	document.getElementById("monto").innerHTML=price+" &#8364;";
	//document.getElementById("daye").value=day;
	document.getElementById("numplaces").value=data[0];
	//document.getElementById("numMonthAbo").value=data[0];
}

function fun_month(mes){
	var m;
	switch(mes){
		case "01":
			m="Janvier";
			break;
		case "02":
			m="Février";
			break;
		case "03":
			m="Mars";
			break;
		case "04":
			m="Avril";
			break;
		case "05":
			m="Mai";
			break;
		case "06":
			m="Juin";
			break;
		case "07":
			m="Juillet";
			break;
		case "08":
			m="Août";
			break;
		case "09":
			m="Septembre";
			break;
		case "10":
			m="Octobre";
			break;
		case "11":
			m="Novembre";
			break;
		case "12":
			m="Décembre";
			break;
	}
	return m;
}

function lieu_salle(flag){
	
	idProduct=document.frm_1.idProduct.value;
		
	if(flag){
		//salle
		$idLieuSalle=document.getElementById("cbo_typeVenue").value;
		$type=1;
	}else{
		//lieu
		$idLieuSalle=document.getElementById("cbo_typeLieu").value;
		$type=0;
	}
	cadena=$idLieuSalle+","+idProduct+","+$type;
	//alert(cadena);
	jsrsExecute("check_salle_lieu.php",end_salle_lieu,"confirmar",cadena);
}

function end_salle_lieu(){
	
	// *** NO BORRAR ESTA FUNCION, ES IMPORTANTE ***

}

function checkFormEvenement(num){
	form=document.frm;
	
	ok="1";
	if(document.getElementById("cbo_Spectacle").value=="0"){
		alert("Le champ \"Spectacle\" est obligatoire");
		document.getElementById("cbo_Spectacle").focus();					
		document.getElementById("cbo_Spectacle").style.background="#FFFF99";
		return false;
		ok=0;
	}
	if(num=="0"){
		if(document.getElementById("image_file").value==""){
			alert("Le champ \"Image\" est obligatoire");
			document.getElementById("image_file").focus();					
			document.getElementById("image_file").style.background="#FFFF99";
			return false;
			ok=0;
		}
	}
	
	if(ok=="1"){
		//alert(ok);
		form.submit();
	}
}

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 checkPrix(ctrl){
	if(ctrl.value<=0){
		alert(" Prix Incorrecte! ");
		ctrl.value="";
		ctrl.focus();
	}
	if(isNaN(ctrl.value)==true){
		alert(" Prix Incorrecte! ");
		ctrl.value="";
		ctrl.focus();
	}
}

function checkFormClose(){
	if(document.getElementById("cboDay").value=="0"){
		alert("Le champ \"jour\" est obligatoire");
		document.getElementById("cboDay").focus();					
		document.getElementById("cboDay").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("cboMonth").value=="0"){
		alert("Le champ \"mois\" est obligatoire");
		document.getElementById("cboMonth").focus();					
		document.getElementById("cboMonth").style.background="#FFFF99";
		return false;
	}

	day=document.getElementById("cboDay").value;
	month=document.getElementById("cboMonth").value;
	year=document.getElementById("cboYear").value;
	
	page=document.getElementById("page").value;
	idClose=document.getElementById("idClose").value;
	
	if(day!=0 && month!=0){
		cadena=year+","+month+","+day+","+page+","+idClose;	
		jsrsExecute("check_date.php",end_checkDate,"confirmar",cadena);
	}
	
}


function end_checkDate(param){
	form=document.frmRegister;
	
	data=param;
	
	if(data){	
		form.submit();		
	}else{
		alert("Date déjà existante");
		return false;
	}
	
}

function valida_formCart(){
	ok=true;
	
	if(document.getElementById("cbo_Spectacle").value=="0"){
		alert("Le champ est obligatoire");
		document.getElementById("cbo_Spectacle").focus();
		document.getElementById("cbo_Spectacle").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	if(document.getElementById("cboRepresentation").value==""){
		alert("Le champ est obligatoire");
		document.getElementById("cboRepresentation").focus();
		document.getElementById("cboRepresentation").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	if(document.getElementById("idUser").value=="0"){
		alert("Le champ est obligatoire");
		document.getElementById("idUser").focus();
		document.getElementById("idUser").style.background="#FFFF99";
		return false;
		ok=false;
	}
	if(document.getElementById("type_reserve").value=="0"){
		alert("Le champ \"Type de réservation\" est obligatoire");
		document.getElementById("type_reserve").focus();
		document.getElementById("type_reserve").style.background="#FFFF99";
		return false;
		ok=false;
	}
	if(document.getElementById("txtNumReserve").value==""){
		alert("Le champ \"Nombre de places\" est obligatoire");
		document.getElementById("txtNumReserve").focus();
		document.getElementById("txtNumReserve").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	day=document.getElementById('cboDay').value;
	month=document.getElementById('cboMonth').value;
	year=document.getElementById('cboYear').value;
			
	if(document.getElementById("chck").checked==false){
		if(document.getElementById("cboTypePay").value=="0"){
			alert("Le champ \"Moyen de paiement\" est obligatoire");
			document.getElementById("cboTypePay").style.background="#FFFF99";
			return false;
			ok=false;
		}
	}else{
		if(day=='0' || month=='0' || year=='0000'){
			alert("Le champ \"Date de paiement\" est obligatoire");
			return false;
			ok=false;
		}
	}
	if(ok){
		idUser=document.getElementById("idUser").value;
		idHour=document.getElementById("cboRepresentation").value;
		type_reser=document.getElementById("type_reserve").value;
		num_reser=document.getElementById("txtNumReserve").value;
		
		if(document.getElementById('chck').checked==false){			
			date_payment=year+"-"+month+"-"+day;			
		}else{
			date_payment=0;
		}
		
		//if(action!='edit'){
			cartId=document.getElementById('idCart').value;
			edit=document.getElementById('page_origen').value;
			cadena=idUser+","+idHour+","+type_reser+","+num_reser+","+date_payment+","+edit+","+cartId;	
			jsrsExecute("check_stock.php",end_checkStock,"confirmar",cadena);
		//}
	}
}

function end_checkStock(param){
	form=document.frmCart;
	
	data=param.split("|");
	
	//alert(data);
	
	if(data[6]=="1"){
		data[4]="1";
	}
	
	if(data[0]=="1" && /*data[1]=="1" &&*/ data[3]=="1" && data[4]=="1" && data[5]=="1"){
		form.submit();	
	}else{
		if(data[0]!="1"){
			alert("Il n'y a pas places disponibles");	
		}
		/*if(data[1]!="1"){
			alert("Vous déjà avez fait une réservation aujourd'hui");	
		}*/
		if(data[3]!="1"){
			alert("Cet abonné n'a pas places disponibles");	
			return 0;
		}
		if(data[4]=="0"){
			alert("Il n'a pas de places disponibles dans ce mois");
			return 0;
		}
		if(data[5]=="0"){
			//alert("Numero de reservas es mayor a los lugares disponibles");	
			alert("Nombre de réserves est plus grand aux places disponibles")
			return 0;
		}
	}	
}


function valida_formCart_loisir(){
	ok=true;
	
	if(document.getElementById("cbo_Spectacle").value=="0"){
		alert("Le champ est obligatoire");
		document.getElementById("cbo_Spectacle").focus();
		document.getElementById("cbo_Spectacle").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	if(document.getElementById("cboRepresentation").value==""){
		alert("Le champ est obligatoire");
		document.getElementById("cboRepresentation").focus();
		document.getElementById("cboRepresentation").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	if(document.getElementById("idUser").value=="0"){
		alert("Le champ est obligatoire");
		document.getElementById("idUser").focus();
		document.getElementById("idUser").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	if(document.getElementById("txtNumReserve").value==""){
		alert("Le champ \"Nombre de places\" est obligatoire");
		document.getElementById("txtNumReserve").focus();
		document.getElementById("txtNumReserve").style.background="#FFFF99";
		return false;
		ok=false;
	}
	
	day=document.getElementById('cboDay').value;
	month=document.getElementById('cboMonth').value;
	year=document.getElementById('cboYear').value;
			
	/*if(document.getElementById("chck").checked==false){
		if(document.getElementById("cboTypePay").value=="0"){
			alert("Le champ \"Moyen de paiement\" est obligatoire");
			document.getElementById("cboTypePay").style.background="#FFFF99";
			return false;
			ok=false;
		}
	}else{
		if(day=='0' || month=='0' || year=='0000'){
			alert("Le champ \"Date de paiement\" est obligatoire");
			return false;
			ok=false;
		}
	}*/
	if(day=='0' || month=='0' || year=='0000'){
			alert("Le champ \"Date de paiement\" est obligatoire");
			return false;
			ok=false;
	}
	if(ok){
		idUser=document.getElementById("idUser").value;
		idHour=document.getElementById("cboRepresentation").value;
		//type_reser=document.getElementById("type_reserve").value;
		num_reser=document.getElementById("txtNumReserve").value;
		
		/*if(document.getElementById('chck').checked==false){			
					
		}else{
			date_payment=0;
		}*/
		date_payment=year+"-"+month+"-"+day;	
		//if(action!='edit'){
			cartId=document.getElementById('idCart').value;
			edit=document.getElementById('page_origen').value;
			cadena=idUser+","+idHour+","+num_reser+","+date_payment+","+edit+","+cartId;
			//alert(cadena);
			jsrsExecute("check_stock.php",end_checkStock_loisir,"confirmar",cadena);
		//}
	}
}

function end_checkStock_loisir(param){
	form=document.frmCart;
	
	data=param.split("|");
	
	//alert(param);
	
	if(data[6]=="1"){
		data[4]="1";
	}
	
	if(data[0]=="1" && data[3]=="1" && data[4]=="1" && data[5]=="1"){
		form.submit();	
	}else{
		if(data[0]!="1"){
			alert("Il n'y a pas places disponibles");	
		}
		
		if(data[3]!="1"){
			alert("Cet abonné n'a pas places disponibles");	
			return 0;
		}
		if(data[4]=="0"){
			alert("Il n'a pas de places disponibles dans ce mois");
			return 0;
		}
		if(data[5]=="0"){
			//alert("Numero de reservas es mayor a los lugares disponibles");	
			alert("Nombre de réserves est plus grand aux places disponibles")
			return 0;
		}
	}	
}

function select_representation(idProd){
	var UserID
	UserID=document.getElementById('idUser').value;
	cadena=idProd+","+UserID;
	jsrsExecute("select_representation.php",llenar_combo_representation,"confirmar",cadena);
	
}
function put_num_reserva(UserID){
	var idProd;
	
	//Limpiamos tipo de reservacion, tarifa
	/*document.getElementById('type_reserve').options[0].selected="selected";
	document.getElementById('txtTarifa').value="";
	document.getElementById('txtTotal').value="";*/
	
	idProd=document.getElementById('cbo_Spectacle').value;
	cadena=idProd+","+UserID;
	jsrsExecute("select_representation.php",max_num_reserver_spectacle,"confirmar",cadena);	
}

function max_num_reserver_spectacle(param){
	datos=param.split("|");

	numMaxRep=datos[2];
	// Para el combo numero maximo de reservaciones
	large=document.getElementById('txtNumReserve').length;
	for(y=0;y<large;y++){
		document.getElementById('txtNumReserve').options[0]= null;
	}
	maxi=numMaxRep;
	
	$xx=1;
	for(y=0;y<maxi;y++){
		newopc=new Option(y+1,y+1);
		document.getElementById('txtNumReserve').options[y]=newopc;	
		
		// ESTO ES PARA HACER LA SELECCION EN LA PAGINA EDIT 
		if(document.getElementById("page_origen").value==1 && $xx==1){
			if((y+1)==document.getElementById("numReser").value){
				document.getElementById("txtNumReserve").options[y].selected=true;
				document.getElementById("txtNumReserveHidden").value=document.getElementById("numReser").value;
				$xx=0;
			}
		}
		//--------------------------------------------------
		
	}
}

function llenar_combo_representation(param){
	datos=param.split("|");
	
	id=datos[0].split(",");
	nb=datos[1].split(",");
	
	cid=id.length;		
	
	long=document.getElementById('cboRepresentation').length;
	
	for(x=0; x < long; x++) {	
		document.getElementById("cboRepresentation").options[0]= null;
	}
	
	$xx=1;
	for(x=0; x < cid-1; x++) {
		otraopcion=new Option(nb[x],id[x]);
		document.getElementById("cboRepresentation").options[x]= otraopcion;
		
		// ESTO ES PARA HACER LA SELECCION EN LA PAGINA EDIT 
		if(document.getElementById("page_origen").value==1 && $xx==1){
			if(id[x]==document.getElementById("idHour").value){
				document.getElementById("cboRepresentation").options[x].selected=true;
				$xx=0;
			}
		}
		//--------------------------------------------------
	}	
	
	if(document.getElementById('idUser').value!="" && document.getElementById('idUser').value!=0){
		put_num_reserva(document.getElementById('idUser').value);
	}
}

function select_representation_loisir(idProd){
	var UserID
	UserID=document.getElementById('idUser').value;
	cadena=idProd+","+UserID;
	jsrsExecute("select_representation.php",llenar_combo_representation_loisir,"confirmar",cadena);
	
}

function llenar_combo_representation_loisir(param){
	datos=param.split("|");
	
	id=datos[0].split(",");
	nb=datos[1].split(",");
	
	cid=id.length;		
	
	long=document.getElementById('cboRepresentation').length;
	
	for(x=0; x < long; x++) {	
		document.getElementById("cboRepresentation").options[0]= null;
	}
	
	$xx=1;
	for(x=0; x < cid-1; x++) {
		otraopcion=new Option(nb[x],id[x]);
		document.getElementById("cboRepresentation").options[x]= otraopcion;
		
		// ESTO ES PARA HACER LA SELECCION EN LA PAGINA EDIT 
		if(document.getElementById("page_origen").value==1 && $xx==1){
			if(id[x]==document.getElementById("idHour").value){
				document.getElementById("cboRepresentation").options[x].selected=true;
				$xx=0;
			}
		}
		//--------------------------------------------------
	}	
	
	if(document.getElementById('idUser').value!="" && document.getElementById('idUser').value!=0){
		put_num_reserva_loisir(document.getElementById('idUser').value);
	}
}

function put_num_reserva_loisir(UserID){
	var idProd;
	
	//Limpiamos tipo de reservacion, tarifa
	/*document.getElementById('type_reserve').options[0].selected="selected";
	document.getElementById('txtTarifa').value="";
	document.getElementById('txtTotal').value="";*/
	
	idProd=document.getElementById('cbo_Spectacle').value;
	cadena=idProd+","+UserID;
	jsrsExecute("select_representation.php",max_num_reserver_spectacle_loisir,"confirmar",cadena);	
}

function max_num_reserver_spectacle_loisir(param){
	datos=param.split("|");

	numMaxRep=datos[2];
	// Para el combo numero maximo de reservaciones
	large=document.getElementById('txtNumReserve').length;
	for(y=0;y<large;y++){
		document.getElementById('txtNumReserve').options[0]= null;
	}
	maxi=numMaxRep;
	
	$xx=1;
	for(y=0;y<maxi;y++){
		newopc=new Option(y+1,y+1);
		document.getElementById('txtNumReserve').options[y]=newopc;	
		
		// ESTO ES PARA HACER LA SELECCION EN LA PAGINA EDIT 
		if(document.getElementById("page_origen").value==1 && $xx==1){
			if((y+1)==document.getElementById("numReser").value){
				document.getElementById("txtNumReserve").options[y].selected=true;
				//document.getElementById("txtNumReserveHidden").value=document.getElementById("numReser").value;
				$xx=0;
			}
		}
		//--------------------------------------------------
		
	}
}

function checkFormVisiotv(page){
	if(document.getElementById("cboDay").value=="0"){
		alert("Le champ \"jour\" est obligatoire");
		document.getElementById("cboDay").focus();					
		document.getElementById("cboDay").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("cboMonth").value=="0"){
		alert("Le champ \"mois\" est obligatoire");
		document.getElementById("cboMonth").focus();					
		document.getElementById("cboMonth").style.background="#FFFF99";
		return false;
	}
	if(document.getElementById("cboYear").value=="0000"){
		alert("Le champ \"Année\" est obligatoire");
		document.getElementById("cboYear").focus();					
		document.getElementById("cboYear").style.background="#FFFF99";
		return false;
	}
	
	if(document.getElementById("txtName").value==""){
		alert("Le champ \"Titre de l\'Émission\" est obligatoire");
		document.getElementById("txtName").focus();					
		document.getElementById("txtName").style.background="#FFFF99";
		return false;
	}
	if(page==1){
		if(document.getElementById("upfileVideo").value==""){
			alert("Le champ \"Video (format flv)\" est obligatoire");
			document.getElementById("upfileVideo").focus();					
			document.getElementById("upfileVideo").style.background="#FFFF99";
			return false;
		}	
	}
}

function check_submit_mails(opc){
	
	form=document.frm_submit_emails;
	form.stSubmitSave.value=opc;
	
	//alert(form.stSubmitSave.value);
	
	flag=1;
	
	if(opc==2){
		if(document.getElementById("txtSubject").value==""){
			alert("Le champ \"Subject\" est obligatoire");
			document.getElementById("txtSubject").focus();					
			document.getElementById("txtSubject").style.background="#FFFF99";
			return false;
			flag=0;
		}
		if(document.getElementById("slcSubmit").value==0 && document.getElementById("txtMail_opcb").value==""){
			alert("Seleccione el tipo de destinatario o ingrese un nuevo email a enviar");
			document.getElementById("slcSubmit").focus();					
			document.getElementById("slcSubmit").style.background="#FFFF99";
			return false;
			flag=0;
		}
		
		if(document.getElementById("txtMail_opcb").value!=""){
			if(emailCheck(document.getElementById("txtMail_opcb").value)==0){
				alert("Votre email n'est pas valide");
				document.getElementById("txtMail_opcb").focus();
				document.getElementById("txtMail_opcb").style.background="#FFFF99";
				return false;
				flag=0;
			}
		}
		
		if(flag){
			form.submit();
		}
	}
	if(opc==1){
		form.submit();
	}
}
function submit_mails(opc){
	
	form=document.frm_submit_emails;
	form.stSubmitSave.value=opc;
	//alert(form.stSubmitSave.value);
	flag=1;
	
	if(opc==2){
		if(document.getElementById("txtSubject").value==""){
			alert("Le champ \"Subject\" est obligatoire");
			document.getElementById("txtSubject").focus();					
			document.getElementById("txtSubject").style.background="#FFFF99";
			return false;
			flag=0;
		}
		
		if(flag){
			form.submit();
		}
	}
}


function checkFormCoeur(){
	
	form=document.frm;
	flag=1;
	//alert("s");
	if(document.getElementById("cboDay_d").value=="0"){
		alert("Le champ \"jour\" est obligatoire");
		document.getElementById("cboDay_d").focus();					
		document.getElementById("cboDay_d").style.background="#FFFF99";
		return false;
		flag=0;
	}
	if(document.getElementById("cboMonth_d").value=="0"){
		alert("Le champ \"mois\" est obligatoire");
		document.getElementById("cboMonth_d").focus();					
		document.getElementById("cboMonth_d").style.background="#FFFF99";
		return false;
		flag=0;
	}
	
	if(document.getElementById("cboYear_d").value=="0000"){
		alert("Le champ \"Annee\" est obligatoire");
		document.getElementById("cboYear_d").focus();					
		document.getElementById("cboYear_d").style.background="#FFFF99";
		return false;
		flag=0;
	}
	
	if(flag==1){
		
		dateB=document.getElementById("cboYear_d").value+"-"+document.getElementById("cboMonth_d").value+"-"+document.getElementById("cboDay_d").value;
		
		dateE=document.getElementById("cboYear_f").value+"-"+document.getElementById("cboMonth_f").value+"-"+document.getElementById("cboDay_f").value;
	
		idProduct=document.getElementById("idProduct").value;
		dateFirst=document.getElementById("dateFirst").value;
		dateLast=document.getElementById("dateLast").value;
		cadena=dateB+","+dateE+","+idProduct+","+dateFirst+","+dateLast;	
		jsrsExecute("check_coups.php",end_checkFormCoeur,"confirmar",cadena);
	}
}

function end_checkFormCoeur(param){
	data=param.split("|");
	var err1=data[0];
	var err2=data[1];
	
	//alert(data);
	dateB=document.getElementById("dateFirst").value;
	dateE=document.getElementById("dateLast").value;
	
	if(err1==1){
		alert("Dates incorrectes 1");
		/*document.getElementById("errdate1").style.display="";
		document.getElementById("errdate1").innerHTML="ERROR : fecha Inicial mayor a fecha final";
		document.getElementById("errdate2").style.display="none";*/
	}
	if(err2==1){
		alert("Dates incorrectes 2");
		/*document.getElementById("errdate1").style.display="none";
		document.getElementById("errdate2").style.display="";
		document.getElementById("errdate2").innerHTML="ERROR : Las fechas deben estar entre "+dateB+" y "+dateE;*/		
	}
	if(err1!=1 && err2!=1){		
		/*document.getElementById("errdate1").style.display="none";
		document.getElementById("errdate2").style.display="none";*/
		form.submit();
	}
	
}

function check_places_dispo_month(){
	idUser=document.getElementById("idseUser").value;
	
	cadena=idUser;
	//alert(cadena);
	jsrsExecute("./include/cron_reserves_month.php",end_cron_reserves_month,"confirmar",cadena);
}

function end_cron_reserves_month(param){}

function check_places_dispo_month_loisir(){
	idUser=document.getElementById("idseUser").value;
	
	cadena=idUser;
	//alert(cadena);
	jsrsExecute("./include/cron_reserves_month_loisir.php",end_cron_reserves_month_loisir,"confirmar",cadena);
}

function end_cron_reserves_month_loisir(param){}

function check_stock_spectacle(){

	idProduct=document.getElementById("idProd").value;
	idHour=document.getElementById("idHr").value;
	idDateprod=document.getElementById("idDp").value;
	idUser=document.getElementById("idUser").value;
	num_reserve=document.getElementById("sltReserve").value;

	if(num_reserve!=0){
		cadena=idProduct+","+idHour+","+idDateprod+","+idUser+","+num_reserve;
		jsrsExecute("./include/check_stock_spectacle.php",end_check_stock_spectacle,"confirmar",cadena);
	}else{
		alert("Merci d'indiquer le nombre de places souhaitées");	
		document.getElementById("sltReserve").focus();
		return false;
	}
}

function end_check_stock_spectacle(param){
	//alert(param);	

	form=document.frmReserve;
	
	data=param.split("|");	
	msj1=data[0];
	msj2=data[1];
	msj3=data[2];
	msj4=data[3];
	/*msj5=data[4];
	msj6=data[5];
	msj7=data[6];*/
	ok=data[4];
	type=data[6];
	
	controlMonth=data[7];		
	document.getElementById("type").value=type;
	
	//Agregado el 12/02/08
	famille=document.getElementById("famille").value;
	var msg_alert;
	if(famille==1){
		msg_alert="Nous sommes désolés votre abonnement ne vous permet pas de réserver des places famille";
	}else{
		msg_alert="Désolé, votre quota ne vous permet pas de réserver ce nombre de places";
	}
	///////////////////
	if(controlMonth==1){
		if(msj1==1 && msj2==1 && msj3==1 && msj4==1){
			if(ok){
				form.submit();	
			}else{
				alert(msg_alert);
				return false;
			}
		}else{
			
			if(msj1==0){
				alert(msg_alert);	
				return false;
			}
			if(msj2==0){
				alert("Attention : aucune place disponible");	
				return false;
			}
			if(msj3==0){
				alert("Attention : pas assez de places disponibles");	
				return false;
			}
			if(msj4==0){
				alert(msg_alert);	
				return false;
			}		
		}
	}else{
		//alert("No tiene lugares suficientes en este mes");
		//alert("Il n'a pas de places suffisants dans ce mois");
		alert("Désolé, vous n'avez plus de places disponibles dans votre abonnement");
		return false;
	}
}

function check_stock_spectacle_loisir(){

	idProduct=document.getElementById("idProd").value;
	idHour=document.getElementById("idHr").value;
	idDateprod=document.getElementById("idDp").value;
	idUser=document.getElementById("idUser").value;
	num_reserve=document.getElementById("sltReserve").value;
	if(num_reserve!=0){
		cadena=idProduct+","+idHour+","+idDateprod+","+idUser+","+num_reserve;
		jsrsExecute("./include/check_stock_spectacle_loisir.php",end_check_stock_spectacle_loisir,"confirmar",cadena);
	}else{
		alert("Merci d'indiquer le nombre de places souhaitées");	
		document.getElementById("sltReserve").focus();
		return false;
	}
}

function end_check_stock_spectacle_loisir(param){
	
	form=document.frmReserve;
	
	data=param.split("|");	
	msj1=data[0];
	msj2=data[1];
	msj3=data[2];
	msj4=data[3];
	/*msj5=data[4];
	msj6=data[5];
	msj7=data[6];*/
	ok=data[4];
	type=data[6];
	
	controlMonth=data[7];		
	document.getElementById("type").value=type;
	
	//alert(data);
	if(controlMonth==1){
		if(msj1==1 && msj2==1 && msj3==1 && msj4==1){
			if(ok){
				form.submit();	
			}else{
				alert("Désolé, votre quota ne vous permet pas de réserver ce nombre de places");
				return false;
			}
		}else{
			
			if(msj1==0){
				alert("Désolé, votre quota ne vous permet pas de réserver ce nombre de places");	
				return false;
			}
			if(msj2==0){
				alert("Attention : aucune place disponible");	
				return false;
			}
			if(msj3==0){
				alert("Attention : pas assez de places disponibles");	
				return false;
			}
			if(msj4==0){
				alert("Désolé, votre quota ne vous permet pas de réserver ce nombre de places");	
				return false;
			}		
		}
	}else{
		//alert("No tiene lugares suficientes en este mes");
		alert("Il n'a pas de places suffisants dans ce mois");
		return false;
	}
}

function popup(img, ww, hh){
  derecha=(screen.width-ww)/2;
  arriba=(screen.height-hh)/2;
  string="titlebar='no',toolbar=0,scrollbars=yes,location=0,statusbar=0,menubar=0,resizable=1,width="+ww+",height="+hh+",left="+derecha+",top="+arriba+"";
  fin=window.open(img,this.target,string);
}	

function reload_father(){
	document.location.reload();
}

function onfocus_(){
	if(document.getElementById("txtKeyWord").value=="Mot clé"){
		document.getElementById("txtKeyWord").value="";
	}
}

function onblur_(){
	if(document.getElementById("txtKeyWord").value==""){
		document.getElementById("txtKeyWord").value="Mot clé";
	}
}

function onfocus_billetterie(name,text){
	if(document.getElementById(name).value==text){
		//document.getElementById(name).style.fontStyle="normal";
		document.getElementById(name).className='text_normal_billetterie';
		document.getElementById(name).value="";
	}
}

function onblur_billetterie(name,text){
	if(document.getElementById(name).value==""){
		//document.getElementById(name).style.fontStyle="italic";
		document.getElementById(name).className='text_italic_billetterie';
		document.getElementById(name).value=text;
	}
}

function submit_billetterie(){
	var keyword=document.getElementById('autorelleno').value;
	//var spectacle=document.getElementById('cboSearchSpectacle').value;
	var salle=document.getElementById('cboSearchSalle').value;
	var date_=document.getElementById('cboSearchDate').value;
	var genre=document.getElementById('cboSearchGenre').value;
	var tarif=document.getElementById('cboSearchTarif').value;
	var promotion=document.getElementById('cboSearchPromotion').value;
	
	if((keyword=="Recherche par spectacle..." || keyword=="") && salle==0 && (date_=="Recherche par date..." || date_=="") && genre==0 && tarif==0){
		alert("Vous devez choisir un critère de recherche");
		return false;
	}else{
		return true;
	}
}

function onfocus_gral(text,ctrl){
	if(document.getElementById(ctrl).value==text){
		document.getElementById(ctrl).value="";
	}
}
function onblur_gral(text,ctrl){
	if(document.getElementById(ctrl).value==""){
		document.getElementById(ctrl).value=text;
	}	
}

function checkLoginAbonne(){
	if(document.getElementById("txtLogin").value=="Identification"){
		alert("Le champ \"Identification\" est obligatorie");
		document.getElementById("txtLogin").value="";
		document.getElementById("txtLogin").focus();
		return false;
	}
	if(document.getElementById("txtPassword").value=="Votre mot de passe"){
		alert("Le champ \"Mot de passe\" est obligatorie");
		document.getElementById("txtPassword").value="";
		document.getElementById("txtPassword").focus();
		return false;
	}
	
	return true;
}

function checkLoginPrepaye(){
	if(document.getElementById("txtCode").value=="Votre code partenaire"){
		alert("Le champ \"Code partenaire\" est obligatorie");
		document.getElementById("txtCode").value="";
		document.getElementById("txtCode").focus();
		return false;
	}
	if(document.getElementById("txtCodeprepaye").value=="Votre code prépayé"){
		alert("Le champ \"Code prépayé\" est obligatorie");
		document.getElementById("txtCodeprepaye").value="";
		document.getElementById("txtCodeprepaye").focus();
		return false;
	}
	
	return true;
}

function enviar_boletin(destino)
{
  
  document.forms[0].opcion.value=destino;  
  cnf=true;
  flag=false;
  
   if(Trim(document.forms[0].nomb.value)=="")
	{
	 alert("Vous devez saisir le nom de la newsletter");
	 document.forms[0].nomb.focus();
	 return false;
	}
  
	
  if(destino == "2")
  {
	  
	 if(Trim(document.forms[0].nomb.value)=="")
	{
	 alert("Vous devez saisir le nom de la newsletter");
	 document.forms[0].nomb.focus();
	 return false;
	}
	
	 if(document.getElementById('ra0').checked==true){
	 		//cnf=confirm("Etes-vous sûr de vouloir envoyer la newsletter à la liste sélectionnée ?");
		 cnf=confirm("Etes-vous sûr de vouloir envoyer la newsletter à la liste sélectionnée ?");
			
	 }else{
		 
		  if(Trim(document.forms[0].nomb.value)=="")
	{
	 alert("Vous devez saisir le nom de la newsletter");
	 document.forms[0].nomb.focus();
	 return false;
	}
	
	
		if(document.getElementById('ra1').checked==true){
			if((document.forms[0].mailb.value=="") || !validarEmail(Trim(document.forms[0].mailb.value))){
				alert('Vous devez entrer a valid email');
	  			document.forms[0].mailb.focus();
				document.forms[0].mailb.style.background='#FFFFCA';
	  			cnf=false;
			}
		}
	 }
		
	if(cnf)
	  document.forms[0].submit();
  }
  else
   document.forms[0].submit();
  
  
}
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("L'email est incorrect!");	
	}
}
function closePopUp(){
	setTimeout("window.close();",5000);
}
function delete_abonne(url){
	aviso="Vous souhaitez supprimer cet article de mon panier ?";
	if(confirm(aviso)){
		location.href='abonnement_etat.php?page=3&cmdDelete=1&'+url;	
	}
}

function delete_reservation(url){
	/*msg="De supprimer sûrement cette réserve ?"*/
	msg="Etes-vous sûr de vouloir annuler cette réservation ?"
	if(confirm(msg)){
		location.href='include/delete_reservation.php?cmdDelete=1&'+url;	
	}
}

function activa(n){
	if(n==1){
		document.getElementById("divshow").style.display='';	
	}else{
		document.getElementById("divshow").style.display='none';	
	}
}
function check_code_prepaye(){
	form=document.frmPrepago;
	
	codigo_prepago=form.txtCodeprepaye.value;
	codigo_partner=form.txtCpartner.value;
	
	/*codigo_prepago=document.getElementById("txtCodeprepaye").value;
	codigo_partner=document.getElementById("txtCpartner").value;*/
	
	//if((codigo_prepago=="Votre code prépayé" || codigo_prepago=="") && (codigo_partner=="Votre code partenaire" || codigo_partner=="")){
	//if((codigo_prepago=="Votre code prépayé") && (codigo_partner=="Votre code partenaire")){
		//if(codigo_prepago=="Votre code prépayé" || codigo_prepago==""){
			var flag1=1;
			var flag2=1;
		if(codigo_prepago=="Votre code prépayé" || codigo_prepago==""){
			alert("Le champ Votre code prépayé est obligatoire");
			flag1=0;
			return false;
		}
		if(codigo_partner=="Votre code partenaire" || codigo_partner==""){
			alert("Le champ Votre code partenaire est obligatoire");
			return false;
			flag2=0;
		}
	//}else{
		if(flag1 && flag2){
		cadena=codigo_prepago+","+codigo_partner;
		//alert(cadena);
		//jsrsExecute("./include/check_codeprepaye.php",end_check_code_prepaye,"confirmar",cadena);
		jsrsExecute("check_codeprepaye.php",end_check_code_prepaye,"confirmar",cadena);
		}
	//}
}
function end_check_code_prepaye(cadena){
	cadena=cadena.split("|");
	result=cadena[0];
	subscriptionId=cadena[1];
	resul_partner=subscriptionId=cadena[2];
	
	form=document.frmPrepago;
	if(result==1){//expirado
		alert("Code PRÉPAYÉ déjà expiré!");
	}else if(result==2){//usado	
		//alert("Compte existant, veuillez vous conecter avec votre adresse mail et votre mot de passe");
		alert("Ce code prépayé a déjà été utilisé. Veuillez vous identifier avec votre adresse email et mot de passe dans l'espace \"Vous êtes abonné\" ");
	}else if(result==3){//código prepago ok
		if(resul_partner>0){
			form.subscriptionId.value=subscriptionId;//todo ok
			form.submit();	
		}else{
			alert("Code partenaire incorrect!");
		}
	}else if(result==4){//no existe
		alert("Code PRÉPAYÉ incorrect!");
	}
}
function end_check_code_prepaye_17ene08(cadena){
	form=document.frmPrepago;
	if(cadena!=0){//ok
		form.subscriptionId.value=cadena;
		form.submit();
	}else{
		alert("Code PRÉPAYÉ incorrect!");
		form.txtCodeprepaye.select();
		return false;
	}
}


function return_pouce(){	
	document.location="coups_pouce.php";	
}

function end_reserve_pouce(){
	document.location="end_reserve_pouce.php?confirm=1";
}

function validaFormFree(){
	if(document.getElementById('cbo_day').value=='0' || document.getElementById('cbo_month').value=='0' || document.getElementById('cbo_year').value=='0000'){
		alert("Le champ \"Date limite\" est obligatorie");
		return false;
	}	
}

function validaFormFreeNew(){
	
	if(document.getElementById('cbo_user').value=='0'){
		alert("Le champ \"Member\" est obligatorie");
		document.getElementById('cbo_user').focus();
		document.getElementById('cbo_user').style.background='#FFFFCA';
		return false;
	}		
	
	if(document.getElementById('cbo_day').value=='0' || document.getElementById('cbo_month').value=='0' || document.getElementById('cbo_year').value=='0000'){
		alert("Le champ \"Date limite\" est obligatorie");
		return false;
	}	
}

function value_default(){
	if(document.getElementById('txtNumSubscription').value==0 || document.getElementById('txtNumSubscription').value==""){
		document.getElementById('txtNumSubscription').value=1;
	}
	if(document.getElementById('txtPlaces').value==0 || document.getElementById('txtPlaces').value==""){			
		document.getElementById('txtPlaces').value=1;
	}
}

function checkAboNew(flag){
	var flagsubmit=1;
	if(flag==0){
		if(document.getElementById('cboTypeAbono').value==0){
			alert("Le champ \"abonnement\" est obligatoire");
			document.getElementById('cboTypeAbono').focus();			
			return false;			
			flagsubmit=0;
		}
		
		if(document.getElementById('cbo_State1').value==0){
			alert("Le champ \"etat\" est obligatoire");
			document.getElementById('cbo_State1').focus();			
			return false;
			flagsubmit=0;
		}
	}
	if(flagsubmit==1){
		//alert("envio");
		document.frm01.submit();
	}
}

function checkAboEdit(flag){
	var flagsubmit=1;
	if(flag==0){
		if(document.getElementById('cboTypeAbono').value==0){
			alert("Le champ \"abonnement\" est obligatoire");
			document.getElementById('cboTypeAbono').focus();			
			return false;			
			flagsubmit=0;
		}	
	}
		
	if(document.getElementById('cboDay1').value==0){
		alert("Choisir Jour");
		document.getElementById('cboDay1').focus();
		return false;
		flagsubmit=0;
	}
	if(document.getElementById('cboMonth1').value==0){
		alert("Choisir Mois");
		document.getElementById('cboMonth1').focus();
		return false;
		flagsubmit=0;
	}
	if(document.getElementById('cboYear1').value==0){
		alert("Choisir Année");
		document.getElementById('cboYear1').focus();
		return false;
		flagsubmit=0;
	}
	
	if(document.getElementById('cboDayE').value==0){
		alert("Choisir Jour");
		document.getElementById('cboDayE').focus();
		return false;
		flagsubmit=0;
	}
	if(document.getElementById('cboMonthE').value==0){
		alert("Choisir Mois");
		document.getElementById('cboMonthE').focus();
		return false;
		flagsubmit=0;
	}
	if(document.getElementById('cboYearE').value==0){
		alert("Choisir Année");
		document.getElementById('cboYearE').focus();
		return false;
		flagsubmit=0;
	}
	
	if(document.getElementById('cboTypePay').value==""){
		alert("Le champ \"Mode de paiement\" est obligatoire");
		document.getElementById('cboTypePay').focus();
		return false;
		flagsubmit=0;
	}
	
	if(document.getElementById('cbo_State1').value==0){
		alert("Le champ \"etat\" est obligatoire");
		document.getElementById('cbo_State1').focus();			
		return false;
		flagsubmit=0;
	}
	
	if(document.getElementById('numplaces').value==0 || document.getElementById('numplaces').value==""){
		alert("Nombre de places est obligatoire");
		document.getElementById('numplaces').focus();
		return false;
		flagsubmit=0;
	}
	
	if(document.getElementById("ckPouce").checked==true){
		if(document.getElementById("txtNumCoups").value==""){
			alert("Nombre de places coups de pouce est obligatoire");
			document.getElementById("txtNumCoups").focus();
			return false;
			flagsubmit=0;
		}	
	}
	
	
	if(flagsubmit==1){
		//alert("envio");
		document.frm01.submit();
	}
}

function changeCodeParnert(){
	idPartner=document.getElementById("cbo_Partner").value;
	idUser=document.getElementById("idUser").value;
	idUserSubs=document.getElementById("idSubscriptionAbo").value;
	cadena=idUser+","+idPartner+","+idUserSubs;
	//alert(cadena);
	jsrsExecute("change_abo_partner.php",end_changeAbonnemetPartner,"confirmar",cadena);
}

function end_changeAbonnemetPartner(param){
	data=param;
	//alert(data);
	if(data==1)
		document.getElementById("msgChange").innerHTML=" Modifié! ";		
}

function jstype_reserve(){
	if(document.getElementById('type_reserve').value==1 || document.getElementById('type_reserve').value==0){
		document.getElementById('txtTarifa').value="0.00";
		document.getElementById('showCheck').style.display="none";
		document.getElementById('typePay').style.display="none";
		document.getElementById('chck').checked=true;
		document.getElementById('txtTotal').value="";
		//document.getElementById('txtNumReserve').value="";
		document.getElementById('cboTypePay').value="0";
	}else{
		if(document.getElementById("page_origen").value==1){
			idHour=document.getElementById('idHour').value;
		}else{
			idHour=document.getElementById('cboRepresentation').value;
		}
			
		type_rese=document.getElementById('type_reserve').value
		cadena=idHour+","+type_rese;
		
		jsrsExecute("price_representation.php",price_representation,"confirmar",cadena);
	}
}

function price_representation(param){
	//alert(param);
	datos=param.split("|");
	$price_tn=datos[0];
	$price_ta=datos[1];
	type_rese=document.getElementById('type_reserve').value
	
	if(type_rese==2){
		document.getElementById('txtTarifa').value=$price_ta;
	}else{
		document.getElementById('txtTarifa').value=$price_tn;
	}
	
	if(document.getElementById("page_origen").value==1){
		tot=document.getElementById('numReser').value*document.getElementById('txtTarifa').value;	
	}
	if(document.getElementById("page_origen").value==0){
		tot=document.getElementById('txtNumReserve').value*document.getElementById('txtTarifa').value;	
	}
	
	
	document.getElementById('txtTotal').value=tot;
		
	document.getElementById('showCheck').style.display="";
}

function submit_key(){
	if(event.keyCode==13){
		form=document.searchskey;
		form.submit();
	}
}

function contCaract(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}

function activaBtn(){
	cont=document.getElementById('RegTot').value;
	var num_check=0;
	for(i=0;i<cont;i++){
		if(document.getElementById("idHourChk"+i).checked){
			num_check++;
			document.getElementById("desactiver"+i).disabled="";
			document.getElementById("bloque"+i).disabled="";
			document.getElementById("delete"+i).disabled="";
			document.getElementById("pouce"+i).disabled="";
			
			document.getElementById("hh"+i).disabled="";
			document.getElementById("mm"+i).disabled="";
			document.getElementById("TN"+i).disabled="";
			document.getElementById("TA"+i).disabled="";
			document.getElementById("INV"+i).disabled="";
			
			document.getElementById("PrixTn"+i).disabled="";
			document.getElementById("PrixTa"+i).disabled="";
			
		}else{
			document.getElementById("desactiver"+i).disabled="true";
			document.getElementById("bloque"+i).disabled="true";
			document.getElementById("delete"+i).disabled="true";
			document.getElementById("pouce"+i).disabled="true";
			
			document.getElementById("hh"+i).disabled="true";
			document.getElementById("mm"+i).disabled="true";
			document.getElementById("TN"+i).disabled="true";
			document.getElementById("TA"+i).disabled="true";
			document.getElementById("INV"+i).disabled="true";
			
			document.getElementById("PrixTn"+i).disabled="true";
			document.getElementById("PrixTa"+i).disabled="true";
		}
	}
	if(num_check>0){
		document.getElementById("btnModifier").style.display="";
		document.getElementById("btnModifier2").style.display="";
	}else{
		document.getElementById("btnModifier").style.display="none";
		document.getElementById("btnModifier2").style.display="none";
		
		for (i=0;i<document.frmModifier.elements.length;i++){
			if(document.frmModifier.elements[i].type == "checkbox")	
				document.frmModifier.elements[i].checked=0
		}
	}
}

function formatTime(obj){
	string=document.getElementById(obj).value;

	if(string.length==1){
		document.getElementById(obj).value="0"+string;
	}
	if(string=="" || string=="00"){
		alert("Le champ es obligatoire");
		document.getElementById(obj).focus();
	}
}

function check(obj1,obj2,obj3,permission){
	if(document.getElementById(obj1).checked){
		document.getElementById(obj2).checked="";
		if(permission==3){
			document.getElementById(obj3).checked="";
		}
	}
}

function placeReservable(){
	idProduct=document.getElementById('idProduct').value;
	numReserver=document.getElementById('numPlaceReservable').value;		
	cadena=idProduct+","+numReserver;
	jsrsExecute("add_num_reserver.php",end_add_num_reserver,"confirmar",cadena);	
}

function end_add_num_reserver(param){
	// NO BORRAR ESTA FUNCION ES IMPORTANTE	
}

//#@funcion que compara dos fechas 
   function esDigito(sChr){  
    var sCod = sChr.charCodeAt(0);  
    return ((sCod > 47) && (sCod < 58));  
   }  

   function valSep(oTxt){  
    var bOk = false;  
    bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));  
    bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));  
    return bOk;  
   }  

   function finMes(oTxt){  
    var nMes = parseInt(oTxt.value.substr(3, 2), 10);  
    var nAno = parseInt(oTxt.value.substr(6), 10);  
    var nRes = 0;  
    switch (nMes){  
     case 1: nRes = 31; break;  
     case 2: nRes = 28; break;  
     case 3: nRes = 31; break;  
     case 4: nRes = 30; break;  
     case 5: nRes = 31; break;  
     case 6: nRes = 30; break;  
     case 7: nRes = 31; break;  
     case 8: nRes = 31; break;  
     case 9: nRes = 30; break;  
     case 10: nRes = 31; break;  
     case 11: nRes = 30; break;  
     case 12: nRes = 31; break;  
    }  
    return nRes + (((nMes == 2) && (nAno % 4) == 0)? 1: 0);  
   }  

   function valDia(oTxt){  
    var bOk = false;  
    var nDia = parseInt(oTxt.value.substr(0, 2), 10);  
    bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));  
    return bOk;  
   }  

   function valMes(oTxt){  
    var bOk = false;  
    var nMes = parseInt(oTxt.value.substr(3, 2), 10);  
    bOk = bOk || ((nMes >= 1) && (nMes <= 12));  
    return bOk;  
   }  

   function valAno(oTxt){  
    var bOk = true;  
    var nAno = oTxt.value.substr(6);  
    bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));  
    if (bOk){  
     for (var i = 0; i < nAno.length; i++){  
      bOk = bOk && esDigito(nAno.charAt(i));  
     }  
    }  
    return bOk;  
   }  

   function valFecha(oTxt){  
    var bOk = true;  
    if (oTxt.value != ""){  
     bOk = bOk && (valAno(oTxt));  
     bOk = bOk && (valMes(oTxt));  
     bOk = bOk && (valDia(oTxt));  
     bOk = bOk && (valSep(oTxt));  
     return bOk;  
    }  
   }  

   function fechaMayorOIgualQue(fec0, fec1){  
    var bRes = false;  
    var sDia0 = fec0.value.substr(0, 2);  
    var sMes0 = fec0.value.substr(3, 2);  
    var sAno0 = fec0.value.substr(6, 4);  
    var sDia1 = fec1.value.substr(0, 2);  
    var sMes1 = fec1.value.substr(3, 2);  
    var sAno1 = fec1.value.substr(6, 4);  
    if (sAno0 > sAno1) bRes = true;  
    else {  
     if (sAno0 == sAno1){  
      if (sMes0 > sMes1) bRes = true;  
      else {  
       if (sMes0 == sMes1)  
        if (sDia0 >= sDia1) bRes = true;  
      }  
     }  
    }  
    return bRes;  
   }  

   function valFechas(ruta){  
    var bOk = false;  
    if (valFecha(document.frmBusqueda.textDate)){  
     if (valFecha(document.frmBusqueda.textDate2)){  
      if (fechaMayorOIgualQue(document.frmBusqueda.textDate2, document.frmBusqueda.textDate)){  
       bOk = true;  
       //alert("Ok la fecha ");  
	   /// todo esta ok comparacion de los datos 
		var propControl = new Array();
		debecontar=0;
		contar=0;
		validar=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;
						}
					}
				}
			}
      } else {  
       alert("Le rang de dates est incorrect");  
       document.frmBusqueda.textDate2.focus();
	   return false;  
      }  
     } else {  
      alert("Date incorrecte");  
      document.frmBusqueda.textDate2.focus();  
	  return false; 
     }  
    } else {  
     alert("Date incorrecte");  
     document.frmBusqueda.textDate.focus(); 
	 return false; 
    } 
	
   }  
//#@ fin de la funcion que compara dos fechas 

function keyPressLogin(e){
	//alert(event.keyCode);
	//document.getElementById("btn_enviar").disabled="true";
	tecla=(document.all)?(event.keyCode):(e.which);

	if(tecla==13){
		checkLoginAbonne2();
	}
}
function keyPressParner(e){
	//alert(event.keyCode);
	//document.getElementById("btn_enviar").disabled="true";
	tecla=(document.all)?(event.keyCode):(e.which);

	if(tecla==13){
		check_code_prepaye();
		//document.frmPrepago.submit();
	}
}
function keyPressGuest(e){
	//alert(event.keyCode);
	//document.getElementById("btn_enviar").disabled="true";
	tecla=(document.all)?(event.keyCode):(e.which);

	if(tecla==13){
		guest();
	}
}

function guest(){
	if(document.getElementById("txtEmailguest").value=="Votre email"){
		alert("Le champ \"Email\" est obligatorie");
		document.getElementById("txtEmailguest").value="";
		document.getElementById("txtEmailguest").focus();
		return false;
	}else{
		//alert(emailCheck(document.getElementById("txtEmail").value));
		if(emailCheck(document.getElementById("txtEmailguest").value)==0){
			alert("Votre email n'est pas valide");
			document.getElementById("txtEmailguest").focus();
			document.getElementById("txtEmailguest").style.background="#FFFF99";
			return false;
		}else{
			mail=document.getElementById("txtEmailguest").value;
			popup("popup_guest.php?email_visite="+mail,"380","158");
			//cadena=document.getElementById("txtEmailguest").value;
			//jsrsExecute("./include/add_guest.php",end_guest,"confirmar",cadena);	
		}
	}	
}
function check_simple_visite(){	
	var yesno;
	var mail;
	mail=document.getElementById("txtEmailguest_").value;	
	if(document.getElementById("rbYesNo0").checked==true || document.getElementById("rbYesNo1").checked==true){
		if(document.getElementById("rbYesNo0").checked==true){
			yesno=document.getElementById("rbYesNo0").value;			
		}
		if(document.getElementById("rbYesNo1").checked==true){
			yesno=document.getElementById("rbYesNo1").value;
		}
		cadena=mail+","+yesno;
		jsrsExecute("./include/add_guest.php",end_guest,"confirmar",cadena);
	}else{
		alert("Merci de bien vouloir spécifier si vous souhaitez recevoir des ventes flashs de spectacles.");	
	}
}

function end_guest(param){
	//form=document.frmGuest;		
	//form.submit();
	window.opener.location.href="../index1.php";
	window.close();
}

function show_msg_guest(){
	document.getElementById('msgGuest').style.display='';
	setTimeout("end_guest(0)",30000);
}

function checkLoginAbonne2(){
	var oklogin=true;
	var okpass=true;
	if(document.getElementById("txtLogin").value=="Email"){		
		alert("Le champ \"Email\" est obligatorie");
		document.getElementById("txtLogin").value="";
		document.getElementById("txtLogin").focus();
		return false;
		oklogin=false;
	}
	if(document.getElementById("txtPassword").value=="Votre mot de passe"){
		alert("Le champ \"Mot de passe\" est obligatorie");
		document.getElementById("txtPassword").value="";
		document.getElementById("txtPassword").focus();
		return false;
		okpass=false;
	}
	
	if(oklogin && okpass){
		var cadena=document.getElementById("txtLogin").value+","+document.getElementById("txtPassword").value;

		jsrsExecute("./include/check_login_index.php",end_login_index,"confirmar",cadena);
	}
}

function end_login_index(param){

	form=document.frmLogin;

	data=param.split("|");	
	loginOk=data[0];
	
	document.getElementById('errorLogin').style.display='none';
	document.getElementById('errorPass').style.display='none';
	
	if(loginOk==1){
		form.submit();
	}else{
		if(loginOk==0){
			document.getElementById('errorLogin').style.display='';
			setTimeout("divLogin(0)",4000);
		}
		if(loginOk==2){
			document.getElementById('errorPass').style.display='';
			setTimeout("divLogin(0)",4000);
		}
	}	
}

function divLogin(pag){
	
	if(pag==0){
		document.getElementById('errorPass').style.display='none';
		document.getElementById('errorLogin').style.display='none';
		document.getElementById("txtLogin").value="Email"
		document.getElementById("txtPassword").value="Votre mot de passe";
		document.getElementById("txtLogin").focus();
	}else{
		
		// esto es de la parte del admin players_videobillets
		
		document.getElementById("slt_idProdtypeUp").disabled=false; 
		document.getElementById("slt_idProdtypeDown").disabled=false; 
		document.getElementById("slt_idSpectacle").disabled=false; 
		document.getElementById('errorLogin').style.display='none';	
	}
}

function disabled_control(){
	document.getElementById("slt_idProdtypeUp").disabled=true; 
	document.getElementById("slt_idProdtypeDown").disabled=true; 
	document.getElementById("slt_idSpectacle").disabled=true;	
}

function show_form_abo(e){
	
	if(document.getElementById('cboUser').value!="" && e==1){
		document.getElementById('frmAbo').style.display="";
	}else{
		document.getElementById('frmAbo').style.display="none";
		document.getElementById('cbo_Partner').value="";
		document.getElementById('numPlaces').value="";
		//byId('txtVersion').value="";
		document.getElementById('txtDuration').value="";
		document.getElementById('txtMonto').value="";
	}
}

function submit_form(){
	if(document.getElementById('cboUser').value==""){
		alert("Le champ \"abonné\" est obligatorie");
		document.getElementById('cboUser').focus();
	}else{
		if(document.getElementById('cboTypeAbono').value==0){
			alert("Le champ \"Abonnement\" est obligatorie");	
		}
		if(document.getElementById('numplaces').value=="" || document.getElementById('numplaces').value==0){
			alert("Le champ \"Nombre de places\" est obligatorie");
			document.getElementById('numplaces').focus();
			return false;
		}
		if(document.getElementById('txtDuration').value=="" || document.getElementById('txtDuration').value==0){
			alert("Le champ \"Durée d'abonnement\" est obligatorie");
			document.getElementById('txtDuration').focus();
			return false;
		}
		if(document.getElementById('txtMonto').value=="" || document.getElementById('txtMonto').value==0){
			alert("Le champ \"Montant de l'abonnement\" est obligatorie");
			document.getElementById('txtMonto').focus();
			return false;
		}
		if(document.getElementById('cboTypePay').value==""){
			alert("Le champ \"Type de Paiement\" est obligatorie");
			document.getElementById('cboTypePay').focus();
			return false;
		}
		
		if(document.getElementById("ckPouce").checked==true){
			if(document.getElementById("txtNumCoups").value==""){
				alert("Nombre de places coups de pouce est obligatoire");
				document.getElementById("txtNumCoups").focus();
				return false;				
			}	
		}
		document.frm01.submit();
	}	
}

function check_user_abono(){
	var idUser;	
	idUser=document.getElementById('cboUser').value;
	cadena=idUser;
	jsrsExecute("check_user_abono.php",end_check_user_abono,"confirmar",cadena);
}

function end_check_user_abono(param){
	data=param.split("|");
	var idUser=document.getElementById('cboUser').value;
	
	if(data==1){
		//alert("Ce membre n'est pas actuellement abonné \nmais a déjà demandé un abonnement actuellement en attente.\n\nIl n'est pas possible de l'abonner.");
		location.href='abonnement_actuel2.php?userId='+idUser+'&link06=on&linktit01=on';
		//show_form_abo(0);
	}else{
		//show_form_abo(1);
	}
}

function show_data_abonnement(){
	var idAbono;
	idAbono=document.getElementById('cboTypeAbono').value;
	cadena=idAbono;
	jsrsExecute("show_data_abonnement.php",end_show_data_abonnement,"confirmar",cadena);	
}

function end_show_data_abonnement(param){
	data=param.split("|");
	price=data[0];
	duration=data[1];
	places=data[2];
	version=data[3];
	typeIdFour=data[4];				
	
	document.getElementById('numplaces').value=places;
	document.getElementById('txtDuration').value=duration;
	document.getElementById('txtMonto').value=price;
	document.getElementById('txtMontoTotal').value=price;
	document.getElementById('txtReduccion').value="0.00";
	
	if(typeIdFour!=1){
		document.getElementById('txtDuration').readOnly=true;
		document.getElementById('txtMonto').readOnly=true;
		document.getElementById('numplaces').readOnly=true;
	}else{
		document.getElementById('txtDuration').readOnly=false;
		document.getElementById('txtMonto').readOnly=false;
		document.getElementById('numplaces').readOnly=false;
	}
		
}

function calculaMonto(){
	
	var monto;
	
	if(parseFloat(document.getElementById('txtReduccion').value)<=parseFloat(document.getElementById('txtMonto').value)){
		monto=document.getElementById('txtMonto').value-document.getElementById('txtReduccion').value;	
		document.getElementById('txtMontoTotal').value=monto;
	}else{
		alert("La remise doit être plus que le champ montant");	
		document.getElementById('txtReduccion').value="";
		document.getElementById('txtMontoTotal').value=document.getElementById('txtMonto').value;
	}
}

function checkonkeypress(e,num_punto){
	tecla=(document.all)?(event.keyCode):(e.which);
	if (tecla==8) return true;
	if(num_punto==""){		
		patron = /\d/;
		te = String.fromCharCode(tecla);
		//alert(patron.test(te));
		return patron.test(te);
	}else{
		if (tecla < 45 || tecla > 57){
			return false;	
		}else{
			return true;	
		}
	}
}

function copy_data_texbox(){
	var flag=true;
	var pt;
	var ta;
	var inv;
	var prixpt;
	var prixta;
	var hr;
	var minn;
	var secondblock;
	
	for(j=1; j<8; j++){		
		if(document.getElementById("chk"+j).checked==true){
			
			if(flag){												
				
				hr=document.getElementById("cbo_Hr"+j).value;
				minn=document.getElementById("cbo_Min"+j).value;
				
				pt=document.getElementById("txtQuotan"+j).value;
				ta=document.getElementById("txtQuota"+j).value;
				inv=document.getElementById("txtQuotai"+j).value;
				prixpt=document.getElementById("prix_tn"+j).value;
				prixta=document.getElementById("prix_ta"+j).value;
				
				if(document.getElementById("cbo2_Hr"+j).value!="" && document.getElementById("txtQuotai2"+j).value!="" && document.getElementById("prix_tn2"+j).value!="" && document.getElementById("prix_ta2"+j).value!=""){
					
					hr2=document.getElementById("cbo2_Hr"+j).value;
					minn2=document.getElementById("cbo2_Min"+j).value;
					
					pt2=document.getElementById("txtQuotan2"+j).value;
					ta2=document.getElementById("txtQuota2"+j).value;
					inv2=document.getElementById("txtQuotai2"+j).value;
					prixpt2=document.getElementById("prix_tn2"+j).value;
					prixta2=document.getElementById("prix_ta2"+j).value;
					
					secondblock=true;					
					
				}else{
					secondblock=false;	
				}
				
				flag=false;
			}else{
				document.getElementById("cbo_Hr"+j).value=hr;
				document.getElementById("cbo_Min"+j).value=minn;
				
				document.getElementById("txtQuotan"+j).value=pt;
				document.getElementById("txtQuota"+j).value=ta;
				document.getElementById("txtQuotai"+j).value=inv;
				document.getElementById("prix_tn"+j).value=prixpt;
				document.getElementById("prix_ta"+j).value=prixta;
				
				if(secondblock){
					document.getElementById("cbo2_Hr"+j).value=hr2;
					document.getElementById("cbo2_Min"+j).value=minn2;
					
					document.getElementById("txtQuotan2"+j).value=pt2;
					document.getElementById("txtQuota2"+j).value=ta2;
					document.getElementById("txtQuotai2"+j).value=inv2;
					document.getElementById("prix_tn2"+j).value=prixpt2;
					document.getElementById("prix_ta2"+j).value=prixta2;
				}
			}
		}else{
			document.getElementById("cbo_Hr"+j).value="0";
			document.getElementById("cbo_Min"+j).value="0";
			document.getElementById("txtQuotan"+j).value="";
			document.getElementById("txtQuota"+j).value="";
			document.getElementById("txtQuotai"+j).value="";
			document.getElementById("prix_tn"+j).value="";
			document.getElementById("prix_ta"+j).value="";
				
			document.getElementById("cbo2_Hr"+j).value="0";
			document.getElementById("cbo2_Min"+j).value="0";
			
			document.getElementById("txtQuotan2"+j).value="";
			document.getElementById("txtQuota2"+j).value="";
			document.getElementById("txtQuotai2"+j).value="";
			document.getElementById("prix_tn2"+j).value="";
			document.getElementById("prix_ta2"+j).value="";
		}		
	}
}

function check_newPeriod(){
	var chkc=0;
	for(i=1; i<8; i++){
		if(document.getElementById("chk"+i).checked==false){
			chkc=chkc+1;
		}
	}
	if(chkc==7){
		alert("Veuillez sélectionner les jours");
		return false;
	}
		//--------------------------------------------
	
	for(j=1; j<8; j++){
		if(document.getElementById("chk"+j).checked==true){
			
			if(document.getElementById("cbo_Hr"+j).value=='0' && document.getElementById("cbo2_Hr"+j).value=='0'){
				alert("Vous devez entrer l\'heure de début du spectacle");
				document.getElementById("cbo_Hr"+j).focus();
				return false;
			}
				
			if(document.getElementById("cbo_Hr"+j).value!='0'){
					
				if(document.getElementById("txtQuotai"+j).value==""){
					alert("Vous devez spécifier le nombre de places disponibles");
					document.getElementById("txtQuotai"+j).focus();
					return false;
				}
			}
				
			if(document.getElementById("cbo2_Hr"+j).value!='0'){
				
				if(document.getElementById("txtQuotai2"+j).value==""){
					alert("Vous devez spécifier le nombre de places disponibles");
					document.getElementById("txtQuotai"+j).focus();
					return false;
				}
			}
				
			if((document.getElementById("cbo_Hr"+j).value==document.getElementById("cbo2_Hr"+j).value) && (document.getElementById("cbo_Hr"+j).value!='0' && document.getElementById("cbo2_Hr"+j).value!='0')){
					alert("Attention : horaires identiques");
					return false;
			}
				
		}
	}

	if(document.getElementById("chk1").checked==true){
		chckL=1;
	}else{
		chckL="";
	}
	if(document.getElementById("chk2").checked==true){
		chckM=1;
	}else{
		chckM="";
	}
	if(document.getElementById("chk3").checked==true){
		chckMi=1;
	}else{
		chckMi="";
	}
	if(document.getElementById("chk4").checked==true){
		chckJ=1;
	}else{
		chckJ="";
	}
	if(document.getElementById("chk5").checked==true){
		chckV=1;
	}else{
		chckV="";
	}
	if(document.getElementById("chk6").checked==true){
		chckS=1;
	}else{
		chckS="";
	}
	if(document.getElementById("chk7").checked==true){
		chckD=1;
	}else{
		chckD="";
	}
	
	dateLast=document.getElementById("dateLast").value;
	
	dateB=document.getElementById("txtDateBegin").value;
	dateE=document.getElementById("txtDateEnd").value;
	
	dateLastD=putDateNum(dateLast,"/");
	dateBD=putDateNum(dateB,"/");
	dateED=putDateNum(dateE,"/");
		
	/*dateLastD=new Date(dateLast);
	dateBD=new Date(dateB);
	dateED=new Date(dateE);*/
	
	/*if(dateLastD>=dateBD){
		alert("Dates incorrectes");
		return false;
	}*/
	if(dateBD>dateED){
		alert("La date de fin de représentation ne peut être antérieure à la date de début");
		return false;
	}
	
	idProduct=document.getElementById("idProduct").value;
	
	//if(dateBD>dateLastD && dateED>=dateBD){
	if(dateED>=dateBD){
		cadena1=","+idProduct+",,"+dateB+","+dateE+","+chckL+","+chckM+","+chckMi+","+chckJ+","+chckV+","+chckS+","+chckD+",1000";		
		// Esto verifica si en el rango de fecha se encuentra los dias seleccionados.
		jsrsExecute("check_date_spectacle.php",end_check_newPeriod,"confirmar",cadena1);	
	}
}

function putDateNum(date,sep){
	//date=dd/mm/aaaa
	date=date.split(sep);
	date=date[2]+""+date[1]+""+date[0];
	return parseInt(date);
}

function end_check_newPeriod(param){
	form=document.frmRegister;
	
	data=param.split("|");
	//data=param;
	//person=data[0];
	spectacle=data[0];
	lieuVenue=data[1];		
	//alert(spectacle);
	//if(person==1 && spectacle==1){	
	//if(data[9]=="1000"){
		var msg=0;
		var lunes,martes,miercoles,jueves,viernes,sabado,domingo;		
		if(data[2]==1){
			lunes="Lundi, ";	
			msg=1;
		}else{
			lunes="";
		}
		if(data[3]==1){
			martes="Mardi, ";
			msg=1;
		}else{
			martes="";	
		}
		if(data[4]==1){
			miercoles="Mercredi, ";	
			msg=1;
		}else{
			miercoles="";	
		}
		if(data[5]==1){
			jueves="Jeudi, ";
			msg=1;
		}else{
			jueves="";	
		}
		if(data[6]==1){
			viernes="Vendredi, ";
			msg=1;
		}else{
			viernes="";	
		}
		if(data[7]==1){
			sabado="Samedi, ";
			msg=1;
		}else{
			sabado="";	
		}
		if(data[8]==1){
			domingo="Dimanche, ";
			msg=1;
		}else{
			domingo="";	
		}
		var dias;
		dias=lunes+martes+miercoles+jueves+viernes+sabado+domingo;
		var lendias=dias.length;
		dias=dias.substr(0,dias.length-2);
		if(msg=="1"){
			alert("Pas de "+dias+" sur la période de quotas définie");
			return false;
		}else{
			form=document.frmRegister;
			form.submit();
		}		
}

function showFormVideobillets(page){
	var msgErr="Debe seleccionar un video";
	if('new'){
		if(document.getElementById('video').value!=""){
			document.getElementById('showFormVideos').style.display='';
		}else{
			alert(msgErr);
			document.getElementById('showFormVideos').style.display='none';
		}
	}else{ //edit
		if(document.getElementById('file_video').value!=""){
			document.getElementById('showFormVideos').style.display='';
		}
	}
}

function submit_Up(){
	
	document.getElementById("show_iframe").style.display="none";
	
	if(document.getElementById('slt_idProdtypeUp').value==0){
		
		// LIMPIAMOS LOS COMBOS----------------------------------------
		long=document.getElementById('slt_idProdtypeDown').length;	
		long1=document.getElementById('slt_idSpectacle').length;
		
		for(x=0; x < long; x++) {	
			document.getElementById("slt_idProdtypeDown").options[0]= null;
		}
		
		for(x=0; x < long1; x++) {	
			document.getElementById("slt_idSpectacle").options[0]= null;
		}
		//-------------------------------------------------------------
		// OCULTAMOS LOS ID DE LOS TR
		document.getElementById("tr_down").style.display='none';
		document.getElementById("tr_spect").style.display='none';
		// OCULTA EL DIV QUE CONTIENE AL IFRAME
		document.getElementById("show_iframe").style.display="none";
		
	}else{
		document.getElementById("tr_down").style.display='';
		document.getElementById("show_iframe").style.display="none";
		idProdtypeUp=document.getElementById('slt_idProdtypeUp').value;
		cadena=idProdtypeUp;
		jsrsExecute("get_prodtype.php",end_submit_Up,"confirmar",cadena);		
	}
}
function end_submit_Up(param){
	datos=param.split("|");
	
	id=datos[0].split(",");
	nb=datos[1].split(",");
	
	cid=id.length;		
	
	long=document.getElementById('slt_idProdtypeDown').length;
	
	for(x=0; x < long; x++) {	
		document.getElementById("slt_idProdtypeDown").options[0]= null;
	}
	
	for(x=0; x < cid-1; x++) {
		otraopcion=new Option(nb[x],id[x]);
		document.getElementById("slt_idProdtypeDown").options[x]= otraopcion;
	}
}

function submit_down(){
	
	document.getElementById("show_iframe").style.display="none";
	
	if(document.getElementById('slt_idProdtypeDown').value==0){
		long=document.getElementById('slt_idSpectacle').length;
		for(x=0; x < long; x++) {	
			document.getElementById("slt_idSpectacle").options[0]= null;
		}
		document.getElementById("tr_spect").style.display='none';
	}else{
		idProdtypeDown=document.getElementById('slt_idProdtypeDown').value;	
		idProdtypeUp=document.getElementById('slt_idProdtypeUp').value;
		cadena=idProdtypeUp+","+idProdtypeDown;
		//document.getElementById("idProdtypeDown_hidden").value=idProdtypeDown;
		document.getElementById("tr_spect").style.display='';		
		document.getElementById("show_iframe").style.display="none";
		jsrsExecute("getSpectacle.php",end_submit_down,"confirmar",cadena);
	}
}

function end_submit_down(param){
	datos=param.split("|");
	
	id=datos[0].split("*");
	nb=datos[1].split("*");
	
	cid=id.length;			
	
	long=document.getElementById('slt_idSpectacle').length;
	
	for(x=0; x < long; x++) {	
		document.getElementById("slt_idSpectacle").options[0]= null;
	}
	
	for(x=0; x < cid-1; x++) {
		otraopcion=new Option(id[x]+"-"+nb[x],id[x]);
		document.getElementById("slt_idSpectacle").options[x]= otraopcion;
	}
}




function formatoTelefono(fono){
	var slap1=false; 
	var slap2=false; 
	var slap3=false;
	var slap4=false;

	var long = fono.length; 
	var num1; 
	var num2; 
	var num3; 
	var num4;
	var num5;
	
	var t=0;
	if(long==1){
		num1=fono;
		if(IsNumeric(num1)==false)
			fono="";
	}
	
	if((long>=2) && (slap1==false)){
		num1=fono.substr(0,2);
		
		if((IsNumeric(num1)==true) && (num1!="00")){
			fono=fono.substr(0,2)+"."+fono.substr(3,11); slap1=true; 
		}else{
			slap1=false; fono="";
		}
	}
	if((long>=5) && (slap2==false)){
		num2=fono.substr(3,2);
		if(IsNumeric(num2)==true){
			fono=fono.substr(0,5)+"."+fono.substr(6,8); slap2=true; 
		}else{
			fono=fono.substr(0,3);
			slap2=false;
		}
	}
	if((long>=8) && (slap3==false)){
		num3=fono.substr(6,2);
		if(IsNumeric(num3)==true){
			fono=fono.substr(0,8)+"."+fono.substr(9,5); slap3=true; 
		}else{
			fono=fono.substr(0,6);
			slap3=false;
		}
	}
	if((long>=11) && (slap4==false)){
		num4=fono.substr(9,2);
		if(IsNumeric(num4)==true){
			fono=fono.substr(0,11)+"."+fono.substr(12,2); slap4=true; 
		}else{
			fono=fono.substr(0,9);
			slap4=false;
		}		
	}	
	if((long>=14)){
		num5=fono.substr(14,2);	
		if(IsNumeric(num5)==true){
			fono=fono.substr(0,14); t=1;
		}else{
			fono=fono.substr(0,12);	
		}
	}
	return (fono);
}	

function check_all_delete(){
	var total_check=document.getElementById('RegTot').value;
	for(i=0; i<total_check; i++){
		if(document.getElementById('delete'+i).checked==false){
			document.getElementById('delete'+i).checked=true;
			document.getElementById('check_delete').src='../images/btn_aucun.gif';
			document.getElementById('check_delete2').src='../images/btn_aucun.gif';
		}else{
			document.getElementById('delete'+i).checked=false;
			document.getElementById('check_delete').src='../images/btn_tous_check.gif';
			document.getElementById('check_delete2').src='../images/btn_tous_check.gif';
		}
	}
}
function close_popup(seconds){
	setTimeout(window.close(),seconds);
}

function activaFamillie(valor,idProduct){
	cadena=valor+","+idProduct;
	//alert(cadena);
	jsrsExecute("activarFamille.php",end_activaFamillie,"confirmar",cadena);	
}
function end_activaFamillie(param){
	data=param;
	if(data==1 || data==0){
		alert("opération effectuée");	
	}
}

function quotas_one_to_ten(value,id){	
	var va;
	if(IsNumeric(value)==true){		
		if(value>=1 && value<=10){			
			return true;
		}else{
			va=value.substr(0,1);
			document.getElementById(id).value=va;
		}
	}else{		
		document.getElementById(id).value="";
		return false;
	}
}
function valider_vente_flash(){
	date=document.getElementById("cboDate").value;
	cant=new Array();
	for(i=1;i<=7;i++){
		if(document.getElementById("txtCant"+i)){
			cant[i]=document.getElementById("txtCant"+i).value;
		}else{
			cant[i]=0;
		}	
	}
	total_vacios=0;
	for(i=1;i<=7;i++){
		if(cant[i]=="" || cant[i]==0){
			total_vacios++;
		}
	}
	if(date==0){
		alert(" Vous devez choisir une date! ");
		document.getElementById("cboDate").focus();
		return false;
	}else{
		if(total_vacios==7){
			alert(" Vous devez insérer au moins une quantité valable! ");
			return false;
		}else{
			document.frm_vente_flash.submit();	
		}
	}
}
function valider_vente_oferta(){
	date=document.getElementById("cboDate").value;
	cant=new Array();
	for(i=1;i<=7;i++){
		if(document.getElementById("txtCant"+i)){
			cant[i]=document.getElementById("txtCant"+i).value;
		}else{
			cant[i]=0;
		}	
	}
	total_vacios=0;
	for(i=1;i<=7;i++){
		if(cant[i]=="" || cant[i]==0){
			total_vacios++;
		}
	}
	if(date==0){
		alert(" Vous devez choisir une date! ");
		document.getElementById("cboDate").focus();
		return false;
	}else{
		if(total_vacios==7){
			alert(" Vous devez insérer au moins une quantité valable! ");
			return false;
		}else{
			document.frm_vente_flash.submit();	
		}
	}
}
function stock_vente_flash(value,restoStock,id){
	
	if(IsNumeric(value)==true){	
		if(value>restoStock){
			alert("Vous devez mettre max. "+restoStock+" places");
			document.getElementById(id).value="";
			document.getElementById(id).focus();
			return false;
		}
	}else{		
		document.getElementById(id).value="";	
		return false;
	}
	
}
function check_reserve_famille(num_reserve,famille){
	if(famille==1){
		if(num_reserve!=0){
			placesDisp=document.getElementById("placesDisp").value;
			if(num_reserve > placesDisp){
				alert("Nous sommes désolés votre abonnement ne vous permet pas de réserver des places famille");
				document.getElementById("sltReserve").options[0].selected=true;
			}
		}
	}
}
function calcular_oferta(txtoferta,txtcant){
	document.getElementById(txtoferta).value=(document.getElementById(txtcant).value);
}
function show_button_confirm_vente(option){
	if(option.checked==true){
		document.getElementById("cmdBuy").style.display='none';
		document.getElementById("cmdBuy2").style.display='';
	}else{
		document.getElementById("cmdBuy").style.display='';
		document.getElementById("cmdBuy2").style.display='none';
	}
}

function confirm_vente(){
	conditions=document.getElementById("chkConditions").checked;
	if(conditions==false){
		alert("Vous devez accepter les conditions générales de vente");
		return true;
		
	}	
}

function alert_visit_simple(){
	//alert('Veuillez contacter votre CE  pour pouvoir vous abonner, merci.'); 
	//alert('Nous vous invitons à contacter votre CE pour vous abonner, merci');
	alert("Vous devez être membre du club ou être parrainé pour accéder à l’ensemble du site.\nEn cas de problème, merci de nous contacter à cette adresse : sos@visioscene.com");
}

function show_data_flash(productid,dateflashid,page){
	if(dateflashid){
		if(page==1){
			location.href="target_vente_flash.php?idProduct="+productid+"&dateflashId="+dateflashid;
		}else{
			location.href="target_vente_oferta.php?idProduct="+productid+"&dateflashId="+dateflashid;
		}
		
	}
}

/* FUNCIONES PARA VENTE FLASH Y 1+1 livraison */
function operation(typeOpe,row){
	totRow=document.getElementById('totRow').value; // Total de productos
	tva=document.getElementById('tvac').value;	
	prodDefault=1; // por defecto se muestra una unidad por producto
	if(typeOpe=='sum'){
		//for(i=0; i<totRow; i++){
			//if(document.getElementById('idProd'+row).checked==true){
				qDispo=document.getElementById('qDispo'+row).value;				
				cant=parseInt(document.getElementById('quantity'+row).value)+1;
				if(qDispo>=cant){
					document.getElementById('quantity'+row).value=cant;
					document.getElementById('cant'+row).innerHTML=cant;
					tot_ttc=cant*document.getElementById('prixUni'+row).value;
					tot_tct=putDec(tot_ttc,2);
					// DIV TTC
					document.getElementById('ttc'+row).innerHTML=tot_ttc+" &euro;";
					// hidden TTC
					document.getElementById('ttc_total'+row).value=tot_ttc;
					// DIV del HT
					ht=tot_ttc/tva;
					ht=putDec(ht,2);
					
					document.getElementById('ht'+row).innerHTML=ht+" &euro;";
				}/*else{
					alert("La cantidad a agregar es superior al stock disponible");
				}*/
			//}else{
				//alert("Vous devez choisir un produit");
				//return false;
			//}
		//}
	}
	if(typeOpe=='rest'){
		//for(i=0; i<totRow; i++){
			//if(document.getElementById('idProd'+row).checked==true){				
				cant=parseInt(document.getElementById('quantity'+row).value)-1;
				if(cant>=0){
					document.getElementById('quantity'+row).value=cant;
					document.getElementById('cant'+row).innerHTML=cant;
					tot_ttc=cant*document.getElementById('prixUni'+row).value;
					tot_tct=putDec(tot_ttc,2);
					// DIV TTC
					document.getElementById('ttc'+row).innerHTML=tot_ttc+" &euro;";
					// hidden TTC
					document.getElementById('ttc_total'+row).value=tot_ttc;
					// DIV del HT
					ht=tot_ttc/tva;
					ht=putDec(ht,2);
					//ht=length
					document.getElementById('ht'+row).innerHTML=ht+" &euro;";					
				}/*else{
					alert("La cantidad a agregar no debe ser cero");
				}*/
			/*}else{
				alert("Vous devez choisir un produit");	
				return false;
			}*/
		//}
	}
}

function valide_ma_commande(){
	form=document.frmcartflash
	totRow=document.getElementById('totRow').value; // Total de productos
	numDeschk=0;
	/*for(i=0; i<totRow; i++){
		if(document.getElementById('idProd'+i).checked==false){
			numDeschk++;
		}
	}*/
	for(i=0; i<totRow; i++){
		if(document.getElementById('quantity'+i).value=='0'){
			numDeschk++;
		}
	}
	if(numDeschk==totRow){
		alert("Vous devez choisir au moins un produit");	
		return false;
	}else{
		form.submit();	
	}
}

// JavaScript Document para ajax

function XHConn()
{
  var xmlhttp, bComplete = false;
  try { 
  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
  }
  catch (e) { 
  	try { 
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
  	catch (e) { 
		try { 
			xmlhttp = new XMLHttpRequest(); 
		}
  		catch (e) { 
			xmlhttp = false; 
		}
	}
  }
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);
        }
	  };
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

var myConn = new XHConn();

if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

var end_save_data_facturacion = function (oXML){ 
	document.getElementById('div_ConfirmarDataUser').innerHTML = oXML.responseText;
	document.getElementById('btnsAction').style.display='';
	document.getElementById('checkAccepteCond').style.display='';
};

function save_data_facturacion(table){
	page="./include/process_ajax.php";
	address1=document.getElementById('txtAddress1').value;
	address2=document.getElementById('txtAddress2').value;
	cp=document.getElementById('txtCp').value;
	city=document.getElementById('txtCity').value;
	country=document.getElementById('cboCountry').value;
	idCart=document.getElementById('idCartFlash').value;
	
	ok=true;
	if(address1==""){
		alert("Le champ Adresse est obligatoire");
		document.getElementById('txtAddress1').focus();
		return false;
		ok=false;
	}
	if(cp==""){
		alert("Le champ Code postal est obligatoire");
		document.getElementById('txtCp').focus();
		return false;
		ok=false;
	}
	if(city==""){
		alert("Le champ Ville est obligatoire");
		document.getElementById('txtCity').focus();
		return false;
		ok=false;
	}
	if(country=="" || country=="0"){
		alert("Le champ Pays est obligatoire");
		document.getElementById('cboCountry').focus();
		return false;
		ok=false;
	}
	
	if(ok){
		url="table="+table+"&save_infoUserCart=1&address1="+address1+"&address2="+address2+"&cp="+cp+"&city="+city+"&country="+country+"&idCart="+idCart;		
		myConn.connect(page,"GET",url,end_save_data_facturacion);
		document.getElementById('div_ConfirmarDataUser').innerHTML = "<br /><img src='images/attente.gif' />";
	}
}


function putDec(num,nDec){
	return redondea(num, nDec);   
}
   
function redondea(sVal, nDec){
    var n = parseFloat(sVal);
    var s;
    n = Math.round(n * Math.pow(10, nDec)) / Math.pow(10, nDec);
    s = String(n) + "." + String(Math.pow(10, nDec)).substr(1);
    s = s.substr(0, s.indexOf(".") + nDec + 1);
    return s;
}

function popImage(imageURL,imageTitle)
{
// Set the horizontal and vertical position for the popup
PositionX = 100;
PositionY = 100;
// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)
defaultWidth  = 500;
defaultHeight = 500;
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = false;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;	
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=120-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body scroll="no" onload="reSizeToImage();doTitle(); self.focus()" onblur="self.close()">');
writeln('<img name="George" src="'+imageURL+'" style="display:block"></body></html>');
close();		
}}


function OpenNewWindow(url,name,w,h){
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	var v = window.open(url,name,'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+',top='+wint+',left='+winl);
}

function show_data_user($idUser,idFlash){
	if(document.getElementById("chkDataUser").checked==true){
		st=0;	
	}else{
		st=1;	
	}
	window.location.href="confirm_flash_livraison.php?idFlash="+idFlash+"&showDataUser="+st;
}

function confirm_vente_livraison(){
	conditions=document.getElementById("chkConditions").checked;
	
	address1=document.getElementById('txtAddress1').value;
	address2=document.getElementById('txtAddress2').value;
	cp=document.getElementById('txtCp').value;
	city=document.getElementById('txtCity').value;
	country=document.getElementById('cboCountry').value;
	idCart=document.getElementById('idCartFlash').value;
	
	
	if(address1==""){
		alert("Le champ Adresse est obligatoire");
		document.getElementById('txtAddress1').focus();
		return false;
	}
	if(cp==""){
		alert("Le champ Code postal est obligatoire");
		document.getElementById('txtCp').focus();
		return false;
	}
	if(city==""){
		alert("Le champ Ville est obligatoire");
		document.getElementById('txtCity').focus();
		return false;
	}
	if(country=="" || country=="0"){
		alert("Le champ Pays est obligatoire");
		document.getElementById('cboCountry').focus();
		return false;
	}
	
	if(conditions==false){
		alert("Vous devez accepter les conditions générales de vente");
		return true;
		
	}	
}
/* ------------------------------------- */


// SCRIPT PARA LOS LOISIRS 
function check_stock_loisir_quotas(){

	idProduct=document.getElementById("idProd").value;	
	idUser=document.getElementById("idUser").value;
	num_reserve=document.getElementById("sltReserve").value;
	type_reserver=document.getElementById("type_reserver").value;
	if(num_reserve!=0){
		cadena=idProduct+","+idUser+","+num_reserve+","+type_reserver;
		jsrsExecute("./include/check_stock_loisir_quotas.php",end_check_stock_loisir_quotas,"confirmar",cadena);
	}else{
		alert("Merci d'indiquer le nombre de places souhaitées");	
		document.getElementById("sltReserve").focus();
		return false;
	}
}

function end_check_stock_loisir_quotas(param){
	
	form=document.frmReserve;
	
	data=param.split("|");	
	msj1=data[0];
	msj2=data[1];
	msj3=data[2];
	msj4=data[3];
	ok=data[4];
	//alert(data);
	if(msj1==1 && msj2==1 && msj3==1 && msj4==1){
		if(ok){
			form.submit();	
		}else{
			alert("Désolé, votre quota ne vous permet pas de réserver ce nombre de places");
			return false;	
		}
	}else{
		if(msj1==0){
			alert("Désolé, votre quota ne vous permet pas de réserver ce nombre de places");	
			return false;
		}
		if(msj2==0){
			alert("Attention : aucune place disponible");	
			return false;
		}
		if(msj3==0){
			alert("Attention : pas assez de places disponibles");	
			return false;
		}
		if(msj4==0){
			alert("Nous sommes désolés mais vous avez déjà réservé pour ce Loisir");	
			return false;
		}
	}
}

function return_reserver_case0(){
	idProd=document.getElementById('idProduct').value;
	xr=document.getElementById('xr').value;
	video=document.getElementById('video').value;
	url="spectacle_loisir.php?idProduct="+idProd+"&xr="+xr+"&video="+video+"&page=6";
	window.location.href=url;
}
//solo numeros enteros
function validateInt(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 validar_alfanumerico(e){
    tecla = (document.all) ? e.keyCode : e.which;

    //Tecla de retroceso para borrar, siempre la permite
    if (tecla==8){
        return true;
    }
        
    // Patron de entrada, en este caso solo acepta alfanumericos, "ñ Ñ"
    patron =/[0-9a-zñA-ZÑ]/;
    
    tecla_final = String.fromCharCode(tecla);
    
    return patron.test(tecla_final);
}
//Functions Billetterie
function calculateCommissionBilletterie(table,idFlash,idDateFlash,cat){
	
	try {
   		var quotaReduit=document.getElementById('cboTarifNormal'+cat).value;
	} catch(e) {
   		var quotaReduit=0;
	}
	
	try {
   		var quotaEnfant=document.getElementById('cboTarifEnfant'+cat).value;
	} catch(e) {
   		var quotaEnfant=0;
	}

	page="./include/process_ajax.php";

	url="calculateComission=1&table="+table+"&cat="+cat+"&idFlash="+idFlash+"&idDateFlash="+idDateFlash+"&quotaReduit="+quotaReduit+"&quotaEnfant="+quotaEnfant;
	document.getElementById('fraisRes'+cat).innerHTML="<img src='images/attente.gif' />";
	myConn.connect(page,"GET",url,endCalculateCommissionBilletterie);
}

var endCalculateCommissionBilletterie = function (oXML){

	var rs = oXML.responseText.split("|");
	var ok = rs[0];
	var cat = rs[1];
	var stockDisponible = rs[2];
	var totalCommission = rs[3];
	
	if(ok==1){
		document.getElementById('fraisRes'+cat).innerHTML=totalCommission+" €";
	}
	
};
//End functions billetterie
