function objetoAjax(){
	var xmlhttp=false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xmlhttp = false;
  		}
	}

	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function pausecomp(millis)
{
    var date = new Date();
    var curDate = null;
    
    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

function paintvideo(myvideo,titulo,author,vcount){
  playme(myvideo);
	divResultado = document.getElementById('contentcenter');
	divtitleResultado = document.getElementById('videocentertitle');
	divtitleResultado.innerHTML = '<h3>'+titulo+'</h3>';
	 divResultado.innerHTML = '<center><br><br><img src=\'images/lightbox_loading.gif\' border=0><br><br>Cargando...</center>';
	
  ajax=objetoAjax();
	//ajax.prototype.setAsync = true;
	//pausecomp(700);
	ajax.open("GET", "includes/ajax.php?action=showvideo&video_id="+myvideo+"&title="+titulo+"&author="+author+"&viewcount="+vcount);
	
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null)
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features); 
}

function paintvideospot(myvideo){
  //playme(myvideo);
	divResultado = document.getElementById('video_grande');
	
  divResultado.innerHTML = '<center><br><br><img src=\'images/lightbox_loading.gif\' border=0><br><br>Cargando...</center>';
	
  ajax=objetoAjax();
	//ajax.prototype.setAsync = true;
	//pausecomp(700);
	ajax.open("GET", "includes/ajax.php?action=showvideospot&video_id="+myvideo);
	
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			divResultado.innerHTML = ajax.responseText;
		}
	}
	ajax.send(null)
}





function paintcaptcha(){
//Get a reference to CAPTCHA image
   divResultado = document.getElementById('mycaptcha');
   img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src ='captcha.php'+ '?' + (new Date()).getTime();
   
   //divResultado.innerHTML = '<img id="imgCaptcha" src="captcha.php" border=1>';
}


function makevisible(cur,which){
        strength=(which==0)? 1 : 0.4
                        
        // IE/Win
        cur.style.filter = "alpha(opacity:"+strength*100+")";
        
        // Safari<1.2, Konqueror
        cur.style.KHTMLOpacity = strength;
        
        // Older Mozilla and Firefox
        cur.style.MozOpacity = strength;
        
        // Safari 1.2, newer Firefox and Mozilla, CSS3
        cur.style.opacity = strength;    
        
        
}

function clearlist(){
  for (var i=0; i<datos.length; i++) {
      identifier=datos[i];
      //alert(identifier);
          
          //los span....
          for (var x=1; x<5 ;x++) {
            spanname='span'+x+identifier;
            //alert(spanname);
            myspan=document.getElementById(spanname);
             myspan.style.filter= "alpha(opacity=40)";
             myspan.style.MozOpacity = "0.4";
             myspan.style.opacity="0.4";   
             myspan.style.KhtmlOpacity = "0.4"; 
          }
          
      changeme = document.getElementById(identifier);
      makevisible(changeme,0);
      changeme.onMouseover= "makevisible(this,0)";
      changeme.onMouseout= "makevisible(this,1)";  
      changeme.style.filter= "alpha(opacity=40)";
      changeme.style.MozOpacity = "0.4";
      changeme.style.opacity="0.4";   
      changeme.style.KhtmlOpacity = "0.4"; 
      //changeme.onMouseover= "makevisible(this,0);";
       
  }
}

function playme(myid) {
  clearlist(); //esta funciona, pone todos negros
  //alert(myid);
  
  //los span....
        strength=1;
          for (var x=1; x<5 ;x++) {
            spanname='span'+x+myid;
            //alert(spanname);
             myspan=document.getElementById(spanname);
             myspan.style.filter= "alpha(opacity="+strength*100+")";
             myspan.style.MozOpacity = strength;
             myspan.style.opacity=strength;
             myspan.style.KhtmlOpacity = strength; 
          }
          
  lightme = document.getElementById(myid);
  
  makevisible(lightme,0); //esta funciona, ilumina...
}



function SetTripData(data){  
  divtripdata = document.getElementById('myresultcaldiv');
  divtripdata.style.display="block";
  mydata='<table valign=top width="180" border="0" cellspacing="1" cellpadding="0"><tr><td class="today">Vuelo</td></tr><tr><td><table align=left><tr><td>'+data+'</td></tr></table></td></tr></table>';
  divtripdata.innerHTML= mydata;
  //set form data....
}




