/**************************************************************************************************************************************************
'***********************												FUNCIONES DE VALIDACIÓN																	 '***********************
'**************************************************************************************************************************************************/


/* ---------------------------------- Validar caracteres extraños ----------------------------------
Admite:	- Todos los caracteres excepto la '
Recibe el objeto TextFiel y devuelve true si contiene lo antes descrito y falso en cualquier otro caso
*/
function Validar_caracteres(campo)
{
	if (campo.value != "") 
	{
		if (campo.value.match(/^[^']*$/) == null)
		//if (campo.value.match(/[^A-Za-z0-9_ .ñÑá-úÁ-Úä-üÄ-Ü,.:;%@€ªº()\$\/-]/) != null)
		{  
    		return false;
		}
	}
	return true;
}

/* ---------------------------------- Validar caracteres en Busquedas ----------------------------------
Admite:	- Todos los caracteres excepto:  % ? 
Recibe el objeto TextFiel y devuelve true si contiene lo antes descrito y falso en cualquier otro caso
*/
function Validar_caracteres_busqueda(campo)
{
	if (campo.value != "") 
	{
		if (campo.value.match(/^[^%^?^']*$/) == null)
		{  
    		return false;
		}
	}
	return true;
}


/* ------------------- Validar caracteres extraños en Usuarios y Claves -----------------------------
Admite:	- Letras mayúsculas, minúsculas Sin incluir: Ññ
		- Números
Recibe el objeto TextFiel y devuelve true si contiene lo antes descrito y falso en cualquier otro caso
*/
function Validar_caractUsuPas(campo)
{
	if (campo.value != "")
	{
		if (campo.value.match(/[^A-Za-z0-9]/) != null) {  
    		return false;
		}
	}
	return true;
}

/* ---------------------------- Comprobar Campo numérico -------------------------------------------
Recibe el objeto TextField y devuelve true si todos los caracteres son números y falso en cualquier otro caso
*/
function Validar_Numerico(campo)
{
	if (campo.value != "")
	{
		if (campo.value.match(/[^0-9]/) != null) {  
    		return false;
		}
	}
	return true;
}

/* ---------------------------- Comprobar Campo Decimal -------------------------------------------
Recibe el objeto TextField y el Idioma para determinar el formato a cumplir.
Si Idioma = "IN" 
	Devuelve true si el separador de miles es la "," y el de decimales el "." (Ambos pueden omitirse)
Si Idioma = "EU" o "CA"
	Devuelve true si el separador de miles es el "." y el de decimales la "," (Ambos pueden omitirse)
En caso contrario devuelve False.
*/
function Validar_Decimales(campo, idioma)
{
	var ValorMatch
/*	//Formato Americano
	alert(campo.value.match(/^([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,})?|0(\.[0-9]{0,})?|(\.[0-9]{1,})?)$/))
	
	//Formato Europeo
	alert(campo.value.match(/^([1-9]{1}[0-9]{0,2}(\.[0-9]{3})*(\,[0-9]{0,})?|[1-9]{1}[0-9]{0,}(\,[0-9]{0,})?|0(\,[0-9]{0,})?|(\,[0-9]{1,})?)$/))
*/
	if (campo.value != "")
	{
		if (idioma == "IN" )
			ValorMatch = campo.value.match(/^([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,})?|[1-9]{1}[0-9]{0,}(\.[0-9]{0,})?|0(\.[0-9]{0,})?|(\.[0-9]{1,})?)$/)
		else
			ValorMatch = campo.value.match(/^([1-9]{1}[0-9]{0,2}(\.[0-9]{3})*(\,[0-9]{0,})?|[1-9]{1}[0-9]{0,}(\,[0-9]{0,})?|0(\,[0-9]{0,})?|(\,[0-9]{1,})?)$/)

		if (ValorMatch == null) {
    		return false;
		}
	}
	return true;
}

/* ---------------------------- Comprobar Formato Email -------------------------------------------
Admite:	- arroba, a-z, A-Z, 0-9, guión (-), guión bajo (_) y  punto (.)
		- Tiene que haber una sola arroba
		- A la derecha de la arroba, habrá al menos dos grupos de caracteres separados por un punto. 
			El último de ellos tendrá dos o más letras (a-z, A-Z).
		- A la izquierda de la arroba, habrá al menos un carácter.
Recibe el objeto TextFiel y devuelve true si contiene lo antes descrito y falso en cualquier otro caso
*/
function Validar_Email(campo)
{
	if (campo.value != "")
	{
		if (!campo.value.match(/^[\w-_\.]+@([\w-_]+\.)+[A-Za-z]{2,}$/ig)) {  
    		return false;
		}
	}
	return true;
}

/* ---------------------------- Comprobar Formato Teléfono -------------------------------------------
Admite:	teléfonos con espacios, parentesis en los prefijos, prefijo internacional y extensiones
	Ejemplos de formatos válidos:
	   +1 (123) 123 4567
	   02312 345 5467 56
	   +44 (123) 123 4567
	   +44 (123) 123 4567 ext 123
	   +44 (20) 789 4567
Recibe el objeto TextFiel y devuelve true si contiene lo antes descrito y falso en cualquier otro caso
*/
function Validar_Telefono(campo)
{
	if (campo.value != "")
	{
		if (!campo.value.test( /^(\+\d{1,3} ?)?(\(\d{1,5}\)|\d{1,5}) ?\d{3} ?\d{0,7}( ?(x|xtn|ext|extn|extension)?\.? ?\d{1,5})?$/i)) {  
    		return false;
		}
	}
	return true;
}


/**************************************************************************************************************************************************
'***********************												FUNCIONES DE CADENAS																		 '***********************
'**************************************************************************************************************************************************/


/* ------------------------- Comprobar cadena de espacios -------------------------------------------
Recibe el objeto y devuelve true si todos los caracteres son espacios y falso en cualquier otro caso
*/
function Cadena_espacios(campo)
{
	if (campo.value != "") 
	{
		if (campo.value.match(/^[ ]*$/) == null)
		{  
    		return false;
		}
	}
	return true;
}

/* ---------------------------- Eliminar Espacios En blanco-------------------------------------------
Recibe el objeto TextFiel y devuelve el contenido sin los espacios iniciales y finales.
*/
function Trim(cadena)
{
	var ini, fin, longitud = cadena.length-1;
	for (ini=0; cadena.charAt(ini) == " "; ini++);
	for (fin=longitud; cadena.charAt(fin) == " "; fin--);
	return cadena.substr(ini,fin-ini+1); 
}

/* ------------------------ Reutilizar Eliminar Espacios En blanco ----------------------------------
Recibe el objeto TextFiel y devuelve el contenido sin los espacios iniciales y finales.
*/
function trim(cadena)
{
	return Trim(cadena);
}


/* ------------------------------------------------------------------------
DESCRIPTION: Removes commas from source string.

PARAMETERS:
  strValue - Source string from which commas will
    be removed;

RETURNS: Source string with commas removed.
*/
function removeCommas( strValue ) {
  var objRegExp = /,/g; //search for commas globally

  //replace all matches with empty strings
  return strValue.replace(objRegExp,'');
}



/**************************************************************************************************************************************************
'***********************												FUNCIONES DE CALENDARIO																 '***********************
'**************************************************************************************************************************************************/



/* -------------------------------- Llamadas al calendario ------------------------------------------
Recibe el objeto fecha, camino al html del calendario y el Idioma en que debe ser mostrado
Abre el calendario y éste deja el valor seleccionado en el campo que aquí se recibe.
*/
function EDCal(NombreCampo,Camino, Idioma){

	eval("var valor = document.theform." + NombreCampo + ".value;");
	if ( valor != '' ) {
		if (!(isValidDate( valor, Idioma))){
 	    	eval("document.theform." + NombreCampo + ".select();");
        	eval("document.theform." + NombreCampo + ".focus();");
			return false;
  		}
	}
	//Definir el formato de fecha a utilizar en el calendario.
	selectedLanguage = Idioma.toLowerCase( )
	if (Idioma.toUpperCase( ) == 'EU')
		calDateFormat    = "yyyy/MM/DD";
	else if (Idioma.toUpperCase( ) == 'IN')
		calDateFormat    = "MM/DD/yyyy";
	else
		calDateFormat    = "DD/MM/yyyy";
	eval("setDateField(document.theform."+ NombreCampo +");");
	var CamiCalen = Camino + "calendario.asp";
	top.newWin = window.open(CamiCalen,'cal','width=210,height=230','dependent=yes,screenX=200, screenY=300, titlebar=yes');
     return true;
}
	
/* ----------------------- Convertir Date a Fecha con formato indicado ---------------------------------
Recibe el objeto de tipo date
Devuelve una cadena en el formato del Idioma recibido. Comprobado para los 3 Idiomas.
*/
function date_to_str (fecha, idioma) {
	var Strfecha	
	if (idioma == "EU")	{
		// yyyy/mm/dd
		Strfecha = fecha.getFullYear() + "/";
		Strfecha += (((fecha.getMonth() + 1) <10) ? "0" : "") + (fecha.getMonth() + 1) + "/";
		Strfecha += ((fecha.getDate()<10) ? "0" : "" ) + fecha.getDate();
	}
	else if (idioma == "IN"){
		// mm/dd/yyyy
		Strfecha = (((fecha.getMonth() + 1) <10) ? "0" : "") + (fecha.getMonth() + 1) + "/";
		Strfecha += ((fecha.getDate()<10) ? "0" : "" ) + fecha.getDate() + "/";
		Strfecha += fecha.getFullYear();
	}
	else {
		// dd/mm/yyyy
		Strfecha = ((fecha.getDate()<10) ? "0" : "" ) + fecha.getDate() + "/";
		Strfecha += (((fecha.getMonth() + 1) <10) ? "0" : "") + (fecha.getMonth() + 1) + "/";
		Strfecha += fecha.getFullYear();
	}
		return Strfecha
}

/* ---------------------- Valida Fecha en formato cadena del Idioma recibido -------------------------
Recibe el contenido del textFiel y el Idioma en que debe ser validado
Devuelve True si la fecha cumple ese formato, y falso en cualquier otro caso. Comprobado para los 3 Idiomas. 

	En estos momentos se visualizan mensajes específicos aqui, ¡¡¡Valorar como proceder!!!
	Solo estan en Euskera y Castellano, faltaría traducir en inglés.
*/
function isValidDate(dateStr, idioma)
{
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY

	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year
	var datePat_eu = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/; // requires 4 digit year

	textmes=new Array(12)
	textmes[1]="Enero"
	textmes[2]="Febrero"
	textmes[3]="Marzo"
	textmes[4]="Abril"
	textmes[5]="Mayo"
	textmes[6]="Junio"
	textmes[7]="Julio"
	textmes[8]="Agosto"
	textmes[9]="Septiembre"
	textmes[10]="Octubre"
	textmes[11]="Noviembre"
	textmes[12]="Diciembre"

	if (idioma.toUpperCase( ) == "EU")
		var matchArray = dateStr.match(datePat_eu); // El formato es correcto?
	else
		var matchArray = dateStr.match(datePat); // El formato es correcto?
		
	if (matchArray == null) 
		{
			if (idioma.toUpperCase( ) == "EU")
				alert(dateStr + " Dataren formatua oker dago.")
			else
				alert(dateStr + " Fecha con formato no válido.")
			return false;
		}
	// Almacenar los valores en variables
	if (idioma.toUpperCase( ) == "EU") {
		year = matchArray[1]; 
		month = matchArray[3];
		day = matchArray[4]; 
	} 
	else if (idioma.toUpperCase( ) == "IN") {
		month = matchArray[1]; 
		day = matchArray[3]; 
		year = matchArray[4];
	}
	else {
		day = matchArray[1]; 
		month = matchArray[3];
		year = matchArray[4];
	}
	//alert("dia:" + day + "mes:" + month + "Año:" + year)
	if (month < 1 || month > 12) 
		{ // Chequear el rango de los meses
			if (idioma.toUpperCase( ) == "EU")
				alert("Hilabeteak urtarrila eta abenduaren artekoa izan behar du." );
			else	
				alert("Mes debe ser entre Enero y Diciembre" );
			return false;
		}
	if (day < 1 || day > 31) 
		// Chequear el rango de los dias
		{	if (idioma.toUpperCase( ) == "EU")
				alert("Egunak 1 eta 31aren artekoa izan behar du.");
			else
				alert("Día debe ser entre 1 y 31.");
			return false;
		}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
		{ // Chequear el rango de los dias si son meses de 30 dias
		var ValMes =eval("textmes["+ month +"];");
		if (idioma.toUpperCase( ) == "EU")
			alert(ValMes+"k ez dauka 31 egun!")
		else
			alert("El mes de  "+ValMes+" no tiene 31 días!")
		return false;
		}
	if (month == 2) 
		{ // Chequear el rango de los dias si es febrero
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) 
			{if (idioma.toUpperCase( ) == "EU")
				alert(year + "ko otsailak ez dauka " + day + " egun!");

			 else	
				 alert("Febrero del año " + year + " no tiene " + day + " días!");
			return false;
		   }
		}

return true;
}

/* ---------------------- Comprueba si una fecha es mayor que otra  -------------------------
Recibe el contenido de los dos textFiel y el Idioma en que debe ser validado
Devuelve True si la FechaFin es Mayor que FechaIni , y falso en caso contrario. Comprobado para los 3 Idiomas.
*/
function esFechaMayor(fini,ffin,idioma)

{
	//
	if (idioma.toUpperCase( ) == "EU")
		var datePat = /^(\d{4})(\/|-)(\d{1,2})\2(\d{1,2})$/; // requires 4 digit year
	else
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/; // requires 4 digit year			
	var todatei = fini;       
	var todatef = ffin;
	var matchArrayi = todatei.match(datePat); 
	var matchArrayf = todatef.match(datePat);
	if (idioma.toUpperCase( ) == "EU")
	{
		var todateii = new Date(matchArrayi[1], matchArrayi[3] -1 , matchArrayi[4] );       
		var todateff = new Date(matchArrayf[1], matchArrayf[3] -1, matchArrayf[4] );

	}
	else if (idioma.toUpperCase( ) == "IN")
	{
		var todateii = new Date(matchArrayi[4] , matchArrayi[1] -1 , matchArrayi[3]);       
		var todateff = new Date(matchArrayf[4] , matchArrayf[1] -1 , matchArrayf[3]);
	}
	else
	{
		var todateii = new Date(matchArrayi[4], matchArrayi[3] -1 , matchArrayi[1]);       
		var todateff = new Date(matchArrayf[4], matchArrayf[3] -1 , matchArrayf[1]);
	}

	var datediff = todateff.getTime()- todateii.getTime() ;
	var daydiff = Math.round(datediff / (1000 * 60 * 60 * 24));
	if (daydiff >= 0)
		{
		return true;
		}
	else 
		{ 		
			return false;
		}
		    
return true;
}



/**************************************************************************************************************************************************
'***********************												FUNCIONES DE ESTILO																			 '***********************
'**************************************************************************************************************************************************/



/* ---------------------- Cambia de color los TR (Lista)  -------------------------
Recibe la fila a dar color, color de entrada y tipo de cursor
Dibuja la fila con los parámetros indicados
*/
function entrar(src,color_entrada, tip_cursor) 
{
	src.bgColor=color_entrada;
	src.style.cursor=tip_cursor;
}

/* ---------------------- Cambia de color los TR (Lista)  -------------------------
Recibe la fila a quitar color, color default
Dibuja la fila con los parámetros indicados
*/
function sortir(src,color_default) 
{
	src.bgColor=color_default;src.style.cursor="default";
}

/* ---------------------- Selecciona un TR (Lista)  -------------------------
Recibe la fila a quitar color, color default
Selecciona el campo del formulario recibido, teniendo en cuenta el numero de elemento y tamaña de la lista
*/
function SeleccionarOpcion(n, formulario, campo, tamanno)
{ 
	if ((tamanno == 1) && (n == 0)){
		eval("document."+formulario+"."+campo+".checked=true;");
	}else{
		eval("document."+formulario+"."+campo+"[n].checked=true;");
	}	
}


//Esta funcion puede eliminarse si decidimos validar los decimales mediante la expresion regular y dar solo un mensaje genérico
function comprobarDecimales(fieldName, idioma, NumMaxEnt, NumMaxDeci) {

if (Trim(fieldName.value) != ""){ // Solo haremos la comprobación si el valor es distinto de "" 
	// Comprobamos que solo meten números, puntos o comas.
	 var valcorr = true;
	 var lon = fieldName.value.length; 
	 var can_sepdec = 0;
	 var valido2='0123456789';     	// caracteres numéricos válidos
		for (i = 0; i < lon ; i++)
		{
			ss = fieldName.value.substr(i, 1);
	
			if (( ss == 1) || (ss == 2) ||( ss == 3) || (ss == 4)||( ss == 5) || (ss == 6) ||( ss == 7) || (ss == 8) || ( ss == 9) || (ss == 0) ||( ss == ",")||( ss == "."))
			{
					if(ss ==".")  {
					  if (valido2.indexOf(fieldName.value.charAt(i-1)) == -1 
						|| fieldName.value.charAt(i-1) == ''
						|| valido2.indexOf(fieldName.value.charAt(i+1)) == -1
						|| fieldName.value.charAt(i+1) == ''
						|| valido2.indexOf(fieldName.value.charAt(i+2)) == -1
						|| fieldName.value.charAt(i+2) == ''
						|| valido2.indexOf(fieldName.value.charAt(i+3)) == -1
						|| fieldName.value.charAt(i+3) == '') {
	//traduccir INI
							if (idioma.toUpperCase( ) == "EU")
								alert('Separador de enteros (.) mal posicionado EU')
							else
								alert('Separador de enteros (.) mal posicionado')
	//traduccir FIN
							fieldName.select();
							fieldName.focus();
							return false;
					  }
					  else
						 {
						if(valido2.indexOf(fieldName.value.charAt(i+4)) != -1
						  && fieldName.value.charAt(i+4) != '') {
	//traduccir INI
						if (idioma.toUpperCase( ) == "EU")
							alert('Si utiliza puntuación de miles, no omita ninguno EU')
						else
							alert('Si utiliza puntuación de miles, no omita ninguno')
	//traduccir FIN
						  fieldName.select();
						  fieldName.focus();
						   return false;
							}
						 if(i > 3 && fieldName.value.charAt(i-4) != ''
						&& valido2.indexOf(fieldName.value.charAt(i-4)) != -1) {
	//traduccir INI
							if (idioma.toUpperCase( ) == "EU")
								alert('Si utiliza puntuación de miles, no omita ninguno EU')
							else
								alert('Si utiliza puntuación de miles, no omita ninguno')
	//traduccir FIN
							fieldName.select();
							fieldName.focus();
							 return false;
							}
						}
						}	
			}
			else
			{valcorr = false;
			}
		 if(ss == ",") {
		   can_sepdec++;
		}
		}
	
	//decpermitidos = 3;  // Decimales que permitimos meter
	if (valcorr != true) { //
	//traduccir INI
		if (idioma.toUpperCase( ) == "EU")
			alert('El campo tiene que ser numérico EU')
		else
			alert('El campo tiene que ser numérico')
	//traduccir FIN
		fieldName.select();
		fieldName.focus();
		return false;
	}
	else {
			if(can_sepdec > 1) {
	//traduccir INI
				if (idioma.toUpperCase( ) == "EU")
					alert('Ingresar solo una (,) para decimales EU')
				else
					alert('Ingresar solo una (,) para decimales')
	//traduccir FIN
				 fieldName.select();
				 fieldName.focus();
				 return (false);
			 }
			else {
				if (fieldName.value.indexOf(',') == -1) fieldName.value += ",";
				dectext = fieldName.value.substring(fieldName.value.indexOf(',')+1, fieldName.value.length);
			}
			
			var PartEntera = fieldName.value.split(",")[0];
			var ParEntPuntos = PartEntera
			var PartDecimal = fieldName.value.split(",")[1];
			for (i = 0; i < PartEntera.length ; i++){
			 PartEntera = PartEntera.replace(".", "");
			}
			
			if(PartEntera.length > NumMaxEnt){
				if (NumMaxDeci == 0){
					fieldName.value = ParEntPuntos;
				}
				if (idioma.toUpperCase( ) == "EU")
					alert('El número máximo de enteros es '+NumMaxEnt +' EU');
				else
					alert('El número máximo de enteros es '+NumMaxEnt)
				fieldName.select();
				fieldName.focus();
				return (false);
			}
			else{
				if (PartDecimal.length > 0){
					if (PartDecimal.length > NumMaxDeci){
						if (idioma.toUpperCase( ) == "EU")
							alert('El número máximo de decimales es '+NumMaxDeci+' EU');
						else
							alert('El número máximo de decimales es '+NumMaxDeci)
						fieldName.select();
						fieldName.focus();
						return (false);
					}
				}
			}
			if (NumMaxDeci == 0){
				fieldName.value = ParEntPuntos;
			}
			return(true)
	 }
 }
 else{
	return(true)
 }
}

/**************************************************************************************************************************************************
'***********************												FUNCIONES DE ACCESIBILIDAD															 '***********************
'**************************************************************************************************************************************************/
var dw_fontSizer = {
  // sizeUnit and defaultSize for body.style.fontSize
  sizeUnit: "px",
  defaultSize: 14,
  // numbers (same unit as sizeUnit)
  maxSize:     24,
  minSize:     10,

  // Inicializa el controlador de tamaño de fuentes
  init: function() {
    if ( !document.body || !document.getElementById ) return;
    var size = window.location.search? window.location.search.slice(1): getCookie("fontSize");
    size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
    // in case default unit changed or size passed in url out of range
    if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
    var sizerEl = document.getElementById('sizer');
    if (sizerEl) sizerEl.style.display = "block";
    document.body.style.fontSize = size + this.sizeUnit;
  },
  
  // Cambia el tamaño de las fuentes de pantalla
  adjust: function(inc) {
    var size = parseFloat( document.body.style.fontSize );
    size += inc;
    // Test against max and min sizes 
    if (inc > 0) size = Math.min(size, this.maxSize);
    else size = Math.max(size, this.minSize);
    setCookie( "fontSize", size, 180, "/" );
    document.body.style.fontSize = size + this.sizeUnit;
  },

  // Devuelve al tamaño de fuentes su valor inicial
  reset: function() {
    document.body.style.fontSize = this.defaultSize + this.sizeUnit;
    deleteCookie("fontSize", "/");
  }
}


/**************************************************************************************************************************************************
'***********************												FUNCIONES DE COOKIES																		 '***********************
'**************************************************************************************************************************************************/
/* ---------------------- Establece una cookie  -------------------------
Recibe los parámetros de la cookie y la crea con el nombre recibido
*/
function setCookie(name,value,days,path,domain,secure) {
  var expires, date;
  if (typeof days == "number") {
    date = new Date();
    date.setTime( date.getTime() + (days*24*60*60*1000) );
		expires = date.toGMTString();
  }
  document.cookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

/* ---------------------- Obtiene el valor de una cookie  -------------------------
*/
function getCookie(name) {
  var nameq = name + "=";
  var c_ar = document.cookie.split(';');
  for (var i=0; i<c_ar.length; i++) {
    var c = c_ar[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameq) == 0) return unescape( c.substring(nameq.length, c.length) );
  }
  return null;
}

/* ---------------------- Elimina una cookie  -------------------------
	Establece una cookie como caducada
*/
function deleteCookie(name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

/*function escribirCanalTB(textoScr, textoLink,size){
	var tamanyo = 0
	if (size==0)
	{
		document.write('<embed name="video_rm" id="video_rm" src="' + textoScr + '" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" width="352" height="262" autostart="true" SCRIPTCALLBACKS="All"> </embed>')
		tamanyo = 1
	}
	else
	{
		document.write('<embed name="video_rm" id="video_rm" src="' + textoScr + '" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" width="552" height="412" autostart="true" SCRIPTCALLBACKS="All"> </embed>')
	}
	document.write('<noembed><a href="CanalTBTexto.asp">' + textoLink + '</a></noembed>')
	//document.write('<br />')
	document.write('<div id="cajaControlesRealPlayer">')
	document.write('<a href="CanalTB.asp?size=' + tamanyo + '"><img src="../irudiak/ico_aumentarPantalla_1.gif" title="Aumentar Tamaño" /></a>')
	document.write('<embed console="Clip1" type="audio/x-pn-realaudio-plugin" controls="all" height="75" width="194" autostart=true></embed>')
	document.write('<noembed>&nbsp;</noembed>')
	document.write('<a href="javascript:verPantallaCompleta();"><img src="../irudiak/ico_aumentarPantalla_2.gif" title="Aumentar Tamaño" /></a>')
	document.write('</div>')
}*/
function escribirCanalTB(textoScr, textoLink,size,size1,texto1,texto2){
	var tamanyo = 0
	if (size==0)
	{
		document.write('<embed name="video_rm" id="video_rm" src="' + textoScr + '" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" width="352" height="262" autostart="true" SCRIPTCALLBACKS="All"> </embed>')
		tamanyo = 1
	}
	else
	{
		document.write('<embed name="video_rm" id="video_rm" src="' + textoScr + '" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" width="552" height="412" autostart="true" SCRIPTCALLBACKS="All"> </embed>')
	}
	document.write('<noembed><a href="CanalTBTexto.asp">' + textoLink + '</a></noembed>')
	//document.write('<br />')
	document.write('<div class="cajaControlesRealPlayer">')
	//document.write('<a href="CanalTB.asp?size=' + tamanyo + '"><img src="../irudiak/ico_aumentarPantalla_1.gif" title="Aumentar Tamaño" /></a>')
	document.write('<embed console="Clip1" type="audio/x-pn-realaudio-plugin" controls="all" height="75" width="194" autostart=true></embed>')
	document.write('<noembed>&nbsp;</noembed>')
	//document.write('<a href="javascript:verPantallaCompleta();"><img src="../irudiak/ico_aumentarPantalla_2.gif" title="Aumentar Tamaño" /></a>')
	enlaceTamanyoVideo(size1,texto1);
	enlaceFullScreenVideo(texto2);
	document.write('</div>')
}

function enlaceTamanyoVideo(size,texto)
{
	if (size == 1)
	{
		document.write('<div class="aumentar_video">');
	}
	else
	{
		document.write('<div class="disminuir_video">');
	}
	document.write('<a href="CanalTB.asp?size=' + size + '">' + texto + '</a>');
	document.write('</div>');
}

function enlaceFullScreenVideo(texto)
{
	document.write('<div class="pantalla_completa">');
	document.write('<a href="javascript:verPantallaCompleta();">' + texto + '</a>');
	document.write('</div>');
}

function verPantallaCompleta()
{
	document.getElementById("video_rm").SetFullScreen();
			
}

function escribirVideo(textoScr, textoLink){
	document.write('<embed name="video_rm" id="video_rm" src="' + textoScr + '" type="audio/x-pn-realaudio-plugin" console="Clip1" controls="ImageWindow" height=262 width=352 autostart=true scriptcallbacks=All></embed>')
	document.write('<noembed><a href="CanalTBTexto.asp">' + textoLink + '</a></noembed>')
	document.write('<br />')
	document.write('<embed console="Clip1" type="audio/x-pn-realaudio-plugin" controls="All" height=75 width=194 autostart=true> </embed>')
	document.write('<noembed>&nbsp;</noembed>')
	document.write('<div id="pie_video">')
	document.write(textoLink)
	document.write('</div>')
}
