
////////////////////
///cerrar session///
////////////////////
//funcion para manejar cajas de texto con solo numeros(SIRVE EN FIREFOX)
function solo_numeros(evt)
{
	evt = (evt) ? evt : event;
	var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && (charCode < 48 || charCode > 57))
	{
        return false; 
    } 
    return true;
}

function intermedio_cerrar_session()
{
	
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/intermedio_cerrar_session.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmensajes").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmensajes").innerHTML = ajax.responseText;
			//alert (innerHTML = ajax.responseText);
			cerrar_session();
			//alert (innerHTML = ajax.responseText);
		}
	}

	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
}

function cerrar_session_sola()
{
   ajax = nuevoAjax();
   ajax.open("POST", "./../funciones/cerrar_session.php",true);
   ajax.onreadystatechange = function()
	{
	  if (ajax.readyState == 4)
		{
		  var navegador = navigator.appName;
		  if(navegador == "Microsoft Internet Explorer")
			{
			  top.location.href = "../index.php";
			}
		  else
			{
			  if (window != window.top)
			  top.location.href = "../index.php";
			}
		}
	}
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  ajax.send(null);
}

function cerrar_session()
{
	si = confirm('Are you sure you want to log out??');
	if(si == true)
	{
		ajax = nuevoAjax();
		ajax.open("POST", "./../funciones/cerrar_session.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 4)
			{
				/*var navegador = navigator.appName;
				if(navegador == "Microsoft Internet Explorer")
				{*/
					top.location.href = "./../index.php";
				/*}
				else
				{
					if (window != window.top)
					top.location.href = "./../index.php";
				}*/
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(null);
	}
	
}


<!--||||||||||||||||||||||||||||||-->
<!--||  VENDEDORES POR SUCURSAL ||-->
<!--||||||||||||||||||||||||||||||-->
function detectar_enter(evt, funcion, parametro1, parametro2)
{
	//alert("hola");
	tecla = true;
	evt = (evt) ? evt : event;
	var keyCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
	if(navigator.appName.indexOf("Netscape") != -1) {
		var isNN = true;
	}
	else {
		var isNN = false;
	}
	if(navigator.appName.indexOf("Microsoft Internet Explorer") != -1) {
		var isIE = true;
	}
	else {
		var isIE = false;
	}
	
	if( (tecla) && (keyCode == 13) ) {
	  	eval(funcion+"('"+parametro1+"', '"+parametro2+"')");
	}
}


/////////////
////INDEX////
/////////////
function contenido_home_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./home_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_models_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./models_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_dvd_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_galleries_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./galleries_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_support_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./support_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_shopping_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./shopping_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_categories_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./categories_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_downloads_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/downloads_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			usuario_credito_ver();
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

//VALIDAR EL FORMATO DE CORREO DIGITADO
function valida_mail(objeto)
{
	var mail = document.getElementById(objeto).value;
	var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
	if(emailReg.test(mail) == false)
	{
		alert("DIGITE UN E - MAIL VALIDO.");
		document.getElementById(objeto).focus();
	}
	//return emailReg.test(mail);
}

function submit_valida_mail(objeto)
{
	var mail = document.getElementById(objeto).value;
	if(mail != "")
	{
		//alert(mail);
		var emailReg = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i
		if(emailReg.test(mail) == false)
		{
			return 1;
		}
		else
		{
			return 0;
		}
	}
	//return emailReg.test(mail);
}


<!--|||||||||||||||||||||||||||||||||//-->
<!--    PARA EL INICIO DE SESSION    //-->
<!--|||||||||||||||||||||||||||||||||//-->
function enter_valida_inicio_session()
{
	key = (document.all) ? event.keyCode : event.which;	  
	var key = event.keyCode;//código de tecla.
	if(key == 13)
	{
		valida_inicio_session();
	}
}

/////////////
///registro///
//////////////

function registro_mant(page)
{
	if(page == null) {
		page = 1;
	}
	valores  = 'page='+page;
	//alert (valores);
	var URL = "./paginas/registro_mant.php";
	var ventana = window.open(URL,'registro_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=20,top=10 ,width=520, height=635');
	if(ventana != null)
	{
		ventana.focus();
	}
	
}

	
function valida_registro(page)
{
	if(page == null) {
		page = 1;
	}
	valores  = 'page='+page;
	var nombre              = document.getElementById("nombre").value;
 	var fecha_nac_usuario   = document.getElementById("fecha_nac_usuario").value;
    if( (document.getElementById("dia").value != "") || (document.getElementById("mes").value != "") ||  (document.getElementById("ano").value != "") ||
	     (document.getElementById("dia").value != null) || (document.getElementById("mes").value != null) ||  (document.getElementById("ano").value != null) )
	 {	
		var dia                 = document.getElementById("dia").value; 
		var mes                 = document.getElementById("mes").value; 
		var ano                 = document.getElementById("ano").value;
		if((dia == "") || (mes == "") || (ano == "") || (dia == null) || (mes == null) || (ano == null))
		 {
			 
				mensaje = "FIELDS MUST BE FILLED:\n\n";
				if((dia == "") && (mes == "") && (ano == "") )
				  {
					mensaje += "=> ALL FIELDS MUST BE FILLED BIRTHDAY .\n";
				  }
				if(dia == "") 
				  {
					mensaje += "=> DAY BIRTH DATE.\n";
				  }
				if(mes == "") 
				  {
					 mensaje += "=> MONTH BIRTH DATE.\n";
				  }
				if(ano == "") 
				  {
					mensaje += "=> YEAR BIRTH DATE.\n";
				  }
				  //mensaje += "=> 1.\n";
				alert(mensaje);
				return false;
				//alert(dia+mes+ano); 
		 }
	 }
	
	var email               = document.getElementById("email").value;
	var pais                = document.getElementById("pais").value;
	var password            = document.getElementById("password").value;
	var ciudad              = document.getElementById("ciudad").value;
	var password2           = document.getElementById("password2").value;
	var si                  = document.getElementById("si");
	var no                  = document.getElementById("no");
	
	var validar_mail;
	if(email != "") {
		validar_mail = submit_valida_mail("email");
	}
	//alert(fecha_nac_usuario);
//if(password == password2)
 //{
	if( (nombre == "") /*|| (fecha_nac_usuario == "")*/ ||  (email == 1) || (pais== "") || (password == "") || (ciudad == "") || 
		(password2 == "") || ((si.checked == 0) && (no.checked == 0))  )
	{
		                mensaje = "FIELDS MUST BE FILLED:\n\n";
						if(nombre == "") {
							mensaje += "=> USERNAME.\n";
						}
						/*if(fecha_nac_usuario == "") {
							mensaje += "=> BIRTH DATE.\n";
						}*/
						if (email == ""){
						   mensaje += "=> E-MAIL.\n";
						 }
					    if(validar_mail == 1){
						   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
						 }
						if(pais == "") {
							mensaje += "=> COUNTRY.\n";
						}
						if(password == "") {
							mensaje += "=> YOUR PASSWORD.\n";
						}
						if(ciudad == "") {
							mensaje += "=> YOUR LOCALIDAD.\n";
						}
						if(password2 == "") {
							mensaje += "=> CONFIRM YOUR PASSWORD.\n";
						}
						/*if(password2 != password){
							mensaje += "=>CONFIRMATION PASSWORD MUST BE THE SAME PASSWORD.\n";
						}*/
						if( (password2 != "")&&(password != "")&&(password2 != password) ) {
							mensaje += "=> CONFIRMATION PASSWORD MUST BE THE SAME PASSWORD.\n";
							document.getElementById("password").value = "";
							document.getElementById("password2").value = "";
							document.getElementById("password").focus();
						}
						if( (si.checked == 0) &&  (no.checked == 0) ) {
			                mensaje += "=>YOU HAVE TO ACCEPT THE TERMS OF USE TO REGISTER.\n";
		                 }
						 //mensaje += "=> 2.\n";						
											
						alert(mensaje);
						return false;	
		
	}
	else
	{
		
		 valores  = 'nombre='+nombre;
			if( (fecha_nac_usuario == "") || (fecha_nac_usuario == "0") || (fecha_nac_usuario == "1") )
			 {
				valores += '&fecha_nac_usuario='+fecha_nac_usuario;
			 }
			if(dia != "")
			 { 
				valores += '&dia='+dia;
			 }
			if(mes != "")
			 { 
				valores += '&mes='+mes;
			 }
			if(ano != "")
			 { 
				valores += '&ano='+ano;
			 }
			valores += '&email='+email;
			valores += '&password='+password;
			valores += '&pais='+pais;
			valores += '&ciudad='+ciudad;
			valores += '&password2='+password2;
			acepto = "";
			if(si.checked == 1) {
				acepto = 1;
			}
			if(no.checked == 1) {
				//acepto = 2;
				alert("Gracias por entrar a  nuestros sitio, si no aceptas los terminos no podra seguir con el proceso de regsitro");
				location.href = "./indexprueba.php";
				//window.close();
			}
			else
			 {
				valores += '&acepto='+acepto;
				//alert(valores);
				//alert(fecha_nac_usuario);
				ajax = nuevoAjax();
				if( (fecha_nac_usuario == "") || (fecha_nac_usuario == "0")  )
				 {
					//alert("1");
					ajax.open("POST", "./registro_guardar.php", true);
				}
				if( (fecha_nac_usuario == "") || (fecha_nac_usuario == "1") )
				 {
					 //alert("2");
					ajax.open("POST", "./paginas/registro_guardar.php", true);
				}
				ajax.onreadystatechange = function()
				{
					if (ajax.readyState == 1)
					{
						document.getElementById("tdmensajes1").innerHTML = "<img src='./images/loading.gif' border='0'>";
						document.getElementById("tdmensajes2").innerHTML = "&nbsp;Almacenando datos...";
					}
					if (ajax.readyState == 4)
					{
						document.getElementById("tdmensajes1").innerHTML = "";
						document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
						if(document.getElementById("mens") != null)
						{
							mens = document.getElementById("mens").value;
							//alert(ajax.responseText);
							if(mens == 1)
							{
								alert("REGISTRATION SUCCESSFUL.");
								nombre_usuario = document.getElementById("nombre_usuario").value;
								id_usuario = document.getElementById("id_usuario").value;
								valores  = 'nombre_usuario='+nombre_usuario;
								valores  += '&id_usuario='+id_usuario;
								
								if( (fecha_nac_usuario == "") || (fecha_nac_usuario == "0")  )
				 					{
									 //location.href = "./index_registro.php?"+valores;
									 /*location.href = "./index.php";*/
									 window.close();
									 index_registro2(nombre_usuario,id_usuario);
								  }
								  
								if( (fecha_nac_usuario == "") || (fecha_nac_usuario != "0")  )
								  {
									 location.href = "./index.php";
									 index_registro(nombre_usuario,id_usuario);
									 
								  }
							}
							if(mens == 3)
							{
								alert('THE MINIMUM LENGTH ALLOWED FOR THE KEY IS 6 (SIX) CHARACTERS.');
							}
							if(mens == 4)
							{
								alert('THE USERNAME "'+email+'"CANNOT BE REGISTERED. IF YOU REGISTERED WITH THIS EMAIL ADDRESS BEFORE, PLEASE USE THE "FORGOT YOUR PASSWORD" BUTTON TO RETRIEVE YOUR PASSWORD.');
							}
							if(mens == 5)
							{
								alert("FIELDS MUST BE FILLED.....");
							}
							if(mens == 6)
							{
								alert('CONFIRMATION PASSWORD MUST BE THE SAME PASSWORD.');
							}
							if(mens == 7)
							{
								alert('SORRY YOU MUST BE OVER 18 YEARS OLD.');
							}
							if(mens == 8)
							{
								alert('SORRY YOUR IP ADRESS MUST BE REGISTERED.');
							}
							if(mens == 9)
							{
								alert('YOU HAVE ALREADY REGISTERED THIS EMAIL. IF YOU CANNOT LOGIN, IT MEANS YOUR ACCOUNT DID NOT GET PROPERLY ACTIVATED. IF YOU DID NOT SEE THE ACTIVATION EMAIL, PLEASE CHECK THE SPAM FOLDER IN YOUR EMAIL ACCOUNT. IF YOU NEED ANY ASSISTANCE, PLEASE EMAIL US AT FANCLUB@OTBVIDEO.COM FROM THE EMAIL ADDRESS YOU USED TO SIGNUP.');
							}
						}
					}
				}
			  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			  ajax.send(valores);
			 }
  }
}

function index_registro(nombre_usuario,id_usuario)
{

	valores  = 'nombre_usuario='+nombre_usuario;
	valores  += '&id_usuario='+id_usuario;
	//valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./paginas/index_registro.php?"+valores;
	var ventana = window.open(URL,'index_registro','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=402, height=620');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}

function index_registro2(nombre_usuario,id_usuario)
{

	valores  = 'nombre_usuario='+nombre_usuario;
	valores  += '&id_usuario='+id_usuario;
	//valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./index_registro.php?"+valores;
	var ventana = window.open(URL,'index_registro','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=402, height=620');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}

////////////////////////////////
///busqueda por nombre modelo///
////////////////////////////////
function busqueda_nombre_modelo(page)
{

if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	valores += '&busqueda='+document.getElementById("busqueda").value;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_modelo.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

<!--|||||||||||||||||||||||||||||||||//-->
<!--    PARA EL INICIO DE SESSION    //-->
<!--|||||||||||||||||||||||||||||||||//-->
function enter_valida_inicio_session()
{
	key = (document.all) ? event.keyCode : event.which;	  
	var key = event.keyCode;//código de tecla.
	if(key == 13)
	{
		valida_inicio_session();
	}
}

function valida_inicio_session()
{
	var email_usuarioS    = document.getElementById("email_usuarioS").value;
	var passwordS = document.getElementById("passwordS").value;
	var guardar_clave = document.getElementById("guardar_clave");
	mensaje = "NOT ALL FIELDS ARE FILLED OUT, PLEASE COMPLETE THE FORM:\n\n";
	var validar_mail;
	if(email_usuarioS != "") {
		validar_mail = submit_valida_mail("email_usuarioS");
	}
	if( (email_usuarioS== "") || (validar_mail == 1)  || (passwordS == "" ) ) {
						   
	   if (email_usuarioS == ""){
		   mensaje += "=> E-MAIL.\n";
		 }
	   if(validar_mail == 1){
		   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS.\n"
		 }
	   if(passwordS == "") {
			mensaje += "=> PASSWORD.\n";
		}
		alert(mensaje);
		return false;
	}
	
	/*if( (loginS == "") || (passwordS == "") )
	{
		if(loginS == "") {
			mensaje += "=> EMAIL.\n";
		}
		if(passwordS == "") {
			mensaje += "=> PASSWORD.\n";
		}
		alert(mensaje);
		return false;
	}*/
	else
	{
		valida_usuario();
	}
}

function valida_usuario()
{
	var email_usuarioS    = document.getElementById("email_usuarioS").value;
	var passwordS = document.getElementById("passwordS").value;
	var guardar_clave = document.getElementById("guardar_clave");
	valores  = 'email_usuarioS='+email_usuarioS;
	valores += '&passwordS='+passwordS;
	if(guardar_clave.checked == 1)
	   {
	     guardar_clave = 1;
		 valores += '&guardar_clave='+guardar_clave;
	   }
	if(guardar_clave.checked == 0)
	   {
	     guardar_clave = 0;
		 valores += '&guardar_clave='+guardar_clave;
	   }
	ajax = nuevoAjax();
	ajax.open("POST", "./paginas/valida_usuario.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmensajes").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			
			document.getElementById("tdmensajes").innerHTML = ajax.responseText;
			//alert (innerHTML = ajax.responseText);
			if(document.getElementById("mens") != null)
			{
				var mens = document.getElementById("mens").value;
				//alert (mens);
				if(mens == 1)
				{
					alert("LOGIN INCORRECT.");
					document.getElementById("email_usuarioS").focus();
				}
				if(mens == 5)
				{
					alert('YOUR USERNAME IS BLOCKED, PLEASE CONTACT CUSTOMER SERVICE ON FANCLUB@OTBVIDEO.COM.');
					document.getElementById("email_usuarioS").focus();
				}
				if(mens == 6)
				{
					alert('YOU ENTERED A WRONG PASSWORD 3 TIMES, PLEASE REMEMBER THAT YOUR USERNAME WILL BE BLOCK WHEN YOU ENTER A WRONG PASSWORD 5 TIMES. IF YOU FORGOT YOUR PASSWORD, PLEASE CLICK THE LINK FORGOTTEN PASSWORD ON THIS PAGE.');
					document.getElementById("email_usuarioS").focus();
				}
				if ( (document.getElementById("ingreso").value == 1) && (mens == 2) )
				{
					location.href = "./paginas/index_s.php";
				}
				//document.getElementById("email_usuarioS").value    = "";
				document.getElementById("passwordS").value = "";
				document.getElementById("passwordS").focus();
			}
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

/////////////////////
///contador online///
/////////////////////
function contador_online(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/contador_online.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdonline").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdonline").innerHTML = ajax.responseText;
			//alert(ajax.responseText);
			contenido_home_ver2();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contenido_home_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./home_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			usuario_credito_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function usuario_credito_ver()
{
	/*if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./usuario_credito_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcreditover").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcreditover").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			//usuario_credito_ver();
			 //usuario_midescarga_dvd(1);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function contenido_models_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./models_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_dvd_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_galleries_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./galleries_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function contenido_support_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./support_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_shopping_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./shopping_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_categories_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./categories_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_downloads_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./downloads_contenido2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

////////////////////////////////
///busqueda por nombre modelo///
////////////////////////////////
function busqueda_nombre_modelo2(page)
{

if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	valores += '&busqueda='+document.getElementById("busqueda").value;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_modelo2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function dvd_info_ver(id_dvd,page,id)
{
	if( (id_dvd == null) || (id_dvd == "") ) {
		id_dvd = 1;
	}
	valores = 'id_dvd='+id_dvd;
	valores += '&page='+page;
	valores += '&id='+id;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_info_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_info_ver2(id_dvd,page,id)
{
	if( (id_dvd == null) || (id_dvd == "") ) {
		id_dvd = 1;
	}
	valores = 'id_dvd='+id_dvd;
	valores += '&page='+page;
	valores += '&id='+id;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_info_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function busqueda_nombre_video_session(page)
{

    if( (page == null) || (page == "")  )
	  {
		page = 1;
	  }
	valores  = 'page='+page;
	if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_nombre_video(1);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function busqueda_nombre_setfoto_session(page)
{

    if( (page == null) || (page == "")  )
	  {
		page = 1;
	  }
	valores  = 'page='+page;
	if(document.getElementById("nom_modelo") != null)
	 {
		valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	if(document.getElementById("categoria") != null)
	 {
	   valores += '&categoria='+document.getElementById("categoria").value;
	 }
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_setfoto_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(innerHTML = ajax.responseText);
				busqueda_nombre_setfoto(1);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}


function busqueda_nombre_video(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	/*if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function busqueda_nombre_setfoto(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_setfoto.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function busqueda_nombre_video_mant(page)
{

if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}



function busqueda_nombre_video_session2(page)
{

    if( (page == null) || (page == "")  )
	  {
		page = 1;
	  }
	valores  = 'page='+page;
	if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video_session2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_nombre_video2(1);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function busqueda_nombre_video2(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	/*if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function busqueda_nombre_video_mant2(page)
{

if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_nombre_video2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}


function video_escena_ver(id_dvd)
{

if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./video_escena_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdescenas").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdescenas").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function video_escena_ver2(id_dvd)
{

if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./video_escena_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdescenas").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdescenas").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

/*function menu_paquette_video()
{
		
	//valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./paginas", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdocultopaquetevideo").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdocultopaquetevideo").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				//alert("hola");
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
}*/

function menu_paquette_video(id)
{
	
	if( (id != "") && (id != 'undefined') && (id != null) )
	{
		id_cont = id;
		//alert(id_cont);
		opciones("tdocultopaquetevideo"+id);
		//alert("hola2");
		//id_cont = 1;
	}
	if (document.getElementById("tdocultopaquetevideo"+id_cont) == null) {
		opciones("tdocultopaquetevideo"+id);
		//alert("hola2");
		id_cont = 1;
	}
	//}
	if (document.getElementById("tdocultopaquetevideo"+id_cont) == null) {
		opciones("tdocultopaquetevideo"+id_cont);
		//alert("hola2");
		id_cont = 1;
	}
	/*valores  = 'id_mail='+id_mail;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&id_usuarioS='+id_usuarioS;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./paginas/menu_paquette_video.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdocultopaquetevideo1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdocultopaquetevideo1").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function menu_paquette_fotos(id)
{
	
	if( (id != "") && (id != 'undefined') && (id != null) )
	{
		id_cont = id;
		//alert(id_cont);
		opciones("tdocultopaquetefotos"+id);
		//alert("hola2");
		//id_cont = 1;
	}
	if (document.getElementById("tdocultopaquetefotos"+id_cont) == null) {
		opciones("tdocultopaquetefotos"+id);
		//alert("hola2");
		id_cont = 1;
	}
	//}
	if (document.getElementById("tdocultopaquetefotos"+id_cont) == null) {
		opciones("tdocultopaquetefotos"+id_cont);
		//alert("hola2");
		id_cont = 1;
	}
	/*valores  = 'id_mail='+id_mail;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&id_usuarioS='+id_usuarioS;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./paginas/menu_paquette_fotos.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdocultopaquetefotos1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdocultopaquetefotos1").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function menu_paquette_video2(id)
{
	
	if( (id != "") && (id != 'undefined') && (id != null) )
	{
		id_cont = id;
		//alert(id_cont);
		opciones("tdocultopaquetevideo"+id);
		//alert("hola2");
		//id_cont = 1;
	}
	if (document.getElementById("tdocultopaquetevideo"+id_cont) == null) {
		opciones("tdocultopaquetevideo"+id);
		//alert("hola2");
		id_cont = 1;
	}
	//}
	if (document.getElementById("tdocultopaquetevideo"+id_cont) == null) {
		opciones("tdocultopaquetevideo"+id_cont);
		//alert("hola2");
		id_cont = 1;
	}
	/*valores  = 'id_mail='+id_mail;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&id_usuarioS='+id_usuarioS;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/menu_paquette_video2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdocultopaquetevideo1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdocultopaquetevideo1").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function menu_paquette_fotos2(id)
{
	
	if( (id != "") && (id != 'undefined') && (id != null) )
	{
		id_cont = id;
		//alert(id_cont);
		opciones("tdocultopaquetefotos"+id);
		//alert("hola2");
		//id_cont = 1;
	}
	if (document.getElementById("tdocultopaquetefotos"+id_cont) == null) {
		opciones("tdocultopaquetefotos"+id);
		//alert("hola2");
		id_cont = 1;
	}
	//}
	if (document.getElementById("tdocultopaquetefotos"+id_cont) == null) {
		opciones("tdocultopaquetefotos"+id_cont);
		//alert("hola2");
		id_cont = 1;
	}
	/*valores  = 'id_mail='+id_mail;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&id_usuarioS='+id_usuarioS;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/menu_paquette_fotos2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdocultopaquetefotos1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdocultopaquetefotos1").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
//PARA MOSTRAR Y OCULTAR TDS
function opciones(obj)
{
  //alert(obj);
  var Div = document.getElementById(obj);
  if (Div.style.display == "none"){
    Div.style.display = ""
   }
   else{
     Div.style.display = "none"
   }
}

function busqueda_serie_session(page,id_serie)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
  if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}
		
	valores  = 'page='+page;
	valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_serie_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_serie(1);
			}
	}
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  ajax.send(valores);

}
function busqueda_serie_session2(page,id_serie)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
  if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}
		
	valores  = 'page='+page;
	valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_serie_session2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_serie2(1);
			}
	}
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  ajax.send(valores);

}

function busqueda_serie(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_serie.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);

}

function busqueda_serie2(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
		
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_serie2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function busqueda_categoria(page,id_categoria)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
  if( (id_categoria == null) || (id_categoria == "")  )
	{
		id_categoria = 1;
	}
		
	valores  = 'page='+page;
	valores  += '&id_categoria='+id_categoria;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_categoria.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
 
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function busqueda_categoria2(page,id_categoria)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
  if( (id_categoria == null) || (id_categoria == "")  )
	{
		id_categoria = 1;
	}
		
	valores  = 'page='+page;
	valores  += '&id_categoria='+id_categoria;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_categoria2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}


function busqueda_set_fotos_session(id)
{

  if( (id == null) || (id == "")  )
	{
		id = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'id='+id;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_set_fotos_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_set_fotos(1);
			}
	}
		
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function busqueda_set_fotos_session2(id)
{

  if( (id == null) || (id == "")  )
	{
		id = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'id='+id;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_set_fotos_session2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				busqueda_set_fotos2(1);
			}
	}
		
    ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function busqueda_set_fotos(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_set_fotos.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);

}

function busqueda_set_fotos2(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_set_fotos2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function ussuario_descargar_video(id_dvd)
{
	
	si = confirm('Please confirm you want to add this video to your downloads');
	if(si == true)
	{
		 if( (id_dvd== null) || (id_dvd == "")  )
			{
				id_dvd = 1;
			}
		valores  = 'id_dvd='+id_dvd;
		 if(document.getElementById("bareback") != null)
	 {
		valores += '&bareback='+document.getElementById("bareback").checked;
	 }
	 if(document.getElementById("action") != null)
	 {
		valores += '&action='+document.getElementById("action").checked;
	 }
	 if(document.getElementById("solo") != null)
	 {
		valores += '&solo='+document.getElementById("solo").checked;
	 }
		if (document.getElementById("setfoto") != null) {
  		    valores += '&setfoto='+document.getElementById("setfoto").checked;
		}
	    //alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_descargar_video.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
                                                                                            
					//alert(id_dvd);
					//alert(resultado);
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{

						//alert("HA AQUIRIDO ESTE PAQUETE LO PUEDE BUSCAR EN SU PAGINA DE DESCARGA.!");
						if(document.getElementById("id_dvd") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
						     var resultado = document.getElementById("resultado").value; 
							//alert("hola1");
							var resultado  = document.getElementById("resultado").value;
							var id_usuario  = document.getElementById("id_usuario").value;
							var dvd_credito = document.getElementById("dvd_credito").value;
							var id_dvd  = document.getElementById("id_dvd").value;
							var descripcion  = document.getElementById("descripcion").value;
							opener.seleccionar_video_ecenas_por_completo(id_dvd,descripcion);
							opener.descuento_credito_dvd(resultado, id_usuario, dvd_credito,id_dvd);
							window.close();
						}
						if(document.getElementById("resultado") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
							var resultado = document.getElementById("resultado").value; 	
							//alert("hola2");
							var resultado  = document.getElementById("resultado").value;
							var id_usuario  = document.getElementById("id_usuario").value;
							var dvd_credito = document.getElementById("dvd_credito").value;
							var id_dvd  = document.getElementById("id_dvd").value;
							var descripcion  = document.getElementById("descripcion").value;
							opener.seleccionar_video_ecenas_por_completo(id_dvd,descripcion);
							opener.descuento_credito_dvd(resultado, id_usuario, dvd_credito,id_dvd);
							window.close();
						}
						/*if(document.getElementById("nombreD") != null)
						{
							var nombreD = document.getElementById("nombreD").value;
							var resultado = document.getElementById("resultado").value;
							var id_usuario = document.getElementById("id_usuario").value;
							//alert(descarga);
							usuario_credito_ver();
							//descarga_archivo_dvd(nombreD,resultado, id_usuario);
						}*/
					
					}
					if(mens == 2)
					{
						alert('ERROR INTENTE DE NUEVO.!');
						
					}
					if(mens == 3)
					{
						alert('You already have purchased this package / scene .');
						
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first..');
						comprar_credito_mant();
						window.close();
					}
					if(mens == 5)
					{
						alert('You already have purchased this package / scene ');
						
					}
				}
			}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);
	}
	
}

