//funcion para manejar cajas de texto con solo numeros
function int_data()
{ 
	var key = event.keyCode;//código de tecla. 
	if (key < 48 || key > 57)
	{//si no es número.
		event.keyCode = 0;//anula la entrada de texto. 
	}
}

//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;
}

//COMPARAR DOS FECHAS
function comparar_fechas(fecha1, fecha2) 
{
	String1 = fecha1;
	String2 = fecha2;
	// Si los dias y los meses llegan con un valor menor que 10 
	// Se concatena un 0 a cada valor dentro del string 
	if(String1.substring(1,2) == "/")
	{
		String1 = "0"+String1
	}
	if(String1.substring(4,5) == "/")
	{
		String1 = String1.substring(0,3)+"0"+String1.substring(3,9)
	}
	if(String2.substring(1,2) == "/")
	{
		String2 = "0"+String2
	}
	if(String2.substring(4,5) == "/")
	{
		String2 = String2.substring(0,3)+"0"+String2.substring(3,9)
	}
	dia1  = String1.substring(0,2);
	mes1  = String1.substring(3,5);
	anyo1 = String1.substring(6,10);
	dia2  = String2.substring(0,2);
	mes2  = String2.substring(3,5);
	anyo2 = String2.substring(6,10);
	
	if(dia1 == "08") // parseInt("08") == 10 base octogonal
		dia1 = "8";
	if(dia1 == '09') // parseInt("09") == 11 base octogonal
		dia1 = "9";
	if(mes1 == "08") // parseInt("08") == 10 base octogonal
		mes1 = "8";
	if(mes1 == "09") // parseInt("09") == 11 base octogonal
		mes1 = "9";
	if(dia2 == "08") // parseInt("08") == 10 base octogonal
		dia2 = "8";
	if(dia2 == '09') // parseInt("09") == 11 base octogonal
		dia2 = "9";
	if(mes2 == "08") // parseInt("08") == 10 base octogonal
		mes2 = "8";
	if(mes2 == "09") // parseInt("09") == 11 base octogonal
		mes2 = "9";
	
	dia1  = parseInt(dia1);
	dia2  = parseInt(dia2);
	mes1  = parseInt(mes1);
	mes2  = parseInt(mes2);
	anyo1 = parseInt(anyo1);
	anyo2 = parseInt(anyo2);
	if(anyo1 > anyo2)
	{
		return 0;
	}
	if( (anyo1 == anyo2) && (mes1 > mes2) )
	{
		return 0;
	}
	if( (anyo1 == anyo2) && (mes1 == mes2) && (dia1 > dia2) )
	{
		return 0;
	}
	return 1;
}

<!--
//document.oncontextmenu = function(){ return false;}
//-->

//CRONOMETRO
var h_ini, crono;
function crono_start()
{
	h_ini = new Date();
	crono_cuenta();
}

function crono_pon()
{
	var h_act = new Date();
	milisec = (h_act - h_ini);
	h_crono = Math.floor( milisec/3600000 ) % 24;
	m_crono = Math.floor( milisec/60000 ) % 60;
	s_crono = Math.floor( milisec/1000 ) % 60;
	milisec = milisec%1000;
	h_crono = ((h_crono<10)?"0":"") + h_crono;
	m_crono = ((m_crono<10)?"0":"") + m_crono;
	s_crono = ((s_crono<10)?"0":"") + s_crono;
	milisec = ((milisec<100)?"0":"")+((milisec<10)?"0":"") + milisec;
	document.getElementById("text_crono").innerHTML = h_crono+":"+m_crono+":"+s_crono+"."+milisec;
}

function crono_cuenta()
{
	crono_pon();
	crono = setTimeout( "crono_cuenta();",53 );
	//end;//no se que hace, imagino que es un break
}

function crono_stop()
{
	clearTimeout( crono );
}

function crono_reset()
{
	h_ini = new Date();
	crono_pon();
}
//FIN CRONOMETRO


//VALIDAR EL FORMATO DE CORREO DIGITADO
function valida_mail(objeto)
{
	var mail = document.getElementById(objeto).value;
	var emailReg = /^[a-z-_0-9][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();
	}
}

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");
	/*alert(email_usuarioS);
	alert(passwordS);
	alert(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()
{
	email_usuarioS = document.getElementById("email_usuarioS").value;
	passwordS 	   = document.getElementById("passwordS").value;
	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;
	   }
	//alert(valores);   
	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)
			{
				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) )
				{
					/*var id_usuario_cookie = document.cookie("id_usuario_cookie").value;
					var marca_aleatoria_usuario = document.cookie("marca_aleatoria_usuario").value;
					alert(id_usuario_cookie);
					alert(marca_aleatoria_usuario);*/
					location.href = "./index_s.php";
					//JuntarPiezas():
				}
				//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);
}

/**************************************************************************************/
//GESTION DE COOKIES
//Autor: Iván Nieto Pérez
//Mejora: Sergio Ruiz
//Este script y otros muchos pueden
//descarse on-line de forma gratuita
//en El Código: www.elcodigo.com


/////////////////// CONFIGURACION ////////////////////////////////////
var separador = "$"		//caracter separador de campos en el texto de la cookie
var numElementos = 2		//numero de campos en el formulario


/////////////////// DATOS QUE SE MOSTRARAN ///////////////////////////
function Mostrar(nombre, formulario){
	var pieza = null
	var i = 0

	if(CojerCookie(nombre) != null) {
		nombre = CojerCookie(nombre)
		pieza = nombre.split(separador)
	
		for(i = 0; i < pieza.length; i++) 
			if (pieza[i] != null) {
				formulario.elements[ i ].value = pieza[ i ]
			}
	}		
}