function formsubmit(form_name)
{
   var frm = document.forms[form_name];
			var txt = '';
			if (frm.nombre.value == '')	txt += 'Por favor indique su Nombre.\n';
			if (frm.apellido.value == '')	txt +=  'Por favor indique su Apellido.\n';
			if (frm.apellido_2.value == '')	txt += 'Por favor indique su segundo Apellido.\n';
			if (frm.dia.value == '' || frm.dia.value == '00')	txt +=  'Por favor indique su Día.\n';
			if (frm.mes.value == '' || frm.mes.value == '00')	txt +=  'Por favor indique su Mes.\n';
			if (frm.ano.value == '' || frm.ano.value == '00')	txt +=  'Por favor indique su Año.\n';
			if (frm.provincia.value == '' || frm.provincia.value == '00')	txt += 'Por favor indique su Provincia.\n';
			if (frm.email.value == '' && frm.movil.value == '')	txt += 'Por favor indique el email ó el móvil.\n';
				if (frm.url.value == '')	txt +=  'Por favor indique la URL del vídeo.\n';
			//if (form_name.infook.value == '')	txt = 'Por favor indique su Nombre.\n';
			
			if(frm.condok.checked == false) txt +='Debe aceptar las condiciones generales.\n';
      //if (frm.condok.checked != 1)	txt +='Debe aceptar las condiciones generales.\n';
	

			if (txt != ''){
				alert (txt);
				return false;
			}
	//form submit
	frm.formsent.value="1";
  frm.submit();
}






function nif(dni) {
  		numero = dni.substr(0,dni.length-1);
  		let = dni.substr(dni.length-1,1);
  		numero = numero % 23;
  		letra='TRWAGMYFPDXBNJZSQVHLCKET';
  		letra=letra.substring(numero,numero+1);
  		if (letra!=let){ 
    		//alert('Dni erroneo');
			return false;
			}
		return true;
	}

	function FSfncCheckForm(form_name) {
	
	 var FormRef = document.forms[form_name];
	 
  //QUITAR
	/*FormRef.formsent.value="10";
		FormRef.submit();
	 return true;*/
	 //QUITAR
	 
	 
	
		if(FormRef.nombre_declaracion.value==""){
			alert("- Introduzca el nombre del titular de la tarjeta de crédito");
			return false;
			}
	
		if(!nif(FormRef.dni_declaracion.value)){
			alert("- Introduzca su DNI/Pasaporte");
			return false;
			}
			
		if (!testCreditCard(FormRef)) {return false}	
		//if (!FSfncCheckCCnum(FormRef.numero_tarjeta)) {return false}
		//if (!FSfncCheckCCexpire(FormRef.fecha_tarjeta)) {return false}
		
		if(FormRef.email.value==""){
			alert("- Introduzca un email de contacto");
			return false;
		}else{
			mail=FormRef.email.value;
			mail_1 = mail.split("@");
			mail_2 = mail.split(".");
			if((mail_1.length!=2)||(mail_2.length<2)){
				alert(" - Introduce una direccion de email valida\n");
				return false;
				}
			}
		if(FormRef.telefono.value==""){
			alert("- Introduzca un telefono de contacto");
			return false;
		}else{
			var tlf=FormRef.telefono.value;
					
			if(isNaN(tlf)){
			 	alert(" - El teléfono ha de ser un número\n");
				return false;
				}
			var pnum = tlf.substr(0,1);
			if((pnum!=6)&&(pnum!=9)){
				alert(" - El teléfono ha de empezar por 6 o 9\n");
				return false;
				}
			if(tlf.length!=9){
				alert(" - El teléfono ha de ser de 9 digitos\n");
				return false;
				}
			}
		if(FormRef.codigo_postal.value==""){
			alert("- Introduzca su código postal para saber su ciudad de salida del viaje");
			return false;
			}
		if(FormRef.acepto.checked==false){
			alert("- Debe aceptar las condiciones de uso y privacidad para finalizar la reserva.");
			return false;
			}
		
		FormRef.formsent.value="10";
		FormRef.submit();
		return true; // disable actual submit for example purposes - borrar esta línea en las páginas en vivo.
		}