function seleccionar_video_ecenas_por_completo(id_dvd,descripcion)
{
	 if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
    		
	valores  = 'id_dvd='+id_dvd;
	valores  += '&descripcion='+descripcion;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/seleccionar_video_ecenas_por_completo.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//seleccionar_video_ecenas_por_completo(id_dvd,descripcion);
				//usuario_midescarga_setfoto(1);l
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function ussuario_descargar_individual_video(id_video)
{
	si = confirm('You selected to download this video. After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
	if(si == true)
	{
		 if( (id_video == null) || (id_video== "")  )
			{
				id_video = 1;
			}
		valores  = 'id_video='+id_video;	
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_descargar_individual_video.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert (innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					
					//alert (mens);
					if(mens == 1)
					{
					  if(document.getElementById("nombreD") != null)
						{
							var nombreD = document.getElementById("nombreD").value;
							//alert("EN ALGUNOS SEGUNDO SE DESCARGARA EL VIDEO "+nombreD+" .!");
							//alert(nombreD);
							//var resultado = document.getElementById("resultado").value;
							var id_usuario = document.getElementById("id_usuario").value;
						   descarga_archivo_dvd(nombreD, id_usuario);
						}
						/*if(document.getElementById("nombreD") != null)
						{
							var nombreD = document.getElementById("nombreD").value;
							var resultado = document.getElementById("resultado").value;
							var id_usuario = document.getElementById("id_usuario").value;
							//alert(descarga);
							usuario_credito_ver();
							//descarga_archivo_dvd(nombreD,resultado, id_usuario);
						}*/
					
					}
					if(mens == 2)
					{
						alert('ERROR.!');
						
					}
					if(mens == 3)
					{
						if(document.getElementById("id_video") != null)
						{
							var id_video = document.getElementById("id_video").value;
							usuario_descargar_denuevo(id_video);
						}
						
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first.');
						comprar_credito_mant();
						window.close();
						
					}
					if(mens == 5)
						{
							alert('Our system indicates that you already attempted to download this video 5 times. To avoid piracy and hacked accounts we have blocked the download of this video. In case you feel this is in error, please contact customer support(support@otbvideo.com, or use the form on the support page).!');
							
						}
				}
					
			}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);
	}
	
}


