function MM_CheckFlashVersion (reqVerStr, msg)
{
	with (navigator)
	{
		var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
		var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
		if (!isIE || !isWin)
		{  
			var flashVer = -1;
			if (plugins && plugins.length > 0)
			{
				var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
				desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;

				if (desc == "")
					flashVer = -1;
				else
				{
					var descArr = desc.split(" ");
					var tempArrMajor = descArr[2].split(".");
					var verMajor = tempArrMajor[0];
					var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
					var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
					flashVer =  parseFloat(verMajor + "." + verMinor);
				}
			}
			// WebTV has Flash Player 4 or lower -- too low for video
			else if (userAgent.toLowerCase().indexOf ("webtv") != -1)
				flashVer = 4.0;

			var verArr = reqVerStr.split(",");
			var reqVer = parseFloat(verArr[0] + "." + verArr[2]);

			if (flashVer < reqVer)
			{
				if (confirm(msg))
					window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
			}
		}
	} 
}

function fn_AbrirPopUp ()
{
	var ancho, alto, top, left;
	
	// Seteamos el DIV del sombreado.
	document.getElementById ("div_Sombreado").style.height = document.body.scrollHeight;
	document.getElementById ("div_Sombreado").style.width = document.body.scrollWidth;

	// Quitamos el reloj de arena.
	document.getElementById ("div_Sombreado").style.cursor = "default";

	// Limpiamos los campos.
	document.frm_PopUp.txt_Nombre.value = "";
	document.frm_PopUp.txt_Email.value = "";
	document.frm_PopUp.txt_Comentarios.value = "";

	// Mostramos los DIVs.
	document.getElementById ("div_Sombreado").style.display = "block";
	document.getElementById ("div_PopUp").style.display = "block";

	// Seteamos el DIV del envío de e-mail.
	ancho = 538;
	alto = document.getElementById ("div_PopUp").clientHeight;
	
	top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	left = parseInt ((document.body.clientWidth - ancho) / 2);	

	document.getElementById ("div_PopUp").style.top = top.toString () + "px";
	document.getElementById ("div_PopUp").style.left = left.toString () + "px";	

	document.frm_PopUp.txt_Nombre.focus ();
}

function fn_AbrirVentanaProcesando ()
{
	var ancho, alto, top, left;
	
	// Mostramos el DIV.
	document.getElementById ("div_Procesando").style.display = "block";

	// Seteamos el DIV.
	ancho = 670;
	alto = document.getElementById ("div_Procesando").clientHeight;
	
	top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	left = parseInt ((document.body.clientWidth - ancho) / 2);	

	document.getElementById ("div_Procesando").style.top = top.toString () + "px";
	document.getElementById ("div_Procesando").style.left = left.toString () + "px";
	
	// Ponemos el reloj de arena.
	document.getElementById ("div_Sombreado").style.cursor = "wait";
	document.getElementById ("div_Procesando").style.cursor = "wait";
}

function fn_AbrirVentanaProcesoOk ()
{
	var ancho, alto, top, left;
	
	// Quitamos el reloj de arena.
	document.getElementById ("div_Sombreado").style.cursor = "default";

	// Mostramos el DIV.
	document.getElementById ("div_ProcesoOk").style.display = "block";

	// Seteamos el DIV.
	ancho = 300;
	alto = document.getElementById ("div_ProcesoOk").clientHeight;
	
	top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	left = parseInt ((document.body.clientWidth - ancho) / 2);	

	document.getElementById ("div_ProcesoOk").style.top = top.toString () + "px";
	document.getElementById ("div_ProcesoOk").style.left = left.toString () + "px";
}

function fn_VolverAPantallaNormal ()
{
	document.getElementById ("div_Sombreado").style.display = "none";

	// Ocultamos todos los DIVs.
	document.getElementById ("div_PopUp").style.display = "none";
	document.getElementById ("div_Procesando").style.display = "none";
	document.getElementById ("div_ProcesoOk").style.display = "none";
}