/////////////////////////DATOS QUE SE GUARDARAN /////////////////////////////////////
function JuntarPiezas( formulario ) {

	var entero = ''
	//inserta en un string cada elemento, separados por el caracter separado	
	for ( contador = 0; contador < numElementos - 1; contador++) {
		entero += formulario.elements[ contador ].value + separador
	}

	//inserta el ultimo elemento
	entero += formulario.elements[ numElementos - 1 ].value
    alert(entero);
	IntroducirCookie(entero)
}

////////////////////////////////// FIN DE VARIABLES A CAMBIAR /////////////////////////////////

function CojerValorCookie(indice) {
	//indice indica el comienzo del valor
	var galleta = document.cookie
	//busca el final del valor, dado por ;, a partir de indice
	var finDeCadena = galleta.indexOf(";", indice)
	//si no existe el ;, el final del valor lo marca la longitud total de la cookie
	if (finDeCadena == -1)
		finDeCadena = galleta.length

	return unescape(galleta.substring(indice, finDeCadena))
	}

function CojerCookie(nombre) {
	var galleta = document.cookie
	//construye la cadena con el nombre del valor
	var arg = nombre + "="
        var alen = arg.length			//longitud del nombre del valor
	var glen = galleta.length		//longitud de la cookie

	var i = 0
	while (i < glen) {
		var j = i + alen			//posiciona j al final del nombre del valor
		if (galleta.substring(i, j) == arg)	//si en la cookie estamo ya en nombre del valor		
			return CojerValorCookie(j)	//devuleve el valor, que esta a partir de j

		i = galleta.indexOf(" ", i) + 1		//pasa al siguiente
		if (i == 0)
			break				//fin de la cookie
	}
	return null					//no se encuentra el nombre del valor
}

function GuardarCookie (nombre, valor, caducidad) {
	if(!caducidad)
		caducidad = Caduca(0)

	//crea la cookie: incluye el nombre, la caducidad y la ruta donde esta guardada
	//cada valor esta separado por ; y un espacio
	document.cookie = nombre + "=" + escape(valor) + "; expires=" + caducidad + "; path=/"
}

function Caduca(dias) {
	var hoy = new Date()					//coge la fecha actual
	var msEnXDias = eval(dias) * 24 * 60 * 60 * 1000	//pasa los dias a mseg.

	hoy.setTime(hoy.getTime() + msEnXDias)			//fecha de caducidad: actual + caducidad
	return (hoy.toGMTString())
}

function BorrarCookie(nombre) {
	//para borrar la cookie, se le pone una fecha del pasado mediante Caduca(-1)
	document.cookie = nombre + "=; expires=" + Caduca(-1) + "; path=/"
}

function IntroducirCookie(nombre) {
	//establece la cookie: la caducidad es de 31 dias
	var _31dias = Caduca(31)				//crea la fecha de caducidad si 31 dias
	if (nombre != "") 
		GuardarCookie("Datos", nombre, _31dias)
}

function MostrarMiCookie() {
	Mostrar('Datos', document.formulario)
}

window.onload = MostrarMiCookie;
if (document.captureEvents) {				//N4 requiere invocar la funcion captureEvents
	document.captureEvents(Event.LOAD)
}

/**************************************************************************************/
function valida_inicio_session2()
{
	var email_usuarioS    = document.getElementById("email_usuarioS").value;
	var passwordS = document.getElementById("passwordS").value;
	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_usuario2();
	}
}

function valida_usuario2()
{
	email_usuarioS    = document.getElementById("email_usuarioS").value;
	passwordS = document.getElementById("passwordS").value;
	valores  = 'email_usuarioS='+email_usuarioS;
	valores += '&passwordS='+passwordS;
	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)
			{
				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 = "./../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);
}

function valida_inicio_session3()
{
	var email_usuarioS3    = document.getElementById("email_usuarioS3").value;
	var passwordS3 = document.getElementById("passwordS3").value;
	//alert(email_usuarioS3+passwordS3);
	mensaje = "NOT ALL FIELDS ARE FILLED OUT, PLEASE COMPLETE THE FORM:\n\n";
	var validar_mail;
	if(email_usuarioS3 != "") {
		validar_mail = submit_valida_mail("email_usuarioS3");
	}
	if( (email_usuarioS3 == "") || (validar_mail == 1)  || (passwordS3 == "" ) ) {
						   
	   if (email_usuarioS3 == ""){
		   mensaje += "=> E-MAIL.\n";
		 }
	   if(validar_mail == 1){
		   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS.\n"
		 }
	   if(passwordS3 == "") {
			mensaje += "=> PASSWORD.\n";
		}
		alert(mensaje);
		return false;
	}
   else
	{
		valida_usuario3();
	}
}
function valida_usuario3()
{
	email_usuarioS3    = document.getElementById("email_usuarioS3").value;
	passwordS3 = document.getElementById("passwordS3").value;
	valores  = 'email_usuarioS3='+email_usuarioS3;
	valores += '&passwordS3='+passwordS3;
	//alert(valores);
	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) )
				{
					//alert("hola");
					var email_usuario = document.getElementById("email_usuario").value;
					var password = document.getElementById("password").value;
					valores  = 'email_usuario='+email_usuario;
					valores += '&password='+password;
					location.href = "http://download.otbvideo.com/index.php?"+valores;
				}
				//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);
}