function usuario_descargar_individual_setfoto(id_set)
{
	si = confirm('You selected to download this Photo set . After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
	if(si == true)
	{
		 if( (id_set == null) || (id_set== "")  )
			{
				id_set = 1;
			}
		valores  = 'id_set='+id_set;	
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_descargar_individual_setfoto.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert (innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					
					//alert (mens);
					if(mens == 1)
					{
					  if(document.getElementById("nombreD") != null)
						{
							var nombreD = document.getElementById("nombreD").value;
							var id_usuario = document.getElementById("id_usuario").value;
							//alert(nombreD);
						    descarga_archivo_setfoto(nombreD, id_usuario);
						}
					}
					if(mens == 2)
					{
						alert('ERROR.!');
						
					}
					if(mens == 3)
					{
						if(document.getElementById("id_set") != null)
						{
							var id_set = document.getElementById("id_set").value;
							usuario_descargar_denuevo_setfoto(id_set);
						}
						
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first.');
						comprar_credito_mant();
						window.close();
						
					}
					if(mens == 5)
						{
							alert('Our system indicates that you already attempted to download this video 5 times. To avoid piracy and hacked accounts we have blocked the download of this video. In case you feel this is in error, please contact customer support(support@otbvideo.com, or use the form on the support page).!');
							
						}
				}
					
			}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);
	}
	
}


function descuento_credito_dvd(resultado, id_usuario, dvd_credito,id_dvd)
{
	/* if( (page == null) || (page == "")  )
	{
		page = 1;
	}*/
  /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&dvd_credito='+dvd_credito;
	valores  += '&id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descuento_credito_dvd.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{
						 var resultado = document.getElementById("resultado").value;
						 var efectivo_unidad = document.getElementById("efectivo_unidad").value;
						 var efectivo_total = document.getElementById("efectivo_total").value;
						 //alert(efectivo_total);
						 var dvd_unidad_resta = document.getElementById("dvd_unidad_resta").value;
						 var credito_total = document.getElementById("credito_total").value;
						 var efectivo_unidad = document.getElementById("efectivo_unidad").value;
						 var dvd_credito = document.getElementById("dvd_credito").value;
						 var id_usuario = document.getElementById("id_usuario").value;
						 var id_dvd = document.getElementById("id_dvd").value;
						 descuento_credito_dvd_asignar(resultado,efectivo_unidad,efectivo_total,dvd_unidad_resta,credito_total,efectivo_unidad,dvd_credito,id_usuario,id_dvd);
							//usuario_credito_ver(); 
						
						//usuario_midescarga_dvd2(1);
					}
					if(mens == 2)
					{
			 		   alert('ERROR INTENTE DE NUEVO.!');
					}
			}
		}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);
}

function descuento_credito_dvd_asignar(resultado,efectivo_unidad,efectivo_total,dvd_unidad_resta,credito_total,efectivo_unidad,dvd_credito,id_usuario,id_dvd)
{
	valores  = 'resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&dvd_credito='+dvd_credito;
	valores  += '&id_dvd='+id_dvd;
	valores  += '&efectivo_unidad='+efectivo_unidad;
	valores  += '&efectivo_total='+efectivo_total;
	valores  += '&dvd_unidad_resta='+dvd_unidad_resta;
	valores  += '&efectivo_unidad='+efectivo_unidad;
	valores  += '&credito_total='+credito_total;
	//alert(efectivo_total);
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descuento_credito_dvd_asignar.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{
					 alert('Your selected download is added to your downloads. "'+dvd_credito+'" credits were debited from your account. Please click OK to continue to your download page.You can always reach this page by clicking on "Your Downloads" in the box top right on your screen.');	
						contenido_downloads_ver();
					}
					if(mens == 2)
					{
			 		   alert('ERROR INTENTE DE NUEVO.!');
					}
			}
		}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);
}


function usuario_descargar_denuevo(id_video)
{

	valores  = 'id_video='+id_video;
	//valores  += '&resultado='+resultado;
	//valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./../paginas/usuario_descargar_denuevo.php?"+valores;
	var ventana = window.open(URL,'usuario_descargar_denuevo','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=487, height=270');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}

function usuario_descargar_denuevo_setfoto(id_set)
{

	valores  = 'id_set='+id_set;
	//valores  += '&resultado='+resultado;
	//valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./../paginas/usuario_descargar_denuevo__setfoto.php?"+valores;
	var ventana = window.open(URL,'usuario_descargar_denuevo__setfoto','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=487, height=270');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}

function descripcion_texto()
{
		
	ajax = nuevoAjax();
	ajax.open("POST", "./descripcion_texto.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddescripcion_texto").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddescripcion_texto").innerHTML = ajax.responseText;
				//usuario_midescarga_setfoto(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);

}
function descripcion_texto_false()
{
		
	ajax = nuevoAjax();
	ajax.open("POST", "./descripcion_texto_false.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddescripcion_texto").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddescripcion_texto").innerHTML = ajax.responseText;
				//usuario_midescarga_setfoto(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);

}

function usuario_descargar_video_denuevo(id_video)
{
	valores  = 'id_video='+id_video;
	var descripcion1       = document.getElementById("descripcion1");
	var descripcion2       = document.getElementById("descripcion2");
	var descripcion3       = document.getElementById("descripcion3");
	var descripcion_texto  = document.getElementById("descripcion_texto").value;

  if ((descripcion1.checked == 0) && (descripcion2.checked == 0) && (descripcion3.checked == 0) )  
	  {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
		  alert(mensaje);
		  return false;	
	}
	else
	{
		if(descripcion1.checked == 1)
		{
				descripcion1 = "Previous download failed";
				valores += '&descripcion1='+descripcion1;
		}
		if(descripcion2.checked == 1)
		{
				descripcion2 = "I lost the file";
				valores += '&descripcion2='+descripcion2;
		}
		if(descripcion3.checked == 1)
		{
				descripcion3 = "other, please specify";
				valores += '&descripcion3='+descripcion3;
				valores += '&descripcion_texto='+descripcion_texto;
		}
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/usuario_descargar_video_denuevo.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(ajax.responseText);
					if(document.getElementById("mens") != null)
					{
						var mens = document.getElementById("mens").value;
						//alert (mens);
						if(mens == 1)
						{
						
						  if(document.getElementById("nombreD") != null)
							{
								var nombreD = document.getElementById("nombreD").value;
								//alert("EN ALGUNOS SEGUNDO SE DESCARGARA EL VIDEO "+nombreD+" .!");
								var id_usuario = document.getElementById("id_usuario").value;
								descarga_archivo_dvd(nombreD, id_usuario);
								window.close();
							} 
						}
						if(mens == 2)
						{
							alert('ERROR.!');
							
						}
						if(mens == 3)
						{
							alert('Our system indicates that you already attempted to download this video 5 times. To avoid piracy and hacked accounts we have blocked the download of this video. In case you feel this is in error, please contact customer support (support@otbvideo.com, or use the form on the support page).!');
							
						}
					}
					
				}
		}
    	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
    }
}

function usuario_descargar_setfoto_denuevo_mant(id_set)
{
	valores  = 'id_set='+id_set;
	var descripcion1       = document.getElementById("descripcion1");
	var descripcion2       = document.getElementById("descripcion2");
	var descripcion3       = document.getElementById("descripcion3");
	var descripcion_texto  = document.getElementById("descripcion_texto").value;

  if ((descripcion1.checked == 0) && (descripcion2.checked == 0) && (descripcion3.checked == 0) )  
	  {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
		  alert(mensaje);
		  return false;	
	}
	else
	{
		if(descripcion1.checked == 1)
		{
				descripcion1 = "Previous download failed";
				valores += '&descripcion1='+descripcion1;
		}
		if(descripcion2.checked == 1)
		{
				descripcion2 = "I lost the file";
				valores += '&descripcion2='+descripcion2;
		}
		if(descripcion3.checked == 1)
		{
				descripcion3 = "other, please specify";
				valores += '&descripcion3='+descripcion3;
				valores += '&descripcion_texto='+descripcion_texto;
		}
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/usuario_descargar_setfoto_denuevo_mant.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(ajax.responseText);
					if(document.getElementById("mens") != null)
					{
						var mens = document.getElementById("mens").value;
						//alert (mens);
						if(mens == 1)
						{
						
						  if(document.getElementById("nombreD") != null)
							{
								var nombreD = document.getElementById("nombreD").value;
								//alert("EN ALGUNOS SEGUNDO SE DESCARGARA EL VIDEO "+nombreD+" .!");
								var id_usuario = document.getElementById("id_usuario").value;
								descarga_archivo_setfoto(nombreD, id_usuario);
								window.close();
							}  
						}
						if(mens == 2)
						{
							alert('ERROR.!');
							
						}
						if(mens == 3)
						{
							alert('Our system indicates that you already attempted to download this video 5 times. To avoid piracy and hacked accounts we have blocked the download of this video. In case you feel this is in error, please contact customer support (support@otbvideo.com, or use the form on the support page).!');
							
						}
					}
					
				}
		}
    	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
    }
}


function descarga_archivo_dvd(nombreD, id_usuario)
{

	valores  = 'nombreD='+nombreD;
	//valores  += '&resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var ventana;
	var URL = "./descarga_archivo_dvd.php?"+valores;
	var ventana = window.open(URL,'descarga_archivo_dvd','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=370, height=54');
	if(ventana != null)
	{
		ventana.focus();
	}
	
}

function descarga_archivo_setfoto(nombreD, id_usuario)
{

	valores  = 'nombreD='+nombreD;
	//valores  += '&resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var ventana;
	var URL = "./descarga_archivo_setfoto.php?"+valores;
	var ventana = window.open(URL,'descarga_archivo_setfoto','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=370, height=54');
	if(ventana != null)
	{
		ventana.focus();
	}
	
}

function descargar(url) 
{
	var url2 = "/download_video/";
	var url3 =url2+url;
	//alert(url3); 
	//window.onfocus = finalizada;
	/*var ventana = window.open(url3,url3,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=380, height=280')
	if(ventana != null)
	{
		ventana.focus();
	}*/
	document.location = url3;
}
function descargar_archivo_dvd_IE()
{

	//alert ("hola");
	/*document.location = "./descargar_archivo_dvd_IE.php"; 
	valores  = 'nombreD='+nombreD;
	//valores  += '&resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	alert (valores);*/
	var ventana;
	var URL = "./descargar_archivo_dvd_IE.php";
	var ventana = window.open(URL,'descargar_archivo_dvd_IE','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=370, height=54');
	if(ventana != null)
	{
		ventana.focus();
	}
	/*ajax = nuevoAjax();
	ajax.open("POST", "./descargar_archivo_dvd_IE.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddescarga").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddescarga").innerHTML = ajax.responseText;
				//usuario_midescarga_dvd(1);
				//usuario_credito_ver();
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);*/
}

function usuario_midescarga_dvd(page)
{
	 if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
		
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/usuario_midescarga_dvd.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddescargasdvd").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddescargasdvd").innerHTML = ajax.responseText;
				usuario_credito_ver();
				//usuario_midescarga_setfoto(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}

function usuario_midescarga_dvd2(page)
{
	 if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
		
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/usuario_midescarga_dvd.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				usuario_credito_ver();
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);

}