function fn_ValidarIngreso ()
{
	var formulario = document.frm_PopUp;
	var textoComentarios = fn_QuitarBasuraExtremos (formulario.txt_Comentarios.value);
		
	if (trim (formulario.txt_Nombre.value) == "")
	{
		alert ("Ingresá tu nombre y apellido.");
		formulario.txt_Nombre.focus ();
		return false;
	}

	if (trim (formulario.txt_Email.value) == "")
	{
		alert ("Ingresá tu dirección de e-mail.");
		formulario.txt_Email.focus ();
		return false;
	}
	
	if (fn_ValidarUnEmailValido (trim (formulario.txt_Email.value)) == false)
	{
		alert ("La dirección de e-mail que ingresaste es incorrecta.");
		formulario.txt_Email.focus ();
		return false;
	}	

	if (trim (formulario.txt_UploadArchivo.value) == "")
	{
		alert ("No seleccionaste ningún video.");
		return false;
	}

	if (textoComentarios.length > 10000)
	{
		alert ("Superaste el límite de 10000 caracteres para los comentarios.");
		formulario.txt_Comentarios.focus ();
		return false;
	}

	return true;
}

function fn_EnviarPopUp ()
{
	if (fn_ValidarIngreso ())
	{
		// Cerramos la ventana de upload de archivo.
		document.getElementById ("div_PopUp").style.display = "none";

		// Abrimos la ventana con la leyenda de 'subiendo video'.
		fn_AbrirVentanaProcesando ();
		
		document.frm_PopUp.txt_HacerGrabar.value = "0";
		document.frm_PopUp.txt_HacerUpload.value = "-1";

		document.body.onbeforeunload = "";
		document.frm_PopUp.action = "index_ajax.php";
		document.frm_PopUp.target = "iframeSubmit";
		document.frm_PopUp.submit ();
	}
}

function fn_UploadOk (nombreArchivo)
{
	var formulario = document.frm_PopUp;
	var lista = "";

	formulario.txt_HacerGrabar.value = "-1";
	formulario.txt_HacerUpload.value = "0";
	
	lista = lista + "txt_HacerGrabar=" +  formulario.txt_HacerGrabar.value;

	lista = lista + "&txt_Nombre=" + fn_Escape (trim (formulario.txt_Nombre.value));
	lista = lista + "&txt_Email=" + fn_Escape (trim (formulario.txt_Email.value));
	lista = lista + "&txt_NombreArchivo=" + fn_Escape (nombreArchivo);
	lista = lista + "&txt_Comentarios=" + fn_Escape (fn_ColocarSaltosDeLineaHTML (fn_QuitarBasuraExtremos (formulario.txt_Comentarios.value)));

	fn_InvocarAjax_Post ("index_ajax.php", lista);
}

function fn_GrabacionOk ()
{
	// Cerramos la ventana de 'subiendo video'.
	document.getElementById ("div_Procesando").style.display = "none";

	// Abrimos la ventana con la leyenda de 'video subido ok'.
	fn_AbrirVentanaProcesoOk ();
}

function fn_Bloqueo_Input_File (evento)
{
	if (!evento)
		var evento = window.event;

	if (evento.keyCode != 9 && evento.keyCode != 35 && evento.keyCode != 36 && evento.keyCode != 37 && evento.keyCode != 39)
	{
		alert ("Utilizá el bot" + String.fromCharCode (243) + "n 'Examinar...' para seleccionar el archivo.");
		document.frm_PopUp.txt_UploadArchivo.blur ();
	}
}

window.onscroll = fn_Scroll;

function fn_Scroll ()
{
	var objeto1 = document.getElementById ("div_PopUp");
	var objeto2 = document.getElementById ("div_Procesando");
	var objeto3 = document.getElementById ("div_ProcesoOk");
	var alto, top;
	
	if (objeto1.style.display == "block")	
	{
		alto = objeto1.clientHeight;		
		top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	
		objeto1.style.top = top.toString () + "px";
	}

	if (objeto2.style.display == "block")	
	{
		alto = objeto2.clientHeight;		
		top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	
		objeto2.style.top = top.toString () + "px";
	}

	if (objeto3.style.display == "block")	
	{
		alto = objeto3.clientHeight;		
		top = parseInt ((document.body.clientHeight - alto) / 2) + document.body.scrollTop;
	
		objeto3.style.top = top.toString () + "px";
	}
}