function valida_inicio_session4()
{
	var email_usuarioS4    = document.getElementById("email_usuarioS4").value;
	var passwordS4 = document.getElementById("passwordS4").value;
	//alert(email_usuarioS3+passwordS3);
	mensaje = "NOT ALL FIELDS ARE FILLED OUT, PLEASE COMPLETE THE FORM:\n\n";
	var validar_mail;
	if(email_usuarioS4 != "") {
		validar_mail = submit_valida_mail("email_usuarioS4");
	}
	if( (email_usuarioS4 == "") || (validar_mail == 1)  || (passwordS4 == "" ) ) {
						   
	   if (email_usuarioS4 == ""){
		   mensaje += "=> E-MAIL.\n";
		 }
	   if(validar_mail == 1){
		   mensaje += "=> PLEASE FILL OUT A VALID EMAIL ADDRESS.\n"
		 }
	   if(passwordS4 == "") {
			mensaje += "=> PASSWORD.\n";
		}
		alert(mensaje);
		return false;
	}
   else
	{
		valida_usuario4();
	}
}
function valida_usuario4()
{
	var email_usuarioS4    = document.getElementById("email_usuarioS4").value;
	var passwordS4 = document.getElementById("passwordS4").value;
	valores  = 'email_usuarioS4='+email_usuarioS4;
	valores += '&passwordS4='+passwordS4;
	//alert(valores);
	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) )
				{
					//alert("hola");
					var email_usuario = document.getElementById("email_usuario").value;
					var password = document.getElementById("password").value;
					valores  = 'email_usuario='+email_usuario;
					valores += '&password='+password;
					location.href = "http://project.otbvideo.com/index.php?"+valores;
				}
				//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);
}

//////////////////
///INICIO ADMIN///
//////////////////
function valida_inicio_admin()
{
	var email_usuarioS   = document.getElementById("email_usuarioS").value;
	var passwordS        = document.getElementById("passwordS").value;
	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;
	}
	
	else
	{
		valida_admin();
	}
}

function valida_admin()
{
	email_usuarioS    = document.getElementById("email_usuarioS").value;
	passwordS = document.getElementById("passwordS").value;
	valores  = 'email_usuarioS='+email_usuarioS;
	valores += '&passwordS='+passwordS;
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/valida_admin.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)
			{
				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) )
				{
					document.getElementById("tdmensajes").innerHTML = "<img src='./../images/loading.gif' border='0'>";
					location.href = "./fprincipal.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);
			home_modelo_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function contador_online2(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);
			//nuevo_miembros();
			miembros_allnuevos_ver(1);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_online22(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);
			nuevo_miembros(1);
			//miembros_allnuevos_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_online3(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);
			//modelos_nuevos_ver();
			modelos_allnuevos_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function contador_online33(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);
			modelos_nuevos_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function contador_online4(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;
			website_contenido_ver();
			//alert(ajax.responseText);

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_online5(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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;
			dvd_montar_mant();
			//alert(ajax.responseText);
			

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function contador_online55(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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;
			dvd_nuevo_ver();
			//alert(ajax.responseText);
			

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

function contador_online6(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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);
			banner_ver();

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_online7(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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);
			modelos_entrevistas_ver();

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_online8(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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);
			foro_comentario_general_mant();

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
function contador_onlinesoporte(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	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);


		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

//////////////
///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=680');
	if(ventana != null)
	{
		ventana.focus();
	}
	
}

	
function valida_registro(page)
{
	if(page == null) {
		page = 1;
	}
	valores  = 'page='+page;
	nombre                  = document.getElementById("nombre").value;
	fecha_nac_usuario       = document.getElementById("fecha_nac_usuario").value;
	email                   = document.getElementById("email").value;
	pais                    = document.getElementById("pais").value;
	password                = document.getElementById("password").value;
	ciudad                  = document.getElementById("ciudad").value;
	password2               = document.getElementById("password2").value;
	si                      = document.getElementById("si");
	no                      = document.getElementById("no");
	
	var validar_mail;
	if(email != "") {
		validar_mail = submit_valida_mail("email");
	}
	//alert(pais);
//if(password == password2)
 //{
	if( (nombre == "") || (fecha_nac_usuario== "") || (email == 1) || (pais== "") || (password == "") || 
		(password2 == "") || ((si.checked == 0)&&(no.checked == 0))  )
	{
		                mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\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";
		                 }
						
											
						alert(mensaje);
						return false;	
		
	}
	else
	{
		
		valores  = 'nombre='+nombre;
		valores += '&fecha_nac_usuario='+fecha_nac_usuario;
		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("YOU CANNOT SIGN UP FOR THE OTB FAN CLUB IF YOU DO NOT AGREE WITH OUR TERMS AND CONDITIONS. THIS WINDOW WILL BE CLOSED...");
			window.close();
		}
		
	   valores += '&acepto='+acepto;
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./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;
					if(mens == 1)
					{
						alert("YOUR ACCOUNT DETAILS WERE SUCCESSFULLY EMAILED TO YOU…");
						//window.close(this);
						nombre_usuario = document.getElementById("nombre_usuario").value;
						id_usuario = document.getElementById("id_usuario").value;
						valores  = 'nombre_usuario='+nombre_usuario;
						valores  += '&id_usuario='+id_usuario;
						//alert(valores);
						location.href = "./index_registro.php?"+valores;
					}
					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. ');
						window.close(this);
					}
					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.');
					}
					if(mens == 11)
					{
						alert('SERVER REJECTED ADDRESS.');
					}
					if(mens == 12)
					{
						alert('NO RESPONSE FROM SERVER.');
					}
					if(mens == 13)
					{
						alert('CAN NOT CONNECT E-MAIL SERVER.');
					}
					/*if(mens == 14)
					{
						alert('SORRY YOUR IP ADRESS MUST BE REGISTERED.');
					}*/
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
	}
			/*}
			 else
			 {
				 alert ("EL PASSWORDS CONFIRAMDO ES INCORRECTO");
			 }*/
			 
}
//////////////////////
///home_modelos_ver///
//////////////////////
function home_modelo_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	/*if( (idcategoria != null) && (idcategoria != "") ) {
		valores += '&idcategoria='+idcategoria;
	}*/
	//valores += '&nombre1='+document.getElementById("nombre1").value;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./home_modelo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelo").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelo").innerHTML = ajax.responseText;
			//update_paginas_ver();
			update_dvd_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