function usuario_midescarga_setfoto(page)
{
	 if( (page == null) || (page == "")  )
	{
		page = 1;
	}
    /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
		
	valores  = 'page='+page;
	//valores  += '&id_serie='+id_serie;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/usuario_midescarga_setfoto.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddescargasdvd").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddescargasdvd").innerHTML = ajax.responseText;
				//usuario_midescarga_setfoto(1);
				//alert(ajax.responseText);
			}
	}
  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
  ajax.send(valores);

}

function usuario_descargar_video_foto(id_dvd)
{
	si = confirm('You selected to download this video. After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
	if(si == true)
	{
		 if( (id_dvd== null) || (id_dvd == "")  )
			{
				id_dvd = 1;
			}
		valores  = 'id_dvd='+id_dvd;	
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_descargar_video_foto.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert (innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					
					//alert (mens);
					if(mens == 1)
					{
						alert("HAS AQUIRIDO ESTE PAQUETE + EL SET DE FOTOS  PUEDE BUSCAR EN SU PAGINA DE DESCARGA.!");
						if(document.getElementById("resultado") != null)
						{
							//var nombreD = document.getElementById("nombreD").value;
							var resultado = document.getElementById("resultado").value;
							var id_usuario = document.getElementById("id_usuario").value;
						    descuento_credito_dvd(resultado, id_usuario);
						}
				
					}
					if(mens == 2)
					{
						alert('ERROR INTENTE DE NUEVO.!');
						
					}
					if(mens == 3)
					{
						alert('YA HAS COMPRADO ESTE PAQUETE SI DESEA DESCARGAR ESTE SET FOTOS POR FAVOR HACERLE INDIVIDUALMENTE.');
						
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account firstS.');
						comprar_credito_mant();
						
					}
					if(mens == 5)
					{
						alert('YA HAS COMPRADO ESTE PAQUETE ESTE PAQUETE + FOTOOS POR FAVOR BUSCARLO EN LA PAGINA DE DESCARGA.');
						
					}
				}
					
			}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);
	}
	
}


function descarga_set_fotos(id)
{
	
	if( (id != "") && (id != 'undefined') && (id != null) )
	{
		id_cont = id;
		//alert(id_cont);
		opciones("tdocultosetfotos"+id);
		//alert("hola2");
		//id_cont = 1;
	}
	if (document.getElementById("tdocultosetfotos"+id_cont) == null) {
		opciones("tdocultosetfotos"+id);
		//alert("hola2");
		id_cont = 1;
	}
	//}
	if (document.getElementById("tdocultosetfotos"+id_cont) == null) {
		opciones("tdocultosetfotos"+id_cont);
		//alert("hola2");
		id_cont = 1;
	}
	valores  = 'id='+id;
	/*valores  += '&id_usuario='+id_usuario;
	valores  += '&id_usuarioS='+id_usuarioS;*/
	//alert("hola");
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descarga_set_fotos.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdocultosetfotos"+id_cont).innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdocultosetfotos"+id_cont).innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function setfoto_descarga(id_set, id_dvd)
{
	//alert("hola");
	si = confirm('You selected to download this video. After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
	if(si == true)
	{
		 if( (id_set == null) || (id_set == "")  )
			{
				id_set = 1;
			}
		if( (id_dvd == null) || (id_dvd == "")  )
			{
				id_dvd = 1;
			}	
		valores  = 'id_set='+id_set;
		valores += '&id_dvd='+id_dvd;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./setfoto_descarga.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert (innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					
					//alert (mens);
					if(mens == 1)
					{
						alert("EN UNOS SEGUNDOS SE DECARGARA EL SET DE FOTOS.!");
						  if(document.getElementById("nom_archivo") != null)
						    {
								//var nombreD = document.getElementById("nombreD").value;
								var nom_archivo = document.getElementById("nom_archivo").value;
								var id_usuario = document.getElementById("id_usuario").value;
								//alert(nom_archivo);
								//alert(id_usuario);
							    descarga_setfotos_mant(nom_archivo, id_usuario);
                            }                                        
					}
					if(mens == 2)
					{
						alert('ERROR INTENTE DE NUEVO.!');
						
					}
					if(mens == 3)
					{
						 //alert("hola");
						if(document.getElementById("id_set") != null)
						    {
								//var nombreD = document.getElementById("nombreD").value;
								var id_set = document.getElementById("id_set").value;
								var id_usuario = document.getElementById("id_usuario").value;
							    descarga_setfotos_emergente(id_set);
                            }
					}
					if(mens == 4)
					{
						alert('_');
						
					}
					if(mens == 5)
					{
						alert('HA SOBREPASDO EL LIMITE DE DESCARGA POR FAVOR SI DESA VOLVER A DESCARGAR PONERCE EN COMINICACION CON EL ADMINISTRADOR GRACIAS.!');
					}
				}
		    }
		}
	 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	 ajax.send(valores);
   }
}


function descarga_setfotos_emergente(id_set)
{

	valores  = 'id_set='+id_set;
	//valores  += '&resultado='+resultado;
	//valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./../paginas/descarga_setfotos_emergente.php?"+valores;
	var ventana = window.open(URL,'descarga_setfotos_emergente','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=250, height=250');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}

function descarga_setfotos_mant(nom_archivo, id_usuario)
{

	valores  = 'nom_archivo='+nom_archivo;
	//valores  += '&resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	//alert (valores);
	var URL = "./../paginas/descarga_setfotos_mant.php?"+valores;
	var ventana = window.open(URL,'descarga_setfotos_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=10, height=10');
	if(ventana != null)
	{
		ventana.focus();
		//usuario_credito_ver();
		//alert("hola papa");
	}
	
}


function usuario_descargar_setfoto_denuevo(id_set)
{
	//alert("hola");
	var walter   = document.getElementById("walter").value;
	//alert(walter);
	
	if (walter == "") 
	{
		mensaje = "FIELDS MUST BE FILLED:\n\n";
		if(walter == "") {
			mensaje += "=> descripcion.\n";
		  }
	    alert(mensaje);
		return false;	
	}
	else
	{
		valores  = 'id_set='+id_set;
		valores  += '&walter='+walter;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/usuario_descargar_setfoto_denuevo.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(ajax.responseText);
					if(document.getElementById("mens") != null)
					{
						var mens = document.getElementById("mens").value;
						//alert (mens);
						if(mens == 1)
						{
						   //alert("hola")
						  alert("EN UNOS SEGUNDOS SE DECARGARA NUEVAMENTE  SET DE FOTOS.!");
						  if(document.getElementById("nom_archivo") != null)
							{
								var nom_archivo = document.getElementById("nom_archivo").value;
								var id_usuario = document.getElementById("id_usuario").value;
								descarga_setfotos_mant(nom_archivo, id_usuario);
							}  
						}
						if(mens == 2)
						{
							alert('ERROR INTENTE DE NUEVO.!');
							
						}
						if(mens == 3)
						{
							alert('HA SOBREPASDO EL LIMITE DE DESCARGA POR FAVOR SI DESA VOLVER A DESCARGAR PONERCE EN COMINICACION CON EL ADMINISTRADOR GRACIAS.!');
							
						}
					}
					
				}
		}
    	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
    }
}

function usuario_descargar_setfoto(id_set)
{
	si = confirm('Please confirm you want to add this photo set to your downloads.');
	if(si == true)
	{
		 if( (id_set== null) || (id_set == "")  )
			{
				id_set = 1;
			}
		valores  = 'id_set='+id_set;	
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_descargar_setfoto.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "";
			}
			if (ajax.readyState == 4)
			{
				
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert (innerHTML = ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					
					//alert (mens);
					if(mens == 1)
					{
						if(document.getElementById("resultado") != null)
						{
							//alert("hola");
							var id_set = document.getElementById("id_set").value;
							var credito_setfoto = document.getElementById("credito_setfoto").value;
							var resultado = document.getElementById("resultado").value;
							var id_usuario = document.getElementById("id_usuario").value;
						    descuento_credito_setfoto(resultado,id_usuario,credito_setfoto,id_set);
						}
					
					}
					if(mens == 2)
					{
						alert('ERROR.!');
					}
					if(mens == 3)
					{
						alert('You already have purchased this Photo Set.');
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this Photo Set, please add credits to your account first..');
						comprar_credito_mant();
						window.close();
					}
					if(mens == 5)
					{
						alert('You already have purchased this Photo Set.');
					}
				}
			}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);
	}
	
}

function descuento_credito_setfoto(resultado,id_usuario,credito_setfoto,id_set)
{
	valores  = 'resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&credito_setfoto='+credito_setfoto;
	valores  += '&id_set='+id_set;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descuento_credito_setfoto.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{
					 	 var resultado = document.getElementById("resultado").value;
						 var efectivo_unidad = document.getElementById("efectivo_unidad").value;
						 var efectivo_total = document.getElementById("efectivo_total").value;
						 //alert(efectivo_total);
						 var dvd_unidad_resta = document.getElementById("dvd_unidad_resta").value;
						 var credito_total = document.getElementById("credito_total").value;
						 var efectivo_unidad = document.getElementById("efectivo_unidad").value;
						 var credito_setfoto = document.getElementById("credito_setfoto").value;
						 var id_usuario = document.getElementById("id_usuario").value;
						 var id_set = document.getElementById("id_set").value;
						 descuento_credito_setfoto_asignar(resultado,efectivo_unidad,efectivo_total,dvd_unidad_resta,credito_total,efectivo_unidad,credito_setfoto,id_usuario,id_set);
					}
					if(mens == 2)
					{
			 		   alert('ERROR.!');
					}
			}
		}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);
}

function descuento_credito_setfoto_asignar(resultado,efectivo_unidad,efectivo_total,dvd_unidad_resta,credito_total,efectivo_unidad,credito_setfoto,id_usuario,id_set)
{
	valores  = 'resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&credito_setfoto='+credito_setfoto;
	valores  += '&id_set='+id_set;
	valores  += '&efectivo_unidad='+efectivo_unidad;
	valores  += '&efectivo_total='+efectivo_total;
	valores  += '&dvd_unidad_resta='+dvd_unidad_resta;
	valores  += '&efectivo_unidad='+efectivo_unidad;
	valores  += '&credito_total='+credito_total;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descuento_credito_setfoto_asignar.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{
					 alert('Your selected download is added to your downloads. "'+credito_setfoto+'" credits were debited from your account. Please click OK to continue to your download page.You can always reach this page by clicking on "Your Downloads" in the box top right on your screen.');
				        //usuario_midescarga_setfoto(1);
						//usuario_credito_ver();
						contenido_downloads_ver(); 
						//usuario_midescarga_dvd2(1);
					}
					if(mens == 2)
					{
			 		   alert('ERROR.!');
					}
			}
		}
	}
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);
}


function modelo_ver_session(page,id_modelo,page2,id )
{
	 if( (id_modelo== null) || (id_modelo == "")  )
			{
				id_modelo = 1;
			}
		valores  = 'page='+page;
		valores += '&id_modelo='+id_modelo;
		valores += '&page2='+page2;
		valores += '&id='+id;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./modelo_ver_session.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdcontenido").innerHTML = ajax.responseText;
					modelo_ver(page);
					//usuario_midescarga_setfoto(1);
					//alert(ajax.responseText);
				}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);

}

function modelo_ver(page)
{
	 if( (page== null) || (page == "")  )
			{
				page = 1;
			}
		valores  = 'page='+page;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./modelo_ver.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdcontenido").innerHTML = ajax.responseText;
					//usuario_midescarga_setfoto(1);
					//alert(ajax.responseText);
				}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);

}

function modelo_ver_session2(page,id_modelo,page2,id )
{
	 if( (id_modelo== null) || (id_modelo == "")  )
			{
				id_modelo = 1;
			}
		valores  = 'page='+page;
		valores += '&id_modelo='+id_modelo;
		valores += '&page2='+page2;
		valores += '&id='+id;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./modelo_ver_session2.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdcontenido").innerHTML = ajax.responseText;
					modelo_ver2(1);
					//usuario_midescarga_setfoto(1);
					//alert(ajax.responseText);
				}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);

}

function modelo_ver2(page)
{
	 if( (page== null) || (page == "")  )
			{
				page = 1;
			}
		valores  = 'page='+page;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./modelo_ver2.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
				{
					document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
			if (ajax.readyState == 4)
				{
					document.getElementById("tdcontenido").innerHTML = ajax.responseText;
					//usuario_midescarga_setfoto(1);
					//alert(ajax.responseText);
				}
		}
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	  ajax.send(valores);

}

