function carga()
{
	posicion=0; elMovimiento=null;
	
	// IE
	if(navigator.userAgent.indexOf("MSIE")>=0) navegador=0;
	// Otros
	else navegador=1;
}


var request = false;

if (window.XMLHttpRequest) {
	request = new XMLHttpRequest();
}

function insertarnombre() {
	var theForm = document.getElementById('ingresarDatos');
	var ret = Spry.Widget.Form.validate(theForm);
	if (ret){
		if (window.ActiveXObject) {
			try {
				request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					request = false;
				}
			}
		}
	
		if (request) {
			var nombre = document.getElementById("nombre").value;
			var celular = document.getElementById("celular").value;
			var edad = document.getElementById("edad").value;
			var email = document.getElementById("email").value;
			var genero = document.getElementById("genero").value;
			request.onreadystatechange = processReqChange;
			request.open("GET", "insertar.php?nombre=" + encodeURIComponent(nombre) + "&celular=" + encodeURIComponent(celular) + "&edad=" + encodeURIComponent(edad) + "&email=" + encodeURIComponent(email) + "&genero=" + encodeURIComponent(genero));
			request.send(null);
			document.datos.reset()
			//cerrarTime()
		}
		//return false;
	}else{
		return false;
	}
}

function processReqChange() {
    var mensaje = document.getElementById("msg");

    if (request.readyState == 4) {
        if (request.status == 200) {
            mensaje.innerHTML = request.responseText;
        }
    } else {
        mensaje.innerHTML = "Procesando...";
    }
}

function tonos(id){
	//document.getElementById('ContentIFrame').src='vertonos.php?id='+id;
	//alert(document.getElementById('select').Value);
	var idselect = document.getElementById('select').Value;
	if(idselect){
		document.getElementById(idselect).className = "boton_nombre";
	}
	document.getElementById(id).className = "boton_nombre_select";
	document.getElementById('select').Value = id;
}

function seleccionarPlayer(video, divHTML, tipoReproduccion, ancho, alto,urlImagen) {
   
   if (tipoReproduccion == 'audio' && !ancho && !alto) {
        alto = 20;
        altoVideo = 20;
    }else {
        altoVideo = alto + 20;
	}
	var playlistArray;
    playlistArray = new Array();
    playlistArray[0] = "";
    playlistArray[1] = "";
    if (tipoReproduccion == 'audio')
       var s3 = new SWFObject("player/audioplayer.swf", tipoReproduccion + '_' + divHTML ,ancho,24,"7");    
    else
       var s3 = new SWFObject("player/videoplayer.swf", tipoReproduccion + '_' + divHTML ,ancho,altoVideo,"7");
    if(tipoReproduccion == 'audio')   {
       s3.addParam("allowfullscreen","false");   
       
    }   
	s3.addParam("swLiveConnect","true");
	s3.addVariable("width",ancho);	
   	s3.addVariable("height",alto);
   	s3.addVariable("displaywidth" , ancho);
	s3.addVariable("displayheight" , alto);
	s3.addVariable("file", video);
	s3.addParam("wmode","transparent"); 
  	  
	if(tipoReproduccion == 'video'){
	  s3.addParam("allowfullscreen","true");
	  s3.addVariable("showdigits" , "total");
	  s3.addVariable("image" ,urlImagen);
	  s3.addVariable("searchbar" , "false");
	  s3.addVariable("showstop" , "false");
   }
	   
	s3.write(divHTML);
}
function over(id){
	if(document.getElementById('select').Value != id){
		document.getElementById(id).className = "boton_nombre_over";
	}
	document.getElementById("msg").innerHTML = "";
}
function out(id){
	if(document.getElementById('select').Value != id){
		document.getElementById(id).className = "boton_nombre";
	}
}

function ingresar(){
		document.getElementById('nombre_nuevo').style.display = 'inline';
}

function ingresarover(){
	document.getElementById('bt_ingresar').className = "ingresar_boton_over";
}
function ingresarout(){
	document.getElementById('bt_ingresar').className = "ingresar_boton";
}
function condicionesover(){
	document.getElementById('bt_condi').className = "boton_condiciones_over";
}
function condicionesout(){
	document.getElementById('bt_condi').className = "boton_condiciones";
}
function mostrarcondiciones(){
	document.getElementById('fondocondi').style.display = 'inline';
	document.getElementById('condiciones').style.display = 'inline';
	document.getElementById('divOne').style.display = 'none';
	document.getElementById('divTwo').style.display = 'none';
}
function cerrarcondiciones(){
	document.getElementById('fondocondi').style.display = 'none';
	document.getElementById('condiciones').style.display = 'none';
}
function mostrardivOne(){
	document.getElementById('divOne').style.display = 'inline';
}
function mostrardivTwo(){
	document.getElementById('divTwo').style.display = 'inline';
}
function formcerrar(){
		document.getElementById('nombre_nuevo').style.display = 'none';
		document.datos.reset();
		document.getElementById("msg").innerHTML = '';
}

function mostrartitsel(){
	document.getElementById('tit_sel').style.display = 'inline';
	document.getElementById('paraescuchar').style.display = 'inline';
	document.getElementById('vistanombre').style.display = 'none';
}

function ocultartiosel(){
	document.getElementById('tit_sel').style.display = 'none';
	document.getElementById('paraescuchar').style.display = 'inline';
	document.getElementById('vistanombre').style.display = 'none';
}
function mostrarvistanombre(){
	document.getElementById('paraescuchar').style.display = 'none';
	document.getElementById('vistanombre').style.display = 'inline';
}

var howLong = 2000;

t = null;
function cerrarTime(){
t = setTimeout("formcerrar()",howLong);
}

function FilterData(ds_actual,filtro,filtrarpor)
{
	var tf = document.getElementById(filtro);
	if (!tf.value)
	{
		// If the text field is empty, remove any filter
		// that is set on the data set.

		ds_actual.filter(null);
		return;
	}
	// Set a filter on the data set that matches any row
	// that begins with the string in the text field.

	var regExpStr = tf.value;
	
	//if (!document.getElementById("containsCB").checked)
		//regExpStr = "^" + regExpStr;

	var regExp = new RegExp(regExpStr, "i");
	var filterFunc = function(ds, row, rowNumber)
	{
		var str = row[filtrarpor];
		if (str && str.search(regExp) != -1)
			return row;
		return null;
	};

	ds_actual.filter(filterFunc);
}

function StartFilterTimer(ds_actual,filtro,filtrarpor)
{
	if (StartFilterTimer.timerID)
		clearTimeout(StartFilterTimer.timerID);
	StartFilterTimer.timerID = setTimeout(function() { StartFilterTimer.timerID = null; FilterData(ds_actual,filtro,filtrarpor); }, 100);
}

function infodescarga(ev,id)
{
	posicion = 0;
	// Obtengo la posicion del cursor
	var infodes = document.getElementById('infodescarga');
	if(navegador==0)
	{
		xActual=window.event.clientX+document.body.scrollLeft-50;
		yActual=window.event.clientY+document.body.scrollTop-91;
	}
	if(navegador==1)
	{    
		xActual=ev.pageX-50;
		yActual=ev.pageY-91;
	}
	infodes.style.left = xActual+"px";
	infodes.style.top = yActual+"px";
	infodes.innerHTML = '<br />Envia '+ id + ' al 530';
	infodes.style.display = 'inline';
}
function ocultarinfo()
{
	document.getElementById('infodescarga').style.display = 'none';
}