//////////////////////
///home_paginas_ver///
//////////////////////
function update_paginas_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	ajax = nuevoAjax();
	ajax.open("POST", "./update_paginas_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdpaginas").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdpaginas").innerHTML = ajax.responseText;
			//update_dvd_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
////////////////
///update DVD///
////////////////
function update_dvd_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	ajax = nuevoAjax();
	ajax.open("POST", "./update_dvd_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvd").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvd").innerHTML = ajax.responseText;
			//myLightbox.updateImageList();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
///////////////////
//nuevo mienbros///
///////////////////
function nuevo_miembros(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./nuevo_miembros.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

/////////////////////
/// todos modelos ///
/////////////////////
function miembros_allnuevos_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./miembros_allnuevos_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
			//modelos_entrevistas_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function busqueda_nombre_miembro(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_miembro.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

////////////////////////////
///busquedaletras modelo///
////////////////////////////
function busqueda_letras_miembro_session(page,busqueda)
{
if( (page == null) || (page == "")  )
	{
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	if( (busqueda!= null) && (busqueda!= "") ) {
		valores += '&busqueda='+busqueda;
	}
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_letras_miembro_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				busqueda_letras_miembro(page);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
////////////////////////////
///busquedaletras modelo///
////////////////////////////
function busqueda_letras_miembro(page)
{
if( (page == null) || (page == "")  )
	{
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_letras_miembro.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}


/////////////////////
/// nuevos modelos///
/////////////////////
function modelos_nuevos_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelos_nuevos_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
			//modelos_entrevistas_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
/////////////////////
/// todos modelos ///
/////////////////////
function modelos_allnuevos_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelos_allnuevos_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
			//modelos_entrevistas_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
////////////////////////////////
///busquedapor 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("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
////////////////////////////
///busquedaletras modelo///
////////////////////////////
function busqueda_letras_modelo_session(page,busqueda)
{
if( (page == null) || (page == "")  )
	{
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	if( (busqueda!= null) && (busqueda!= "") ) {
		valores += '&busqueda='+busqueda;
	}
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_letras_modelo_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				busqueda_letras_modelo(page);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
////////////////////////////
///busquedaletras modelo///
////////////////////////////
function busqueda_letras_modelo(page)
{
if( (page == null) || (page == "")  )
	{
		page = 1;
	}
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./busqueda_letras_modelo.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
/////////////////////////
///entrevistas nuevas///
/////////////////////////
function modelos_entrevistas_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./modelos_entrevistas_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdentrevistasnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdentrevistasnew").innerHTML = ajax.responseText;
		
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
//////////////
/// GALERIA///
//////////////
function galeria_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./galeria_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdentrevistasnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdentrevistasnew").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function busqueda_nombre_galerias(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_galerias.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tdentrevistasnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tdentrevistasnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

///////////////////
///websites ver ///
///////////////////
function website_contenido_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./website_contenido_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdwebver").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdwebver").innerHTML = ajax.responseText;
			
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
//////////////////
///CARATULAS ID///
//////////////////
function mandar_id_caratula(id_dvd)
{
		valores  = 'id_dvd='+id_dvd;
		 alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./barebackcumparty_ver.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;
				//alert(innerHTML=ajax.responseText);
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
	}
		

/////////////////////////
///      dvd          ///
/////////////////////////
function dvd_ver(id_dvd, tipo_dvd)
{
	if( (id_dvd == null) || (id_dvd == "") ){
		id_dvd = 1;
	}
	if( (tipo_dvd == null) || (tipo_dvd == "") ){
		tipo_dvd = 1;
	}
	
	valores = 'id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./dvd_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvd").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvd").innerHTML = ajax.responseText;
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
/////////////
///DVD VER///
/////////////
function dvd_montar_ver(id_dvd, tipo_dvd)
{
	
	if( (id_dvd == null) || (id_dvd == "") ){
		id_dvd = 1;
	}
	if( (tipo_dvd == null) || (tipo_dvd == "") ){
		tipo_dvd = 1;
	}
	valores = 'id_dvd='+id_dvd;
	valores += '&tipo_dvd='+tipo_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/dvd_montar_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvd").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvd").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
function dvd_nuevo_ver(page)
{
   if( (page == null) || (page == "") )
   {
		page = 1;
   }
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/dvd_nuevo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvdnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvdnew").innerHTML = ajax.responseText;
		}
	}
	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;
   }
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/dvd_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvdnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvdnew").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			//contador_online5();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/   
}

function dvd_proximo_ver(page)
{
   if( (page == null) || (page == "") )
   {
		page = 1;
   }
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/dvd_proximo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvdnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvdnew").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			//contador_online5();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/   
}

function busqueda_nombre_dvd(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_dvd.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
			{
				document.getElementById("tddvdnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
				
			}
		if (ajax.readyState == 4)
			{
				document.getElementById("tddvdnew").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
			}
	}
		
    
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}
/////////////////
///mostrar dvd///
/////////////////
function dvd_montar_mant_ver(page,id_dvd,tipo_dvd)
{
    if( (page == null) || (page == "")  )
	{
		page = 1;
	}
	valores  = 'page='+page;
	valores += '&id_dvd='+id_dvd;
	valores +='&tipo_dvd='+tipo_dvd;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/dvd_montar_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvdnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvdnew").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			//contador_online5();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);// 
}
/////////////
///banners///
/////////////
function banner_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/banner_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdbanner").innerHTML = "<img src='./images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdbanner").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			offers_dvd_ver();

		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
///////////////
///offersdvd///
///////////////
function offers_dvd_ver(page)
{
	if( (page == null) || (page == "") ){
		page = 1;
	}
	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/offers_dvd_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdoffersdvd").innerHTML = "<img src='./images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdoffersdvd").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
			offers_trailer_dvd_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
/////////////////////////
///offersdvdvertrailer///
/////////////////////////
function offers_trailer_dvd_ver(page)
{
	
	if( (page == null) || (page == "") ){
		page = 1;
	}
	
	valores = 'page='+page;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/offers_trailer_dvd_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tddvdver").innerHTML = "<img src='./images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tddvdver").innerHTML = ajax.responseText;
					
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}
////////////////
///birthdays///
///////////////
function birthdays_ver(page)
{
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
	//alert (valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./birthdays_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
			//modelos_entrevistas_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}



//para pasar a la siguiente caja de texto con enter(IE)
function enter_tab(nextfield)
{
	key = (document.all) ? event.keyCode : event.which;	  
	var key = event.keyCode;//código de tecla.
	if( (key == 13) && (document.getElementById(nextfield) != null) )
	{
		document.getElementById(nextfield).focus();
	}
}

//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;
}

//RECIBE UN SOLO CARACTER
function quitar_caracterU(field, quitar)
{
	add = "";
	temp = "" + field;
	while(temp.indexOf(quitar) > -1)
	{
		pos = temp.indexOf(quitar);
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + quitar.length), temp.length));
	}
	return temp;
}

//EJECUTA CUALQUIER FUNCION AL PRESIONAR ENTER, RECIBE EL NOMBRE DE LA FUNCTION Y LOS PARAMETROS
function ejecutar_con_enter(funcion, parametro1, parametro2, parametro3, parametro4)
{
	/*var key = event.keyCode;//código de tecla.
	if(key == 13)
	{
		//alert(funcion);
		eval(funcion+"('"+parametro1+"', '"+parametro2+"', '"+parametro3+"', '"+parametro4+"')");
	}*/
}

//PASA A LA SIGUIENTE CAJA DE TEXTO, CON ENTER FUNCIONA EN IE Y FIREFOX
function nextfield(evt, proximo)
{
	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) ) {
	  	document.getElementById(proximo).focus();
	}
}