function modelo_foto_perfil(id_foto,id_modelo)
{
	valores = 'id_foto='+id_foto;
	valores += '&id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_foto_perfil.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelofotoperfil").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelofotoperfil").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_video_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_video_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_video_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_video_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant_session(page,id_dvd,tipo_dvd,page2)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	valores += '&page2='+page2;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			dvd_montar_mant(page);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant_session3(page,id_dvd,tipo_dvd,page2)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	valores += '&page2='+page2;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			dvd_montar_mant3(page);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant_session4(page,id_dvd,tipo_dvd,page2)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	valores += '&page2='+page2;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			dvd_montar_mant4(page);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant(page)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function dvd_montar_mant3(page)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant3.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant4(page)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant4.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant_session2(page,id_dvd,tipo_dvd,page2)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	valores += '&page2='+page2;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant_session2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			dvd_montar_mant2(page);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function dvd_montar_mant2(page)
{
	
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	/*if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_montar_mant2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_modelo_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}

	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_modelo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_modelo_ver2(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}

	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_modelo_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_search_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}

	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_search_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//borrar_session();
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_search_fotoset_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}

	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_search_fotoset_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			//borrar_session();
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function borrar_session()
{
	
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./borrar_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
			
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function contenido_search_ver2(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}

	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_search_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_photoset_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_photoset_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contenido_photoset_ver2(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
    valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_photoset_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function contenido_soporte_ver()
{
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
    //valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./contenido_soporte_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}



function action_ver(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("action");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./action_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdaction").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdaction").innerHTML = ajax.responseText;
			 if(document.getElementById("id_dvd") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
						     solo_ver(id_dvd)
						}
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function action_ver2(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("action");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./action_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdaction").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdaction").innerHTML = ajax.responseText;
			 if(document.getElementById("id_dvd") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
						     solo_ver2(id_dvd)
						}
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function bareback_ver(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("barenack");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./bareback_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdbareback").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdbareback").innerHTML = ajax.responseText;
			  if(document.getElementById("id_dvd") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
						     solo_ver(id_dvd)
						}

		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function bareback_ver2(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("barenack");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./bareback_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdbareback").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdbareback").innerHTML = ajax.responseText;
			  if(document.getElementById("id_dvd") != null)
						{
							var id_dvd = document.getElementById("id_dvd").value;
						     solo_ver2(id_dvd)
						}

		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function solo_ver(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("solo");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./solo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdsolo").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdsolo").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function solo_ver2(id_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
			id_dvd = 1;
	}
    valores = 'id_dvd='+id_dvd;
	/*alert("solo");
	alert(valores);*/
	ajax = nuevoAjax();
	ajax.open("POST", "./solo_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdsolo").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdsolo").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function seleccion_paquete_completo_mant(id_dvd)
{
     valores  = 'id_dvd='+id_dvd;
	//alert (valores);
	var URL = "./../paginas/seleccion_paquete_completo_mant.php?"+valores;
	var ventana = window.open(URL,'seleccion_paquete_completo_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=450, height=200');
	if(ventana != null)
	{
		ventana.focus();
	}
}

function seleccion_paquete_video_mant(id_dvd)
{
     valores  = 'id_dvd='+id_dvd;
	//alert (valores);
	var URL = "./../paginas/seleccion_paquete_video_mant.php?"+valores;
	var ventana = window.open(URL,'seleccion_paquete_video_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=500, height=400');
	if(ventana != null)
	{
		ventana.focus();
	}
}

function ussuario_descargar_video_ecenas()
{
    
	var id_video = document.getElementById("id_video").value;
	var setfoto = document.getelementbyid('setfoto'+id_video).checked
    valores = 'id_video='+id_video;
	valores += '&setfoto='+setfoto;
	alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/ussuario_descargar_video_ecenas.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmensajes").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

//RECIBE UNA CADENA DE CARACTERES A QUITAR
function reemplazar_caracter(field, quitar)
{
	//alert(quitar);
	add = "";
	temp = "" + field;
	remover = quitar.split(";");
	while(temp.indexOf(remover[0]) > -1)
	{
		pos = temp.indexOf(remover[0]);
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + remover[0].length), temp.length));
	}
	while(temp.indexOf(remover[1]) > -1)
	{
		pos = temp.indexOf(remover[1]);
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + remover[1].length), temp.length));
	}
	while(temp.indexOf(remover[2]) > -1)
	{
		pos = temp.indexOf(remover[2]);
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + remover[2].length), temp.length));
	}
	//alert(temp);
	return temp;
}

function seleccion_descargar_video_ecenas(nombreF, cadena)
{
si = confirm('Please confirm you want to add this video to your downloads');
  if(si == true)
  {	
	var quitar = "&;|;#";//los valores a remover del formulario
	var Formulario = document.getElementById(nombreF);//recibe el id del formulario
	var longitud = Formulario.elements.length;
	var campos = "";
	var separador;
	//alert (Formulario);
	separador = "";
	sw = 0;
	cont = 0;
	inicio = 0;
	numero_de_campos = 3;//sirve para poner el separador maestro, si quiero poner dos campos coloco 3 en numero de campos
	j = 0;
	if(document.getElementById("mens1") != null)
	{
		inicio = inicio + 1;
	}
	if(document.getElementById("mens2") != null)
	{
		inicio = inicio + 1;
	}
	for (i = inicio; i < longitud; i++)
	{
		if(cont >= 0)
		{
			if(sw == 0)
			{
				separador = "";
				sw = 1;
			}
			else
			{
				separador = "|";
			}
			cont = cont + 1;
			if(cont == numero_de_campos)
			{
				separador = "#";
				cont = 1;
			}
		}
		if(Formulario.elements[i].type == "checkbox")
		{
			if(Formulario.elements[i].checked == true)
				val = 1;
			if(Formulario.elements[i].checked == false)
				val = 0;
			valorF = val;
		}
		if(Formulario.elements[i].type != "checkbox")
		{
			valorF = Formulario.elements[i].value;
		}
		valorF = reemplazar_caracter(valorF, quitar);
		campos += separador+Formulario.elements[i].id+'='+(valorF);
	}//
	valores = "campos="+campos;
	//alert(campos);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/seleccion_descargar_video_ecenas.php", true);			
	ajax.onreadystatechange=function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			document.getElementById("tdmensajes2").innerHTML = "&nbsp;Actualizando datos...";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdmensajes1").innerHTML = "";
			document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			if(document.getElementById("mens") != null)
			  {
					var mens = document.getElementById("mens").value;
					//alert(mens);
					if(mens == 1)
					{
						//alert("HAS AQUIRIDO ESTOS VIDEOS DESCARGUELO EN LA PAGINA DE DESCARGA.!");
						//alert("hola");
						if(document.getElementById("resultado") != null)
						{
							//alert("hola");
							//var nombreD = document.getElementById("nombreD").value;
							var resultado   = document.getElementById("resultado").value;
							var id_usuario  = document.getElementById("id_usuario").value;
							var dvd_credito = document.getElementById("video_credito").value;
							var id_dvd      = document.getElementById("id_dvd").value;
						    opener.descuento_credito_dvd(resultado, id_usuario, dvd_credito, id_dvd);
							window.close();
						}
						
					}
					if(mens == 2)
					{
						alert("ERROR try again")
					}
					if(mens == 3)
					{
						alert("ERROR try again")
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first.');
						comprar_credito_mant();
						window.close();
						
					}
					if(mens == 5)
					{
						if(document.getElementById("titulo_video") != null)
						{
						  var titulo_video = document.getElementById("titulo_video").value;
						  //alert(titulo_video);
						  alert("YA HAS AQUIRIDO ESTOS VIEDOS BUSCALO EN LA PAGINA DE DESCARGA.");
					    }
						
					}
					if(mens == 6)
					{
						
					  alert("DEBES SELECCIONAR ALGUNA ECENA....");
					    
						
					}
			  }
		 }
	 }
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
  }
}

function seleccion_ecenas_individual(id_video,id_dvd)

{
     valores  = 'id_video='+id_video;
	 valores  += '&id_dvd='+id_dvd;
	//alert (valores);
	var URL = "./../paginas/seleccion_ecenas_individual.php?"+valores;
	var ventana = window.open(URL,'seleccion_ecenas_individual','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=500, height=400');
	if(ventana != null)
	{
		ventana.focus();
	}
}

function seleccion_cheked(id_video,id_dvd)
{
    valores = 'id_video='+id_video;
	valores += '&id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/seleccion_cheked.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				if( (document.getElementById("i") != null) && (document.getElementById("i").value != "") )
				{
					var i = document.getElementById("i").value;
					//alert(i);
					document.getElementById("setfoto"+i).checked = 1;
					//alert("setfoto"+i);
					if(document.getElementById("setfoto"+i) != null)
					 {
					   suma_video(id_video,i);
					 }
					//alert(document.getElementById("setfoto"+i).checked);
				}
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function seleccion_descargar_video_ecenas2(nombreF, cadena)
{
si = confirm('You selected to download this video. After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
  if(si == true)
  {	
	var quitar = "&;|;#";//los valores a remover del formulario
	var Formulario = document.getElementById(nombreF);//recibe el id del formulario
	var longitud = Formulario.elements.length;
	var campos = "";
	var separador;
	//alert (Formulario);
	separador = "";
	sw = 0;
	cont = 0;
	inicio =1;
	numero_de_campos = 3;//sirve para poner el separador maestro, si quiero poner dos campos coloco 3 en numero de campos
	j = 0;
	if(document.getElementById("mens1") != null)
	{
		inicio = inicio + 1;
	}
	if(document.getElementById("mens2") != null)
	{
		inicio = inicio + 1;
	}
	for (i = inicio; i < longitud ; i++)
	{
		if(cont >= 0)
		{
			if(sw == 0)
			{
				separador = "";
				sw = 1;
			}
			else
			{
				separador = "|";
			}
			cont = cont + 1;
			if(cont == numero_de_campos)
			{
				separador = "#";
				cont = 1;
			}
		}
		if(Formulario.elements[i].type == "checkbox")
		{
			if(Formulario.elements[i].checked == true)
				val = 1;
			if(Formulario.elements[i].checked == false)
				val = 0;
			valorF = val;
		}
		if(Formulario.elements[i].type != "checkbox")
		{
			valorF = Formulario.elements[i].value;
		}
		valorF = reemplazar_caracter(valorF, quitar);
		campos += separador+Formulario.elements[i].id+'='+(valorF);
	}//
	valores = "campos="+campos;
	//alert(campos);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/seleccion_descargar_video_ecenas.php", true);			
	ajax.onreadystatechange=function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			document.getElementById("tdmensajes2").innerHTML = "&nbsp;Actualizando datos...";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdmensajes1").innerHTML = "";
			document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			if(document.getElementById("mens") != null)
			  {
					var mens = document.getElementById("mens").value;
					//alert(mens);
					if(mens == 1)
					{
						alert("HAS AQUIRIDO ESTOS VIDEOS DESCARGUELO EN LA PAGINA DE DESCARGA.!");
						//alert("hola");
						if(document.getElementById("resultado") != null)
						{
							//alert("hola");
							//var nombreD = document.getElementById("nombreD").value;
							var resultado   = document.getElementById("resultado").value;
							var id_usuario  = document.getElementById("id_usuario").value;
							var dvd_credito = document.getElementById("video_credito").value;
							var id_dvd      = document.getElementById("id_dvd").value;
						    opener.descuento_credito_dvd(resultado, id_usuario, dvd_credito, id_dvd);
							window.close();
						}
						
					}
					if(mens == 2)
					{
						alert("ERROR try again")
					}
					if(mens == 3)
					{
						alert("ERROR try again")
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first.');
						comprar_credito_mant();
						window.close();
						
					}
					if(mens == 5)
					{
						if(document.getElementById("titulo_video") != null)
						{
						  var titulo_video = document.getElementById("titulo_video").value;
						  //alert(titulo_video);
						  alert("YA HAS AQUIRIDO ESTOS VIEDOS BUSCALO EN LA PAGINA DE DESCARGA.");
					    }
						
					}
					if(mens == 6)
					{
						
					  alert("DEBES SELECCSIONAR ALGUNA ECENA.");
					    
						
					}
			  }
		 }
	 }
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
  }
}

function seleccion_ecenas_individual2(id_video,id_dvd,page)

{
     valores  = 'id_video='+id_video;
	 valores  += '&id_dvd='+id_dvd;
	 valores  += '&page='+page;
	//alert (valores);
	var URL = "./../paginas/seleccion_ecenas_individual2.php?"+valores;
	var ventana = window.open(URL,'seleccion_ecenas_individual2','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=0,top=0 ,width=500, height=400');
	if(ventana != null)
	{
		ventana.focus();
	}
}

function seleccion_descargar_video_ecenas3(nombreF, cadena)
{
si = confirm('You selected to download this video. After you click OK the download will start automatically. If you experience problems contact customer support using the form on the support page.');
  if(si == true)
  {	
	var quitar = "&;|;#";//los valores a remover del formulario
	var Formulario = document.getElementById(nombreF);//recibe el id del formulario
	var longitud = Formulario.elements.length;
	var campos = "";
	var separador;
	//alert (Formulario);
	separador = "";
	sw = 0;
	cont = 0;
	inicio = 1;
	numero_de_campos = 3;//sirve para poner el separador maestro, si quiero poner dos campos coloco 3 en numero de campos
	j = 0;
	if(document.getElementById("mens1") != null)
	{
		inicio = inicio + 1;
	}
	if(document.getElementById("mens2") != null)
	{
		inicio = inicio + 1;
	}
	for (i = inicio; i < longitud; i++)
	{
		if(cont >= 0)
		{
			if(sw == 0)
			{
				separador = "";
				sw = 1;
			}
			else
			{
				separador = "|";
			}
			cont = cont + 1;
			if(cont == numero_de_campos)
			{
				separador = "#";
				cont = 1;
			}
		}
		if(Formulario.elements[i].type == "checkbox")
		{
			if(Formulario.elements[i].checked == true)
				val = 1;
			if(Formulario.elements[i].checked == false)
				val = 0;
			valorF = val;
		}
		if(Formulario.elements[i].type != "checkbox")
		{
			valorF = Formulario.elements[i].value;
		}
		valorF = reemplazar_caracter(valorF, quitar);
		campos += separador+Formulario.elements[i].id+'='+(valorF);
	}//
	valores = "campos="+campos;
	//alert(campos);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/seleccion_descargar_video_ecenas2.php", true);			
	ajax.onreadystatechange=function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			document.getElementById("tdmensajes2").innerHTML = "&nbsp;Actualizando datos...";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdmensajes1").innerHTML = "";
			document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			if(document.getElementById("mens") != null)
			  {
					var mens = document.getElementById("mens").value;
					//alert(mens);
					if(mens == 1)
					{
						alert("HAS AQUIRIDO ESTOS VIDEOS DESCARGUELO EN LA PAGINA DE DESCARGA.!");
						//alert("hola");
						if(document.getElementById("resultado") != null)
						{
							//alert("hola");
							//var nombreD = document.getElementById("nombreD").value;
							var resultado   = document.getElementById("resultado").value;
							var id_usuario  = document.getElementById("id_usuario").value;
							var dvd_credito = document.getElementById("video_credito").value;
							var page        = document.getElementById("page").value;
							var id_dvd      = document.getElementById("id_dvd").value;
						    opener.descuento_credito_dvd2(resultado, id_usuario, dvd_credito, id_dvd);
							window.close();
						}
						
					}
					if(mens == 2)
					{
						alert("ERROR try again")
					}
					if(mens == 3)
					{
						alert("ERROR try again")
					}
					if(mens == 4)
					{
						alert('You have not enough credits to purchase this video, please add credits to your account first.');
						comprar_credito_mant();
						window.close();
					}
					if(mens == 5)
					{
						if(document.getElementById("titulo_video") != null)
						{
						  var titulo_video = document.getElementById("titulo_video").value;
						  //alert(titulo_video);
						  alert("YA HAS AQUIRIDO ESTOS VIEDOS BUSCALO EN LA PAGINA DE DESCARGA.");
					    }
						
					}
					if(mens == 6)
					{
						
					  alert("DEBES SELECCSIONAR ALGUNA ECENA.");
					    
						
					}
			  }
		 }
	 }
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
  }
}