<!--||||||||||||||||||||||||||||||-->
<!--||  VENDEDORES POR SUCURSAL ||-->
<!--||||||||||||||||||||||||||||||-->
function detectar_enter(evt, funcion, parametro1, parametro2)
{
	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+"')");
	}
}

//PARA HACER LO DE LOS CHECKBOX COMO HOTMAIL
function select_checkbox(nombreF, cadena, same)//nombreF es el id formulario, cadena es el grupo de checkbox que voy a usar, same es el checkbox superior
{
	var Formulario = document.getElementById(nombreF);//recibe el id del formulario
	var longitud = Formulario.elements.length;
	j = 0;
	var chk;
	//alert("SAME "+document.getElementById(same.id).checked+" CADENA "+cadena+" LONGITUD: "+longitud);
	if(document.getElementById(same.id).checked == false)//VERIFICO ESTADO DEL CHECKBOX PRINCIPAL
	{
		chk = 0;
	}
	if(document.getElementById(same.id).checked == true)//VERIFICO ESTADO DEL CHECKBOX PRINCIPAL
	{
		chk = 1;
	}
	for (i = 0; i <= longitud - 1; i++)
	{
		//if( (Formulario.elements[i].type == "checkbox") && (Formulario.elements[i].id == cadena+j) )
		if( (Formulario.elements[i].type == "checkbox") && (Formulario.elements[i].id == cadena+j) )
		{
			if(chk == 0) {
				document.getElementById(cadena+j).checked = 0;
			}
			if(chk == 1) {
				document.getElementById(cadena+j).checked = 1;
			}
			j++;
		}
	}
}



////////////////////
///cerrar session///
////////////////////
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()
{
	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);
	}
	
}

//HACE TRIM
function trim(s)
{
	return rtrim(ltrim(s));
}

//LEFT TRIM
function ltrim(s)
{
	return s.replace(/^\s+/, "");
}

//RIGHT TRIM
function rtrim(s)
{
	return s.replace(/\s+$/, "");
}

<!--|||||||||||||||||||||||||||||||||||||||||||-->
<!--|| PARA EL CAMBIO DE CLAVE DEL CLIENTE   ||-->
<!--|||||||||||||||||||||||||||||||||||||||||||-->
//ABRE LA VENTANA EMERGENTE DONDE EL CLIENTE HACE EL CAMBIO DE CLAVE
function cambio_de_claveF()
{
	var URL = "./../paginas/cambio_de_claveF.php";
	//location.href = URL;
	var busqueda;
	busqueda= window.open(URL, 'cambio_de_claveF','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, right=20,left=20,top=10 ,width=450, height=410');
	if(busqueda!= null)
	{
		busqueda.focus();
	}
}

//PARA ENVIAR LA NUEVA CLAVE A LA BD
function cambio_de_claveG()
{
	clave_anterior = document.getElementById("clave_anterior").value;
	clave_nueva1   = document.getElementById("clave_nueva1").value;
	clave_nueva2   = document.getElementById("clave_nueva2").value;
	if( (clave_anterior == "") || (clave_nueva1 == "") || (clave_nueva2 == "")
	 || ((clave_nueva1 != "")&&(clave_nueva2 != "")&&(clave_nueva1 != clave_nueva2)) )
	{
		mensaje = "FIELDS MUST BE FILLED:\n\n";
		if(clave_anterior == "") {
			mensaje += "=> OLD PASSWORD.\n";
		}
		if(clave_nueva1 == "") {
			mensaje += "=> NEW PASSWORD.\n";
		}
		if(clave_nueva2 == "") {
			mensaje += "=> PLEASE CONFIRM YOUR PASSWORD.\n";
		}
		if( (clave_nueva1 != "")&&(clave_nueva2 != "")&&(clave_nueva1 != clave_nueva2) ) {
			mensaje += "=> THE NEW PASSWORD AND THE CONFIRMATION MUST BE THE SAME.\n";
			document.getElementById("clave_nueva1").value = "";
			document.getElementById("clave_nueva2").value = "";
			document.getElementById("clave_nueva1").focus();
		}
		alert(mensaje);
		return false;
	}
	else
	{
		valores  = 'clave_anterior='+clave_anterior;
		valores += '&clave_nueva1='+clave_nueva1;
		valores += '&clave_nueva2='+clave_nueva2;
		//alert (valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/cambio_de_claveG.php", true);		
		ajax.onreadystatechange=function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading11.gif' border='0'>";
				document.getElementById("tdmensajes2").innerHTML = "&nbsp;Actualizando datos...";
			}
			if (ajax.readyState == 4)
			{
				//alert(ajax.responseText);
				document.getElementById("tdmensajes1").innerHTML = "";
				document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
				if(document.getElementById("mens") != null)
				{
					mens = document.getElementById("mens").value;
					if(mens == 1)
					{
						alert("PASSWORD CHANGED SUCCESFULLY.");
						window.close(this);
					}
					if(mens == 2)
					{
						alert("CHANGE OF PASSWORD FAILED, TRY AGAIN.");
					}
					if( (mens == 3) && (document.getElementById("mensaje_error") != null) )
					{
						alert(document.getElementById("mensaje_error").value);
					}
					if(mens == 4)
					{
						alert("FILL OUT ALL THE INFORMATION.");
					}
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);//
	}
}

<!--||||||||||||||||||||||||||||||-->
<!--||  VENDEDORES POR SUCURSAL ||-->
<!--||||||||||||||||||||||||||||||-->
//PARA SACAR LOS VENDEDORES POR SUCURSAL
function vendedores_por_sucursal(idsucursalBD, idvendedorBD)
{
	var idsucursalFR = "";
	if( (idsucursalBD != "") && (idsucursalBD != undefined) )
	{
		idsucursal = idsucursalBD;
		//alert("DESDE BD");
	}
	else
	{
		idsucursalFR = document.getElementById("idsucursal").value;
		idsucursal = idsucursalFR;
		//alert("DESDE FORM");
	}
	if(idsucursal != "")
	{
		valores = 'idsucursal='+idsucursal;
		if( (idvendedorBD != "") && (idvendedorBD != undefined) ){
			valores += '&idvendedorBD='+idvendedorBD;
		}
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/vendedores_por_sucursal.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				imagen  = "<img src='./../images/loading11.gif' border='0' align='absmiddle'>";
				imagen += "&nbsp;Cargando vendedores...";
				document.getElementById("tdvendedores").innerHTML = imagen;
			}
			if (ajax.readyState == 4)
			{
				document.getElementById("tdvendedores").innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(idvendedorBD != "") {
					document.getElementById("idvendedor").value = idvendedorBD;
				}
				if(idsucursalFR != "") {
					document.getElementById("idvendedor").value = "";
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);//
	}
	else
	{
		document.getElementById("tdvendedores").innerHTML = "SELECCIONE SUCURSAL.";
	}
}

<!--||||||||||||||||||||||||||||||//-->
<!--   INDICADOR DE EFECTIVIDAD   //-->
<!--||||||||||||||||||||||||||||||//-->
function indicador_efectividad_ver()
{
	fecha1 = document.getElementById("fecha1").value;
	fecha2 = document.getElementById("fecha2").value;
	if( (fecha1 != "") && (fecha2 != "") )
	{
		valores  = 'fecha1='+fecha1;
		valores += '&fecha2='+fecha2;
		if(document.getElementById("idvendedor") != null) {
			valores += '&idvendedor='+document.getElementById("idvendedor").value;
		}
		if(document.getElementById("idsucursal") != null) {
			valores += '&idsucursal='+document.getElementById("idsucursal").value;
		}
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/indicador_efectividad_ver.php",true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				document.getElementById("tdindicador").innerHTML = "<img src='./../images/loading2.gif' border='0'>";
			}
			if (ajax.readyState == 4)
			{
				//alert(ajax.responseText);
				document.getElementById("tdindicador").innerHTML = ajax.responseText;
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
	}
	else
	{
		alert("SELECCIONE FECHA INICIAL Y FECHA FINAL.");
	}
}

//PARA VER LOS VENDEDORES DE UNA SUCURSAL
function vendedores_por_sucursal_usuario(idsucursalBD, idvendedorBD, identificador, contenedor)
{
	var idsucursalFR = "";
	if( (idsucursalBD != "") && (idsucursalBD != undefined) )
	{
		idsucursal = idsucursalBD;
	}
	else
	{
		if( (document.getElementById("idsucursal") != null) && (contenedor == 'tdvendedores') ){
			idsucursalFR = document.getElementById("idsucursal").value;
		}
		idsucursal = idsucursalFR;
	}
	//alert("idsucursal: "+idsucursal+" identificador: "+identificador+" cont: "+contenedor);
	if( (idsucursal != "") && (identificador != "") && (contenedor != "") )
	{
		valores  = 'idsucursal='+idsucursal;
		valores += '&identificador='+identificador;
		if( (idvendedorBD != "") && (idvendedorBD != undefined) ){
			valores += '&idvendedorBD='+idvendedorBD;
		}
		//alert(valores);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/vendedores_por_sucursal_usuario.php", true);
		ajax.onreadystatechange = function()
		{
			if (ajax.readyState == 1)
			{
				imagen  = "<img src='./../images/loading11.gif' border='0' align='absmiddle'>";
				imagen += "&nbsp;Cargando vendedores...";
				document.getElementById(contenedor).innerHTML = imagen;
			}
			if (ajax.readyState == 4)
			{
				document.getElementById(contenedor).innerHTML = ajax.responseText;
				//alert(ajax.responseText);
				if(document.getElementById(identificador) != null) {
					if(idvendedorBD != "") {
						document.getElementById(identificador).value = idvendedorBD;
					}
					if(idsucursalFR != "") {
						document.getElementById(identificador).value = "";
					}
				}
			}
		}
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores);
	}
	else
	{
		document.getElementById(contenedor).innerHTML = "SELECCIONE SUCURSAL.";
	}
}