function descuento_credito_dvd2(resultado, id_usuario, dvd_credito)
{
	/* if( (page == null) || (page == "")  )
	{
		page = 1;
	}*/
  /*if( (id_serie == null) || (id_serie == "")  )
	{
		id_serie = 1;
	}*/
	valores  = 'resultado='+resultado;
	valores  += '&id_usuario='+id_usuario;
	valores  += '&dvd_credito='+dvd_credito;
	//valores  += '&page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/descuento_credito_dvd.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{   
			    
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById("mens") != null)
				{
					var mens = document.getElementById("mens").value;
					//alert (mens);
					if(mens == 1)
					{
  					 alert('Your selected download is added to your downloads. "'+dvd_credito+'" credits were debited from your account. Please click OK to continue to your download page.You can always reach this page by clicking on "Your Downloads" in the box top right on your screen.');
				        //usuario_credito_ver2();
						contenido_downloads_ver();						
					}
					if(mens == 2)
					{
			 		   alert('ERROR INTENTE DE NUEVO.!');
					}
					
			}
		}
	}
   	
   ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
   ajax.send(valores);
}
function usuario_credito_ver2()
{
	//alert("hola")
	/*if( (page == null) || (page == "") ){
		page = 1;
	}*/
	//valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./usuario_credito_ver2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcreditover").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcreditover").innerHTML = ajax.responseText;
			  //alert(innerHTML=ajax.responseText);
			  if(document.getElementById("page") != null)
				{
				  var page = document.getElementById("page").value;
				  //usuario_midescarga_dvd(1);
				}
			//alert(innerHTML=ajax.responseText);
			//usuario_credito_ver();
		}
	}
	//usuario_midescarga_dvd(page);
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function buscar_models_session(page)
{

    if( (page == null) || (page == "")  )
	  {
		page = 1;
	  }
	valores  = 'page='+page;
	if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }

	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./buscar_models_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				buscar_models(1);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function buscar_models(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	/*if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./buscar_models.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function buscar_models_session2(page)
{

    if( (page == null) || (page == "")  )
	  {
		page = 1;
	  }
	valores  = 'page='+page;
	if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }

	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../buscar_models_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				buscar_models2(1);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function buscar_models2(page)
{

  if( (page == null) || (page == "")  )
	{
		page = 1;
	}
		
	valores  = 'page='+page;
	/*if(document.getElementById("busqueda") != null)
	 {
		valores += '&busqueda='+document.getElementById("busqueda").value;
	 }
	if(document.getElementById("nom_modelo") != null)
	 {
	   valores += '&nom_modelo='+document.getElementById("nom_modelo").value;
	 }
	 if(document.getElementById("id_serie") != null)
	 {
	  valores += '&id_serie='+document.getElementById("id_serie").value;
	 }
    if(document.getElementById("id_director") != null)
	 {
	   valores += '&id_director='+document.getElementById("id_director").value;
	 }
	if(document.getElementById("nom_categoria") != null)
	 {
		 valores += '&nom_categoria='+document.getElementById("nom_categoria").value;
	 }*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./buscar_models2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcontenido").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function seleccion_paquete_completo_new(id_dvd)
{
     valores  = 'id_dvd='+id_dvd;
	//alert (valores);
   var URL = "./../paginas/seleccion_paquete_completo_new.php?"+valores;
   var ventana = window.open(URL,'seleccion_paquete_completo_new','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=500, height=400');
	if(ventana != null)
	{
		ventana.focus();
	}
}

function seleccion_paquete_new_completo_mant(id_dvd)
{

  if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./seleccion_paquete_completo_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcomprarcompleto").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcomprarcompleto").innerHTML = ajax.responseText;
				seleccion_paquete_new_video_false(id_dvd)
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
}

function seleccion_paquete_completo_false(id_dvd)
{

  if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./seleccion_paquete_completo_false.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcomprarcompleto").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcomprarcompleto").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
}


function seleccion_paquete_new_video_mant(id_dvd)
{

  if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./seleccion_paquete_video_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcomprarscenas").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcomprarscenas").innerHTML = ajax.responseText;
				seleccion_paquete_completo_false(id_dvd);
				//alert(ajax.responseText);
			}
	}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
}

function seleccion_paquete_new_video_false(id_dvd)
{

  if( (id_dvd == null) || (id_dvd == "")  )
	{
		id_dvd = 1;
	}
		
	valores  = 'id_dvd='+id_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./seleccion_paquete_video_false.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdcomprarscenas").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdcomprarscenas").innerHTML = ajax.responseText;
				//busqueda_nombre_video_mant(1);
				//alert(ajax.responseText);
			}
	}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
}

function suma_video(id_video,i)
{
	
	valores  = 'id_video='+id_video;
	if(document.getElementById("setfoto"+i) != null)
	 {
		valores += '&setfoto='+document.getElementById("setfoto"+i).checked;
	 }
	//valores  += '&setfoto='+setfoto;
    //alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./suma_video_session.php", true);
	ajax.onreadystatechange = function()
	{
			if(ajax.readyState == 1)
			{
				document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				document.getElementById("tdmensajes2").innerHTML = "&nbsp; Cargando Credito...";
			}
			if(ajax.readyState == 4)
			{
				document.getElementById("tdmensajes1").innerHTML = "";
				document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				suma_video_ver(1);
				
				
			}
   }
 	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function suma_video_ver(page)
{
   
	if( (page == "") || (page == null) ) {
		page = 1;
	}
	valores  = 'page='+page;
	//alert(valores);
    ajax = nuevoAjax();
	ajax.open("POST", "./suma_video_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("idcreditover").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("idcreditover").innerHTML = ajax.responseText;
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
	//window.close(this);
}

function contactenos_guardar()
{
     var nombre		= document.getElementById("nombre").value;
	 var correo		= document.getElementById("correo").value;
	 //alert("");
	 var titulo		= document.getElementById("titulo").value;
	 var comentario	= document.getElementById("comentario").value;
	 var validar_mail2;
	
	if(correo != "") {
		validar_mail2 = submit_valida_mail("correo");
	 }
	
	//
	 if (  (nombre == "") || (correo == 1) || (titulo == "") || (comentario == "") )  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						
						if (nombre == ""){
						   mensaje += "=> NAME.\n";
						 } 
						 
						if (correo == ""){
						   mensaje += "=> E-MAIL.\n";
						 }
						 
					    if(validar_mail2 == 1){
						   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
						 }
						/*if(correo == "") {
							mensaje += "=> E-mail.\n";
						}*/
						if(titulo == "") {
							mensaje += "=> SUJECT.\n";
						}
						if(comentario == "") {
							mensaje += "=> COMENTARIO.\n";
						}
																	
					    alert(mensaje);
						return false;	
		
	    }
	   else
   	    {
		
			valores  = 'nombre='+nombre;
			valores += '&correo='+correo;
			valores += '&titulo='+titulo;
			valores += '&comentario='+comentario;

			ajax = nuevoAjax();
			ajax.open("POST", "./paginas/contactenos_guardar.php", true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var mens = document.getElementById("mens").value;
					//var id_modelo = document.getElementById("id_modelo").value;
					//alert(mens);
							  if(mens == 1)
								{
									alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED.");
									//alert("hola2");
									 var nombre  	= document.getElementById("nombre").value = "";
									 var correo 	= document.getElementById("correo").value = "";
									 var titulo		= document.getElementById("titulo").value = "";
									 var comentario	= document.getElementById("comentario").value = "";
									
								}
								if(mens == 2)
								{
									alert('ERROR try again.');
									//modelos_nuevos_ver();
								}
								
								if(mens == 3)
								{
									alert('ERROR try again.');
									
								}
								
								if(mens == 4)
								{
									alert('ERROR try again.');
									//modelos_nuevos_ver();
								}
								
				}
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function contactenos_guardar2()
{
     /*var nombre		= document.getElementById("nombre").value;
	 var correo		= document.getElementById("correo").value;*/
	 //alert("");
	 var titulo		= document.getElementById("titulo").value;
	 var comentario	= document.getElementById("comentario").value;
	 //var validar_mail2;
	
	/*if(correo != "") {
		validar_mail2 = submit_valida_mail("correo");
	 }*/
	
	//
	 if (  (titulo == "") || (comentario == "") )  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						
						/*if (nombre == ""){
						   mensaje += "=> NAME.\n";
						 } 
						 
						if (correo == ""){
						   mensaje += "=> E-MAIL.\n";
						 }
						 
					    if(validar_mail2 == 1){
						   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
						 }*/
						/*if(correo == "") {
							mensaje += "=> E-mail.\n";
						}*/
						if(titulo == "") {
							mensaje += "=> SUJECT.\n";
						}
						if(comentario == "") {
							mensaje += "=> COMENTARIO.\n";
						}
																	
					    alert(mensaje);
						return false;	
		
	    }
	   else
   	    {
		
			/*valores  = 'nombre='+nombre;
			valores += '&correo='+correo;*/
			valores = 'titulo='+titulo;
			valores += '&comentario='+comentario;

			ajax = nuevoAjax();
			ajax.open("POST", "./contactenos_guardar.php", true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var mens = document.getElementById("mens").value;
					//var id_modelo = document.getElementById("id_modelo").value;
					//alert(mens);
							  if(mens == 1)
								{
									alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED.");
									//alert("hola2");
									 /*var nombre  	= document.getElementById("nombre").value = "";
									 var correo 	= document.getElementById("correo").value = "";*/
									 var titulo		= document.getElementById("titulo").value = "";
									 var comentario	= document.getElementById("comentario").value = "";
									
								}
								if(mens == 2)
								{
									alert('ERROR try again.');
									//modelos_nuevos_ver();
								}
								
								if(mens == 3)
								{
									alert('ERROR try again.');
									
								}
								
								if(mens == 4)
								{
									alert('ERROR try again.');
									//modelos_nuevos_ver();
								}
								
				}
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function comprar_credito_mant()
{
  //valores  = 'id_dvd='+id_dvd;
  //alert (valores);
  var URL = "./comprar_credito_mant.php";
  var ventana = window.open(URL,'comprar_registro','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function comprar_credito(page)
{
	 if( (page == "") || (page == null) ) {
		page = 1;
	   }
     var compra7      = document.getElementById("compra7");
	 var compra12     = document.getElementById("compra12");
	 var compra25     = document.getElementById("compra25");
	 var compra50     = document.getElementById("compra50");
	 var compra80     = document.getElementById("compra80");
	 var compra100    = document.getElementById("compra100");
	 var compra125    = document.getElementById("compra125");
	 var compra250    = document.getElementById("compra250");
	 var compra501    = document.getElementById("compra501");
	 var compra802    = document.getElementById("compra802");
	 var compra1003   = document.getElementById("compra1003");
	 var compra1254   = document.getElementById("compra1254");
	 var compra2505   = document.getElementById("compra2505");
	 var verotel      = document.getElementById("verotel");
	 var webbilling   = document.getElementById("webbilling");
	 var westerngrang = document.getElementById("westerngran");
	 var banco        = document.getElementById("banco");
	
	//
	 if ( ((compra7.checked == 0) && (compra12.checked == 0) && (compra25.checked == 0) && (compra50.checked == 0) && (compra80.checked == 0) && (compra100.checked == 0) && 
			 (compra125.checked == 0) && (compra250.checked == 0) && (compra501.checked == 0) && (compra802.checked == 0) && (compra1003.checked == 0) && 
			 (compra1254.checked == 0) && (compra2505.checked == 0) ) || ( (verotel.checked == 0) && (webbilling.checked == 0) && (westerngrang.checked == 0) && (banco.checked == 0) ) )  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						if ( (compra7.checked == 0) && (compra12.checked == 0) && (compra25.checked == 0) && (compra50.checked == 0) && (compra80.checked == 0) && 
							  (compra100.checked == 0) && (compra125.checked == 0) && (compra250.checked == 0) && (compra501.checked == 0) && (compra802.checked == 0) &&
							  (compra1003.checked == 0) &&  (compra1254.checked == 0) && (compra2505.checked == 0)){
						   		mensaje += "=> DEBES ESCOGER LOS CREDITOS QUE DESEAS COMPRAR.\n";
						 } 
						 
						if ( (verotel.checked == 0) && (webbilling.checked == 0) && (westerngrang.checked == 0) && (banco.checked == 0) ){
						   mensaje += "=> DEBES ESCOGER EL SISTEMAS DE COMPRE.\n";
						 }
						 
						alert(mensaje);
						return false;
					    
		
	    }
	   else
   	    {
		
			valores  = 'page='+page;
			if(compra7.checked == 1){
				compra7 = 1;
				valores += '&compra7='+compra7;
			}
			if(compra12.checked == 1){
				compra12 = 1;
				valores += '&compra12='+compra12;
			}
			if(compra25.checked == 1){
				compra25 = 1;
				valores += '&compra25='+compra25;
			}
			if(compra50.checked == 1){
				compra50 = 1;
				valores += '&compra50='+compra50;
			}
			if(compra80.checked == 1){
				compra80 = 1;
				valores += '&compra80='+compra80;
			}
			if(compra100.checked == 1){
				compra100 = 1;
				valores += '&compra100='+compra100;
			}
			if(compra125.checked == 1){
				compra125 = 1;
				valores += '&compra125='+compra125;
			}
			if(compra250.checked == 1){
				compra250 = 1;
				valores += '&compra250='+compra250;
			}
			if(compra501.checked == 1){
				compra501 = 1;
				valores += '&compra501='+compra501;
			}
			if(compra802.checked == 1){
				compra802 = 1;
				valores += '&compra802='+compra802;
			}
			if(compra1003.checked == 1){
				compra1003 = 1;
				valores += '&compra1003='+compra1003;
			}
			if(compra1254.checked == 1){
				compra1254 = 1;
				valores += '&compra1254='+compra1254;
			}
			if(compra2505.checked == 1){
				compra2505 = 1;
				valores += '&compra2505='+compra2505;
			}
			if(verotel.checked == 1){
				verotel = 1;
				valores += '&verotel='+verotel;
			}
			if(webbilling.checked == 1){
				webbilling = 1;
				valores += '&webbilling='+webbilling;
			}
			if(banco.checked == 1){
				banco = 1;
				valores += '&banco='+banco;
			}
			if(westerngrang.checked == 1){
				westerngrang = 1;
				valores += '&westerngrang='+westerngrang;
			}
		    //alert(valores);
			ajax = nuevoAjax();
			ajax.open("POST", "./comprar_credito.php", true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var verotel = document.getElementById("verotel").value;
					//var merchantid = document.getElementById("merchantid").value;
					//alert(verotel);
				    if(verotel == 1)
					   {	
							var shopID        = document.getElementById("shopID").value;
							var version       = document.getElementById("version").value;
							var priceAmount   = document.getElementById("priceAmount").value;
							var priceCurrency = document.getElementById("priceCurrency").value;
							var description   = document.getElementById("description").value;
							var signature     = document.getElementById("signature").value;
							var referenceID   = document.getElementById("referenceID").value;
							/*alert(signature);
							alert(referenceID);*/
							pagina_verotel(shopID,version,priceAmount,priceCurrency,description,signature,referenceID);
							window.close();
					   }
					//var merchantid = document.getElementById("merchantid").value;
					var webbilling = document.getElementById("webbilling").value;
					//alert(webbilling);
				    if(webbilling == 1)
					   {	
					        var merchantid       = document.getElementById("merchantid").value;
							var merchantpass     = document.getElementById("merchantpass").value;
							var desc             = document.getElementById("desc").value;
							var email            = document.getElementById("email").value;
							var product_code     = document.getElementById("product_code").value;
							var product_amount   = document.getElementById("product_amount").value;
							var product_currency = document.getElementById("product_currency").value;
							var post_back_url    = document.getElementById("post_back_url").value;
							var callback_url     = document.getElementById("callback_url").value;
							var return_url       = document.getElementById("return_url").value;
							var jumpback_url     = document.getElementById("jumpback_url").value;
							var domain           = document.getElementById("domain").value;
							var bank_stmt_descr  = document.getElementById("bank_stmt_descr").value;
							var processor_id     = document.getElementById("processor_id").value;
							var pt1              = document.getElementById("pt1").value;
							//alert(post_back_url);
  pagina_webbilling(merchantid,merchantpass,desc,email,product_code,product_amount,product_currency,post_back_url,callback_url,return_url,jumpback_url,domain,bank_stmt_descr,processor_id,pt1);
							window.close();
					   }  
					var banco = document.getElementById("banco").value;
					//alert(banco);
				    if(banco == 1)
					   {	

							var precio       = document.getElementById("precio").value;
							var decripcion = document.getElementById("decripcion").value;
							/*alert(precio);
							alert(decripcion);*/
							pagina_banco(precio,decripcion);
							window.close();
					   }   
					var westerngrang = document.getElementById("westerngrang").value;
					//alert(westerngrang);
				    if(westerngrang == 1)
					   {	

							var precio       = document.getElementById("precio").value;
							var decripcion = document.getElementById("decripcion").value;
							/*alert(precio);
							alert(decripcion);*/
							pagina_westerngrang(precio,decripcion);
							window.close();
					   }
					
					
				 }
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function pagina_westerngrang(precio,decripcion)
{
  
  valores  = 'precio='+precio;
  valores += '&descripcion='+decripcion;
  //alert (referenceID);
  //alert (valores);
  var URL = "./pagina_westerngrang.php?"+valores;
  var ventana = window.open(URL,'pagina_westerngrang','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=640');
  if(ventana != null)
	{
		ventana.focus();
	}
}
function enviar_correo(precio,sistema)
{
   
	valores  = 'precio='+precio;
	valores += '&sistema='+sistema;
	//alert(valores);
    ajax = nuevoAjax();
	ajax.open("POST", "./enviar_correo.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdmesajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdmesajes").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			window.close();
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
	//window.close(this);
}
function pagina_banco(precio,decripcion)
{
  
  valores  = 'precio='+precio;
  valores += '&descripcion='+decripcion;
  //alert (referenceID);
  //alert (valores);
  var URL = "./pagina_banco.php?"+valores;
  var ventana = window.open(URL,'pagina_banco','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=800');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function pagina_verotel(shopID,version,priceAmount,priceCurrency,description,signature,referenceID)
{
  //alert("hola");
  valores  = 'shopID='+shopID;
  valores += '&version='+version;
  valores += '&priceAmount='+priceAmount;
  valores += '&priceCurrency='+priceCurrency;
  valores += '&description='+description;
  valores += '&referenceID='+referenceID;
  valores += '&signature='+signature;
  //alert (referenceID);
  //alert (valores);
  var URL = "https://secure.verotel.com/order/purchase?"+valores;
  var ventana = window.open(URL,'pagina_verotel','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function pagina_webbilling(merchantid,merchantpass,desc,email,product_code,product_amount,product_currency,post_back_url,callback_url,return_url,jumpback_url,domain,bank_stmt_descr,processor_id,pt1)
{
  //alert("hola");
  valores  = 'merchantid='+merchantid;
  valores += '&merchantpass='+merchantpass;
  valores += '&desc='+desc;
  valores += '&email='+email;
  valores += '&product_code='+product_code;
  valores += '&product_amount='+product_amount;
  valores += '&product_currency='+product_currency;
  valores += '&post_back_url='+post_back_url;
  valores += '&callback_url='+callback_url;
  valores += '&return_url='+return_url;
  valores += '&jumpback_url='+jumpback_url;
  valores += '&domain='+domain;
  valores += '&bank_stmt_descr='+bank_stmt_descr;
  valores += '&processor_id='+processor_id
  valores += '&pt1='+pt1
  //alert (valores);
  //var URL = "http://testjoinpage.webbilling.com/?"+valores;
  var URL = "https://joinpage.webbilling.com/?"+valores;
  var ventana = window.open(URL,'pagina_webbilling','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function compra_dolares()
{
   
	//alert(valores);
    ajax = nuevoAjax();
	ajax.open("POST", "./compra_dolares.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tddolares").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tddolares").innerHTML = ajax.responseText;
			compra_euros_false()
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
	//window.close(this);
}

function compra_euros()
{
   
	//alert("hola");
    ajax = nuevoAjax();
	ajax.open("POST", "./compra_euros.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdeuros").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdeuros").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			compra_dolares_false();
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
	//window.close(this);
}
function compra_dolares_false()
{
   
	//alert(valores);
    ajax = nuevoAjax();
	ajax.open("POST", "./compra_dolares_false.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tddolares").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tddolares").innerHTML = ajax.responseText;
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
	//window.close(this);
}

function compra_euros_false()
{
   
	//alert("hola");
    ajax = nuevoAjax();
	ajax.open("POST", "./compra_euros_false.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdeuros").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdeuros").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
	//window.close(this);
}

function compra_bancarias()
{
   
	//alert("hola");
    ajax = nuevoAjax();
	ajax.open("POST", "./compra_bancarias.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdbancarias").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdbancarias").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
		}
	}
	/**/
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
	//window.close(this);
}


/*function confirmacion_nueva_verotel()
{
  
 /* valores  = 'merchantid='+merchantid;
  valores += '&merchantpass='+merchantpass;
  valores += '&desc='+desc;
  valores += '&email='+email;
  valores += '&product_code='+product_code;
  valores += '&product_amount='+product_amount;
  valores += '&product_currency='+product_currency;*/
 /* alert ("valores");
  var URL = "http://testjoinpage.webbilling.com/?"+valores;
  var ventana = window.open(URL,'pagina_verotel','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}*/

/*function confirmacion_verotel_cliente_mant(name,email,saleID,shopID,priceAmount,priceCurrency,referenceID,saleResult)
//confirmacion_verotel_cliente_mant(response,name,email,saleID,shopID,priceAmount,priceCurrency,description,referenceID,paymentMethod,tsCreated,saleResult,billingAddr_fullName,billingAddr_company,billingAddr_addressLine1,billingAddr_addressLine2,billingAddr_city,billingAddr_zip,billingAddr_state,billingAddr_country,shippingAddr_fullName,shippingAddr_company,shippingAddr_addressLine1,shippingAddr_addressLine2,shippingAddr_city,shippingAddr_zip,shippingAddr_state,shippingAddr_country)
{
  
  valores  = 'name='+name;
  alert(name);
  valores += '&email='+email;
  valores += '&saleID='+saleID;
  valores += '&shopID='+shopID;
  valores += '&priceAmount='+priceAmount;
  valores += '&priceCurrency='+priceCurrency;
  //valores += '&description='+description;
  //valores += '&firma='+firma;
  valores += '&referenceID='+referenceID;
 // valores += '&paymentMethod='+paymentMethod;
  //valores += '&tsCreated='+tsCreated;
  valores += '&saleResult='+saleResult;
 /* valores += '&billingAddr_fullName='+billingAddr_fullName;
  valores += '&billingAddr_company='+billingAddr_company;
  valores += '&billingAddr_addressLine1='+billingAddr_addressLine1;
  valores += '&billingAddr_addressLine2='+billingAddr_addressLine2;
  valores += '&billingAddr_city='+billingAddr_city;
  valores += '&billingAddr_zip='+billingAddr_zip;
  valores += '&billingAddr_state='+billingAddr_state;
  valores += '&billingAddr_country='+billingAddr_country;
  valores += '&shippingAddr_fullName='+shippingAddr_fullName;
  valores += '&hippingAddr_company='+hippingAddr_company;
  valores += '&shippingAddr_addressLine1='+shippingAddr_addressLine1;
  valores += '&shippingAddr_addressLine2='+shippingAddr_addressLine2;
  valores += '&shippingAddr_city='+shippingAddr_city;
  valores += '&shippingAddr_zip='+shippingAddr_zip;
  valores += '&shippingAddr_state='+shippingAddr_state;
  valores += '&shippingAddr_country='+shippingAddr_country;*/

  /*alert (valores);
  var URL = "./confirmacion_verotel_cliente_mant?"+valores;
  var ventana = window.open(URL,'confirmacion_verotel_cliente_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=600');
  if(ventana != null)
	{
		ventana.focus();
	}
}*/




function modelo_comentario_max(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_modelo='+id_modelo;
	valores += '&id='+id;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_comentario_max.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function modelo_comentario_max2(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	if( (id == null) || (id == "") ){
		id = 1;
	}*/
	valores = 'page='+page;
	/*valores += '&id_modelo='+id_modelo;
	valores += '&id='+id;*/
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_comentario_max2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function ventana_2257informatio()
{

  var URL = "./../paginas/ventana_2257informatio.php";
  var ventana = window.open(URL,'ventana_2257informatio','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=600');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function ventana_condiciones()
{

  var URL = "./../paginas/ventana_condiciones.php";
  var ventana = window.open(URL,'ventana_condiciones','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=600');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function ventana_2257informatio2()
{

  var URL = "./paginas/ventana_2257informatio.php";
  var ventana = window.open(URL,'ventana_2257informatio','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=600');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function ventana_condiciones2()
{

  var URL = "./paginas/ventana_condiciones.php";
  var ventana = window.open(URL,'ventana_condiciones','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=600');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function recargar_pagina()
{
	  //alert("hola");
	  
	  //top.location.href = "./../index.php";
	  alert("your transaction is complete please refresh the homepage");
	  //prueba();
	  window.close();
	  opener.usuario_credito_ver();
	 
}

function modelo_video_session_ver(page,id_modelo)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores  = 'page='+page;
	valores += '&id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_video_session_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdvideosetfoto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdvideosetfoto").innerHTML = ajax.responseText;
			//alert(innerHTML = ajax.responseText);
			modelo_video_ver(page);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function modelo_video_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	valores  = 'page='+page;
	//valores += '&id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_video_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdvideosetfoto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdvideosetfoto").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function modelo_setfoto_ver_session(page,id_modelo)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores  = 'page='+page;
	valores += '&id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_setfoto_ver_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdvideosetfoto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdvideosetfoto").innerHTML = ajax.responseText;
			modelo_setfoto_ver(1);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function modelo_setfoto_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	/*if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}*/
	valores  = 'page='+page;
	//valores += '&id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelo_setfoto_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdvideosetfoto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdvideosetfoto").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function usuario_donaciones_mant()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./donations/usuario_donaciones_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function usuario_donaciones_mant2()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./../donations/usuario_donaciones_mant2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdcontenido").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdcontenido").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function texto_mail_adicionar_credito()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./donations/texto_mail_adicionar_credito.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdtexto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdtexto").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}
function texto_mail_adicionar_credito2()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./../donations/texto_mail_adicionar_credito2.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdtexto").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdtexto").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}

function texto_enviar_mail()
{
     var texto		  = document.getElementById("texto").value;
	 var send_anonimo = document.getElementById("send_anonimo");
	 var send_mailR	  = document.getElementById("send_mailR");
	 var send_mail 	  = document.getElementById("send_mail").value;
	 
       if(send_mailR.checked == 1)
	    {
			 var validar_mail;
			 if(send_mail != "") {
				validar_mail = submit_valida_mail("send_mail");
			 }
		}
	 
	 if( (texto == "") || ( (send_mailR.checked == 1) && (send_mail == "") ) || (validar_mail == 1) || ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ) ) 
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						
						if (texto == ""){
						   mensaje += "=>YOU NEED TO TYPE SOMETHING.\n";
						 } 
						if ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ){
						   mensaje += "=>PLEASE SELECT SOME SEND OPTION .\n";
						 }
					   if((send_mailR.checked == 1) && (send_mail == "") )
	    				{
							if(send_mail == ""){
							   mensaje += "=> E-MAIL\n"
							 } 	
						}
					   if(validar_mail == 1){
							   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
							 }
					   alert(mensaje);
					   return false;	
		
	    }
	   else
   	    {
		
			valores  = 'texto='+texto;
			if(send_anonimo.checked == 1){
				send_anonimo = "Anonymously";
				valores += '&send_anonimo='+send_anonimo;
			}
			
			if(send_mailR.checked == 1){
				if(send_mail != ""){
					valores += '&send_mail='+send_mail;
				}
				
			}
			//alert(valores);
			ajax = nuevoAjax();
			ajax.open("POST", "./donations/texto_enviar_mail.php", true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdtexto").innerHTML = "<img src='./images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdtexto").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var mens = document.getElementById("mens").value;
				    if(mens == 1)
					  {
						  alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED.");
						  usuario_donaciones_mant();
						  
					  }
					  if(mens == 2)
					  {
						  alert('ERROR TRY AGAIN.');
						  //modelos_nuevos_ver();
					  }
					  
								
				}
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function texto_enviar_mail2()
{
     var texto		  = document.getElementById("texto").value;
	 var send_anonimo = document.getElementById("send_anonimo");
	 var send_mailR	  = document.getElementById("send_mailR");
	 var send_mail 	  = document.getElementById("send_mail").value;
	 
       if(send_mailR.checked == 1)
	    {
			 var validar_mail;
			 if(send_mail != "") {
				validar_mail = submit_valida_mail("send_mail");
			 }
		}
	 
	 if( (texto == "") || ( (send_mailR.checked == 1) && (send_mail == "") ) || (validar_mail == 1) || ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ) ) 
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						
						if (texto == ""){
						   mensaje += "=>YOU NEED TO TYPE SOMETHING.\n";
						 } 
						if ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ){
						   mensaje += "=>PLEASE SELECT SOME SEND OPTION .\n";
						 }
					   if((send_mailR.checked == 1) && (send_mail == "") )
	    				{
							if(send_mail == ""){
							   mensaje += "=> E-MAIL\n"
							 } 	
						}
					   if(validar_mail == 1){
							   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
							 }
					   alert(mensaje);
					   return false;	
		
	    }
	   else
   	    {
		
			valores  = 'texto='+texto;
			if(send_anonimo.checked == 1){
				send_anonimo = "Anonymously";
				valores += '&send_anonimo='+send_anonimo;
			}
			
			if(send_mailR.checked == 1){
				if(send_mail != ""){
					valores += '&send_mail='+send_mail;
				}
				
			}
			//alert(valores);
			ajax = nuevoAjax();
			ajax.open("POST", "./../donations/texto_enviar_mail.php", true);
			ajax.onreadystatechange = function()
			{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdtexto").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdtexto").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var mens = document.getElementById("mens").value;
				    if(mens == 1)
					  {
						  alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED.");
						  usuario_donaciones_mant();
						  
					  }
					  if(mens == 2)
					  {
						  alert('ERROR TRY AGAIN.');
						  //modelos_nuevos_ver();
					  }
					  
								
				}
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function compra_donacion_mant()
{
  usuario_donaciones_mant();	
  var URL = "./donations/compra_donacion_mant.php";
  var ventana = window.open(URL,'compra_donacion_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=800');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function compra_donacion_mant2()
{
  usuario_donaciones_mant2();	
  var URL = "./../donations/compra_donacion_mant.php";
  var ventana = window.open(URL,'compra_donacion_mant','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function compra_donacion_texto()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./compra_donacion_texto.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tddonacionbancarias").innerHTML = "<img src='./images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tddonacionbancarias").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);//*/
}


function comprar_credito_donacion()
{
     var numero_pirata  = document.getElementById("numero_pirata").value;
	 var donacion       = document.getElementById("donacion").value;
	//alert(donacion);
	 if( (document.getElementById("comentario").value != "") || (document.getElementById("comentario").value != null))
	 {
		var comentario     = document.getElementById("comentario").value;  
	 }
	 var verotel        = document.getElementById("verotel");
	 var westerngrang   = document.getElementById("westerngran");
	 var banco          = document.getElementById("banco");
	 var send_anonimo = document.getElementById("send_anonimo");
	 var send_mailR	  = document.getElementById("send_mailR");
	 var send_mail 	  = document.getElementById("send_mail").value;
	 
       if(send_mailR.checked == 1)
	    {
			 var validar_mail;
			 if(send_mail != "") {
				validar_mail = submit_valida_mail("send_mail");
			 }
		}
	
	//
	 if (  (donacion < 5) || (donacion == "") ||  ( (verotel.checked == 0) && (westerngrang.checked == 0) && (banco.checked == 0) ) || ( (send_mailR.checked == 1) && (send_mail == "") )
	          || (validar_mail == 1) || ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ))  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						/*if ( (numero_pirata == "") ){
						   		mensaje += "=> Please check if pop-ups are allowed for this website Without pop-ups your browser blocks the process.\n";
						 } */
						if ( (donacion == "") ){
						   		mensaje += "=> Please check if pop-ups are allowed for this website Without pop-ups your browser blocks the process.\n";
						 }
						 if ( (donacion < 5) ){
						   		mensaje += "=> minimum contribution is 5 US dollars, because of the need to cover transaction costs.\n";
						 }  
						 if ( (verotel.checked == 0) && (westerngrang.checked == 0) && (banco.checked == 0) ){
						   mensaje += "=> YOU NEED TO CLICK SOME METHOD OF PAYMENT.\n";
						 }
						 if ( (send_anonimo.checked == 0) && (send_mailR.checked == 0) ){
						   mensaje += "=>PLEASE SELECT SOME SEND OPTION .\n";
						 }
					   if((send_mailR.checked == 1) && (send_mail == "") )
	    				{
							if(send_mail == ""){
							   mensaje += "=> E-MAIL\n"
							 } 	
						}
					   if(validar_mail == 1){
							   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
							 }
						 
						alert(mensaje);
						return false;
					    
		
	    }
	   else
   	    {
		 
		  valores  = 'donacion='+donacion;
			if( (numero_pirata != "") || (numero_pirata != null) ) {
				valores += '&numero_pirata='+numero_pirata;
			}
			if(comentario != ""){
				valores += '&comentario='+comentario;
			}
			if(comentario != ""){
				valores += '&comentario='+comentario;
			}
			if(verotel.checked == 1){
				verotel = 1;
				valores += '&verotel='+verotel;
			}
  		 if(banco.checked == 1){
				banco = 1;
				valores += '&banco='+banco;
			}
			if(westerngrang.checked == 1){
				westerngrang = 1;
				valores += '&westerngrang='+westerngrang;
			}
			if(send_anonimo.checked == 1){
				send_anonimo = "Anonymously";
				valores += '&send_anonimo='+send_anonimo;
			}
			
			if(send_mailR.checked == 1){
				if(send_mail != ""){
					valores += '&send_mail='+send_mail;
				}
				
			}
		    //alert(valores);
			ajax = nuevoAjax();
			ajax.open("POST", "./comprar_credito_donacion.php", true);
			ajax.onreadystatechange = function()
		{
				if (ajax.readyState == 1)
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./images/loading.gif' border='0'>";
					
				}
				if (ajax.readyState == 4)
				{
					document.getElementById("tdmensajes").innerHTML = ajax.responseText;
					//alert(innerHTML=ajax.responseText);
					var verotel = document.getElementById("verotel").value;
					//var merchantid = document.getElementById("merchantid").value;
					//alert(verotel);
				    if(verotel == 1)
					   {	
							var shopID        = document.getElementById("shopID").value;
							var version       = document.getElementById("version").value;
							var priceAmount   = document.getElementById("priceAmount").value;
							var priceCurrency = document.getElementById("priceCurrency").value;
							var custom1       = document.getElementById("custom1").value;
							var custom2       = document.getElementById("custom2").value;
							var description   = document.getElementById("description").value;
							var signature     = document.getElementById("signature").value;
							var referenceID   = document.getElementById("referenceID").value
							pagina_verotel_donacion(shopID,version,priceAmount,priceCurrency,custom1,custom2,description,signature,referenceID);
							window.close();
					   }
					var banco = document.getElementById("banco").value;
					//alert(banco);
				    if(banco == 1)
					   {	
						    pagina_banco_donacion();
							window.close();
					   }   
					var westerngrang = document.getElementById("westerngrang").value;
					//alert(westerngrang);
				    if(westerngrang == 1)
					   {	
							pagina_westerngrang_donacion();
							window.close();
					   }
					
					
				 }
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function pagina_verotel_donacion(shopID,version,priceAmount,priceCurrency,custom1,custom1,description,signature,referenceID)
{
  
  valores  = 'shopID='+shopID;
  valores += '&version='+version;
  valores += '&priceAmount='+priceAmount;
  valores += '&priceCurrency='+priceCurrency;
  valores += '&description='+description;
  valores += '&referenceID='+referenceID
  valores += '&signature='+signature;
   //alert (referenceID);
  //alert (valores);
  var URL = "https://secure.verotel.com/order/purchase?"+valores;
  var ventana = window.open(URL,'pagina_verotel_donacion','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=1024, height=780');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function correo_enviar_mail()
{
	var correo              = document.getElementById("correo").value;
	var correo2             = document.getElementById("correo2").value;

	
	var validar_mail;
	if(correo != "") {
		validar_mail = submit_valida_mail("correo");
	}
	//alert(pais);
//if(password == password2)
 //{
	if( (correo == "") || (correo2== "")  )
	{
		                mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						if(correo == "") {
							mensaje += "=> E-mail.\n";
						}
						if(correo2 == "") {
							mensaje += "=> Confirm Your E-mail.\n";
						}
					    if(validar_mail == 1){
						   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS\n"
						 }
						if( ( (correo2 != "")&&(correo != "")&&(correo2 != correo) ) || (correo2 != "") || (correo != "")  ) {
							mensaje += "=> CONFIRMATION PASSWORD MUST BE THE SAME E-MAIL.\n";
							document.getElementById("correo").value = "";
							document.getElementById("correo2").value = "";
							document.getElementById("correo").focus();
						}
					
											
						alert(mensaje);
						return false;	
		
	}
	else
	{
		
		valores  = 'correo='+correo;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./correo_enviar_mail.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
				document.getElementById("tdmensajes2").innerHTML = "&nbsp;Downloads...";
			}
			if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes1").innerHTML = "";
				document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
				if(document.getElementById("mens") != null)
				{
					mens = document.getElementById("mens").value;
					if(mens == 1)
					{
						alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED.");
						var correo              = document.getElementById("correo").value = "";
						var correo2             = document.getElementById("correo2").value = "";
					}
					if(mens == 2)
					{
						alert('Error Try.');
					}
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
	}
}

function pagina_westerngrang_donacion()
{
  
  /*valores  = 'precio='+precio;
  valores += '&descripcion='+decripcion;*/
  //alert (referenceID);
  //alert (valores);
  var URL = "./../pagina_westerngrang_donacion.php?"+valores;
  var ventana = window.open(URL,'pagina_westerngrang_donacion','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=640');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function pagina_banco_donacion()
{
  
  /*valores  = 'precio='+precio;
  valores += '&descripcion='+decripcion;
  //alert (referenceID);*/
  //alert (valores);
  var URL = "./../pagina_banco_donacion.php?"+valores;
  var ventana = window.open(URL,'pagina_banco_donacion','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=0,top=0 ,width=800, height=800');
  if(ventana != null)
	{
		ventana.focus();
	}
}

function usuario_olvido_contrasena()
{
	var URL = "./usuario_olvido_contrasena.php";
	//location.href = URL;
	var busqueda;
	busqueda= window.open(URL, 'usuario_olvido_contrasena','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0, left=20,top=10 ,width=260, height=220');
	if(busqueda!= null)
	{
		busqueda.focus();
	}
}

function usuario_mandar_contrasena(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	var email    = document.getElementById("email").value;
	mensaje = "NOT ALL FIELDS ARE FILLED OUT, PLEASE COMPLETE THE FORM:\n\n";
	var validar_mail;
	if(email != "") {
		validar_mail = submit_valida_mail("email");
	}
		if( (email== "") || (validar_mail == 1) ) {
							   
		   if (email == ""){
			   mensaje += "=> E-MAIL.\n";
			 }
		   if(validar_mail == 1){
			   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS.\n"
			 }
	
			alert(mensaje);
			return false;
	}
	else
	{
		valores = 'email='+email;
		//alert (valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./usuario_mandar_contrasena.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			}
			if (ajax.readyState == 4)
			{
				document.getElementById("tdmensajes").innerHTML = ajax.responseText;
				var mens = document.getElementById("mens").value;
					//alert(mens);
					  if(mens == 1)
						{
							alert("Your password has been sent to your e-mail, please check it")
							window.close(this);
						}
					 if(mens == 2)
						{
							alert('ERROR the e-mail address does not exist.');
						}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);//*/
	}
}