<!--|||||||||||||||||-->
<!--||  DESCARGAS  ||-->
<!--|||||||||||||||||-->
//ABRE LA VENTANA EMERGENTE DONDE EL CLIENTE HACE EL CAMBIO DE CLAVE
function descargas()
{
	var URL = "./../paginas/descargas.php";
	//location.href = URL;
	var busqueda;
	busqueda= window.open(URL, 'descargas','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0, left=20,top=10 ,width=420, height=350');
	if(busqueda!= null)
	{
		busqueda.focus();
	}
}
////////////////////////
///LIMITAR UN TEXAREA///
////////////////////////
function ismaxlength(obj)
{
	//alert("hola");
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length > mlength)
obj.valueobj.value.substring(0,mlength)
//alert(mlength);
	/*if (mlength == 40)
	{
	   alert(hola);
	}*/
}

////////////////////
/// foro general ///
////////////////////
function foro_comentario_general_mant()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/foro_comentario_general_mant.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdforos").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdforos").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 foro_comentario_director_mant()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/foro_comentario_director_mant.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdforos").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdforos").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 foro_entrevista_modelo_mant()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/foro_entrevista_modelo_mant.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdforos").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdforos").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);
}

//ABRE LA VENTANA EMERGENTE DONDE EL CLIENTE HACE EL CAMBIO DE CLAVE
function newsletters_mant()
{
	var URL = "./../paginas/newsletters.php";
	//location.href = URL;
	var busqueda;
	busqueda= window.open(URL, 'newsletters','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 newsletters_guardar()
{

	var newsletters		= document.getElementById("newsletters").value; 
	 if (newsletters == "")  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						if(newsletters == "") {
							mensaje += "=> newsletters.\n";
						}
																	
					    alert(mensaje);
						return false;	
		
	    }
	   else
   	    {
		
			valores = 'newsletters='+newsletters;

			ajax = nuevoAjax();
			ajax.open("POST", "./../paginas/newsletters_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");
									//modelos_nuevos_ver();
									window.close(this);
								}
								if(mens == 2)
								{
									alert('ERROR try again.');
									//modelos_nuevos_ver();
								}
								
								if(mens == 3)
								{
									alert('This DVD is already in your list.');
									window.close(this);
								}
								
								if(mens == 4)
								{
									alert('ERROR DE DATOS.');
									//modelos_nuevos_ver();
								}
								if(mens == 5)
								{
									alert('Please fill out the newslatter field.');
									//modelos_nuevos_ver();
								}
				}
			}
		}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


//////////////////////////////
///olvidastes tu contraseña///
//////////////////////////////
function usuario_olvido_contrasena()
{
	var URL = "./paginas/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);//*/
	}
}

function contactenos_guardar()
{
     var titulo		= document.getElementById("titulo").value;
	 var comentario	= document.getElementById("comentario").value;
	 if ( (titulo == "") || (comentario == "") )  
	   {
		  mensaje = "YOU NEED TO FILL ALL FIELDS TO CONTINUE:\n\n";
						if(titulo == "") {
							mensaje += "=> TITULO.\n";
						}
						if(comentario == "") {
							mensaje += "=> COMENTARIO.\n";
						}
																	
					    alert(mensaje);
						return false;	
		
	    }
	   else
   	    {
		
			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");
									 titulo		= document.getElementById("titulo").value = "";
									 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 href(page)
{
	//alert("hola");
	if(page == null) {
		page = 1;
	}
	valores = 'page='+page;
    //alert(valores);
   	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/nuevo_miembros.php",true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdhref").innerHTML = "";
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdhref").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(valores);
  //window.location.href = "./members_contenido.php";
}
*/

//////////////////////
/// cerrara cuenta ///
//////////////////////
////////////////////
///cerrar session///
////////////////////
function inactivar_cuenta()
{
	
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/inactivar_cuenta.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);
			inactivar_cuenta_cerrar();
			//alert (innerHTML = ajax.responseText);
		}
	}

	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(null);
}


function inactivar_cuenta_cerrar()
{
	si = confirm('Are you really sure you want to delete your account?');
	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);
	}
	
}
function modelo_perfil_mant3(id_modelo)
{
	
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores = 'id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/modelo_perfil_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function modelo_perfil_mant4(id_modelo)
{
	
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores = 'id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/modelo_perfil_mant.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdentrevistasnew").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdentrevistasnew").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

/*function cargar(id_modelo)
{
	
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores = 'id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/modelo_promedio.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmensajes2").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			var promedio = document.getElementById("promedio").value;
			var id_modelo = document.getElementById("id_modelo").value;
		    cargar_estrellas(id_modelo,promedio);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
//}

function cargar(id_modelo)
{
	
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores = id_modelo;
	if(id_modelo != "")
	  {
		valores2 = 'id_modelo='+id_modelo;
        //alert(valores2);
		ajax = nuevoAjax();
		ajax.open("POST", "./../paginas/modelo_promedio.php", true);
		//var URL = "./../paginas/modelo_promedio.php?"+valores2;
		ajax.onreadystatechange = function()
		 { 
		   if (ajax.readyState == 1)
			 {
				document.getElementById("tdmensajes2").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			 }
		   if (ajax.readyState == 4)
			 {
				document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
				var promedio = document.getElementById("promedio").value;
				var id_modelo = document.getElementById("id_modelo").value;
				//alert(promedio);
				//alert(id_modelo);
				comentario_usuario_modelo_ver(id_modelo)
				if( (promedio == null) || (promedio == "") )
				{
					promedio = 0;
					//alert(promedio);
	            }
				//alert(promedio);
				$(document).ready(function() {
				   $('#star1').rating('./../paginas/votar.php', {maxvalue: 5, curvalue: promedio, id: id_modelo});
				 });
			 }
		  }
		ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		ajax.send(valores2);
	  }
	
	   
}
function comentario_usuario_modelo_ver(id_modelo)
{
	if( (id_modelo == null) || (id_modelo == "") ){
		id_modelo = 1;
	}
	valores = 'id_modelo='+id_modelo;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/comentario_usuario_modelo_ver.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		{
			document.getElementById("tdcomentariousuario").innerHTML = "<img src='./../images/loading.gif' border='0'>";
			//timer = setInterval("comentario_usuario_modelo_ver()" , 2000);
			//mostrardatos(id_modelo);
			//recargar(id_modelo);
		}
		if (ajax.readyState == 4)
		{
			document.getElementById("tdcomentariousuario").innerHTML = ajax.responseText;
			//alert(innerHTML=ajax.responseText);
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
	//cargar(id_modelo);
}

function usuario_delete_mensaje_perfil(id_mensaje,id_usuarioV,id_usuario_cliente)
{
	valores = "id_mensaje="+id_mensaje;
	valores += "&id_usuarioV="+id_usuarioV;
	valores += "&id_usuario_cliente="+id_usuario_cliente;
	//alert(campos);
	ajax = nuevoAjax();
	ajax.open("POST", "./usuario_delete_mensaje_perfil.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;
			if(document.getElementById("mens") != null)
			  {
					var mens = document.getElementById("mens").value;
					var id_usuario = document.getElementById("id_usuario").value;
					//alert(mens);
					if(mens == 1)
					{
						alert("YOUR REQUEST WAS SUCCESSFULLY PROCESSED")
						 comentario_usuario_cliente_ver(id_usuario);
						
					}
					if(mens == 2)
					{
						alert("ERROR try again")
					}
			    }
		 }
	 }
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

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 modelo_comentario_ver_todo_session(page,id_modelo)
{
	
	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;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/modelo_comentario_ver_todo_session.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmensajes1").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			modelo_comentario_ver_todo(1);
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}

function modelo_comentario_ver_todo(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;
	//alert(valores);
	ajax = nuevoAjax();
	ajax.open("POST", "./../paginas/modelo_comentario_ver_todo.php", true);
	ajax.onreadystatechange = function()
	{
		if (ajax.readyState == 1)
		 {
			document.getElementById("tdmodelosnew").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		 }
		if (ajax.readyState == 4)
		 {
		    document.getElementById("tdmodelosnew").innerHTML = ajax.responseText;
		 }
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);//*/
}


function texto_mail_adicionar_credito()
{
	ajax = nuevoAjax();
	ajax.open("POST", "./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_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 compra_donacion_mant()
{
  //usuario_donaciones_mant();	
  var URL = "http://download.otbvideo.com/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();
	}
}

////////////////////
///   premios    ///
////////////////////
function awards_contenido_ver(page)
{
	if( (page == null) || (page == "") ) {
		page = 1;
	}
	valores = 'page='+page;
	ajax = nuevoAjax();
	ajax.open("POST", "./awards_contenido.php", true);
	ajax.onreadystatechange = function()
	{
		if(ajax.readyState == 1)
		{
			document.getElementById("tdmensajes2").innerHTML = "<img src='./../images/loading.gif' border='0'>";
		}
		if(ajax.readyState == 4)
		{
			document.getElementById("tdmensajes2").innerHTML = ajax.responseText;
			//alert(ajax.responseText);
			//home_modelo_ver();
		}
	}
	ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	ajax.send(valores);
}

/*************/
/****elin****/
/************/
// JavaScript Document

function Crear()
{
   var obj;
   if(window.XMLHttpRequest) 
   { // no es IE
     obj = new XMLHttpRequest();
   }
  else
  { // Es IE o no tiene el objeto
    try{
		obj = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(e){
		alert('El navegador utilizado no está soportado');
    }
  }
   return obj;
}

function Cargar(pagina, marco)
  {
    if(marco==null)
	 {
       marco="contenido";
     }
    oXML = Crear();
    oXML.open('GET',pagina);
    document.getElementById(marco).innerHTML = "<div align='center'><img src='http://produccionaudiovisualpr.uniandes.edu.co/admin/themes/default/img/loader.gif' /></div>";
    oXML.onreadystatechange = function()
	{
      if (oXML.readyState == 4) 
	   {
          var mydiv=document.getElementById(marco);
		  mydiv.innerHTML = oXML.responseText;
          var elementos = mydiv.getElementsByTagName('script');
          for(i=0;i<elementos.length;i++) 
		    {
				var elemento = elementos[i];
				nuevoScript = document.createElement('script');
				nuevoScript.text = elemento.innerHTML;
				nuevoScript.type = 'text/javascript';
				if(elemento.src!=null && elemento.src.length>0)
				 {
					nuevoScript.src = elemento.src;
				 }
			   elemento.parentNode.replaceChild(nuevoScript,elemento);
			}
	    }
	};
  oXML.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
  oXML.send(null);
}
