function buscar(pagina, paginar) {
	var pagina = pagina || 0;
	var paginar = paginar || '';
	var form = document.forms['buscador'];
	if(form.text.value != '') {
		form.pagina.value = pagina;
		form.pagina.name += paginar;
		form.paginar.value = paginar;
		form.action = document.location.href;
		form.submit();		
	}
}


function resize()
{
	if( window.frameElement )
	{
	  window.frameElement.style.backgroundColor = '#fff';
	  
	  var width  = document.getElementById('divTblGeneral').offsetWidth;
	  var height = document.getElementById('divTblGeneral').offsetHeight;
		var vtop 	 = 80 + top.document.documentElement.scrollTop;
		var left	 = ((parent.document.body.offsetWidth )/2)-(width/2);
		
		if(isMSIE())
		{
			window.frameElement.style.width		= width;
			window.frameElement.style.height	= height;
			window.frameElement.style.left 		= left;
			window.frameElement.style.top 		= vtop;
		}else{
			window.frameElement.style.width		= width+'px';
			window.frameElement.style.height	= height+'px';
			window.frameElement.style.left 		= left+'px';
			window.frameElement.style.top 		= vtop+'px';
			
		}
	}
}


window.PopUpLogin = function(src, iframe_name)
{
	if( typeof(iframe_name) == "undefined" ){
		var iframe_name = (Math.random()*10000).toString();
	}

	if(typeof(window.parent.objAdministratorBar) == "undefined")
	{
		//document.body.scroll = 'no';
		//document.body.style.overflow = 'hidden';
		block(); 
		
		var strFrame = (isMSIE()) ? "<iframe name="+iframe_name+" frameborder='0' allowtransparency='true'>" : "iframe";
		
		
		objPopup = document.createElement(strFrame);
		objPopup.setAttribute("frameborder"	,	"0");
		objPopup.setAttribute("scrolling"		,	"no");
		
		objPopup.name = iframe_name;
		objPopup.src	= src;
		objPopup.style.position	= 'absolute';
		objPopup.style.border	= '0';
		var width		= '423';
		var height	= '400';
		var top 		= (screen.height - height) / 2;
		var left 		= (screen.width - width) / 2;
		
		
		
		if(isMSIE()){
			objPopup.style.width	= width;
			objPopup.style.height	= height;
			objPopup.style.top 	= top;
			objPopup.style.left = left;
		}else{
			objPopup.style.width	= width+'px';
			objPopup.style.height	= height+'px';
			objPopup.style.top 	= top+'px';
			objPopup.style.left = left+'px';
		}
		
		document.body.appendChild(objPopup);
	}
	else
	{
		window.location = src;
	}
}

function toggleObj(id)
{
	document.getElementById(id).style.display = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';	
}

function enviarPrograma(frm) {

	var email_r 		= frm.email_remitente.value;
	var email_d 		= frm.email_destinatarios.value;
	var asunto_val 	= frm.asunto.value;
	var nombre_val 	= frm.nombre.value;
	var mensaje_val = frm.mensaje.value;
	var idPrograma_emision = frm.idPrograma_emision.value;
	var msg;
	
	if (nombre_val == "")
	{
		msg = "Por favor ingrese su nombre.";
		frm.nombre.focus();
		window.alert(msg);
		return;
	}
		
	if (email_r == "")
	{
		msg = "Por favor ingrese su dirección de email.";
		frm.email_remitente.focus();
		window.alert(msg);
		return;
	}
	
	if (email_d == "")
	{
		msg = "Por favor ingrese los destinatarios.";
		frm.email_destinatarios.focus();
		window.alert(msg);
		return;
	}
	
	var arrDestinatarios = email_d.split(',');
	
	for(i=0;i<arrDestinatarios.length;i++)
	{
		if (!isValidEmail(arrDestinatarios[i].trim()))
	{
		msg = "La dirección de email '"+arrDestinatarios[i]+"' no es válida.";
		frm.email_destinatarios.focus();
		window.alert(msg);
		return;
	}
	}
	
	if (!isValidEmail(email_r))
	{
		msg = "La dirección de email ingresada no es válida.";
		frm.email_remitente.focus();
		window.alert(msg);
		return;
	}
	
	if (mensaje_val == "")
	{
		msg = "Por favor ingrese su comentario.";
		frm.mensaje.focus();
		window.alert(msg);
		return;
	}

	window._post("../_post/mtv/enviar_programa.php?tipoEnvio=0&dest=form-enviar&asunto="+asunto_val+"&idPrograma_emision="+idPrograma_emision+"&nombre="+nombre_val+"&email_r="+email_r+"&email_d="+email_d+"&mensaje="+mensaje_val);
	return;
}

function mostrarEnviarPrograma(){
	
	var frm = document.getElementById('form-enviar');
	
	if(frm.style.display == 'none')
		frm.style.display = 'inline';
	else
		frm.style.display = 'none';
	
	}

var actual_font_size 		= 12;


function aumentar_tipografia(id){

	if( actual_font_size < 31 )	actual_font_size++;
	setTamFuente(document.getElementById(id),actual_font_size);
}

function reducir_tipografia(id){
	if( actual_font_size > 9 )	actual_font_size--;
	setTamFuente(document.getElementById(id),actual_font_size);
}

function setTamFuente(nodo,tamanio)
{
	//debugger;
	// nodo actual
	if(nodo && nodo.style){
		nodo.style.fontSize = tamanio+'px';
		nodo.style.lineHeight = parseInt((tamanio*1)+4)+'px';
	}
	
	// tiene hijos?
	if(nodo.childNodes.length)
	{
		nodo = nodo.firstChild;
		
		// primer hijo
		if(nodo.style){
			nodo.style.fontSize = tamanio+'px';
			nodo.style.lineHeight = parseInt((tamanio*1)+4)+'px';
		}
		
		setTamFuente(nodo,tamanio);
		
		// resto de los hijos
		while(nodo = nodo.nextSibling)
		{
			if(nodo.style) 
			{
				nodo.style.fontSize = tamanio+'px';
				nodo.style.lineHeight = parseInt((tamanio*1)+4)+'px';
			}
			
			setTamFuente(nodo,tamanio);
		}
	}
}

function clear_this(obj,val){
	if(obj.value == val) obj.value = '';
	return;
}

function fill_this(obj,val){
	if(obj.value == '') obj.value = val;
	return;
}

function suscribir(frm,dest) {
	var email_val = frm.email.value, msg;
	if (email_val == "")
		msg = "Por favor ingrese su dirección de email.";
	else if (!isValidEmail(email_val))
		msg = "La dirección de email ingresada no es válida.";
	else { // Validación OK
		window._post("../_post/mtv/suscribir_newsletter.php?email="+ email_val+"&dest="+dest);
		return;
	}
	// Validación falló
	frm.email.focus();
	window.alert(msg);
}

function contacto(f) {
  frm = document.getElementById(f);
	var email_val = frm.email.value;
	var nombre_val = frm.nombre.value;
	var comentario_val = frm.comentario.value;
	var msg = '';
	
	if (nombre_val == "" && msg)
	{
		msg = "Por favor ingrese su nombre.";
		frm.nombre.focus();
		alert(msg);
		return;
	}
		
	if (email_val == "")
	{
		msg = "Por favor ingrese su dirección de email.";
		alert(msg);
		return;
	}
	
	if (!isValidEmail(email_val))
	{
		msg = "La dirección de email ingresada no es válida.";
		alert(msg);
		return;
	}
	
	if (comentario_val == "")
	{
		msg = "Por favor ingrese su comentario.";
		alert(msg);
		frm.comentario.focus();
		return;
	}

	window._post("../_post/mtv/enviar_contacto.php?tipoEnvio=1&nombre="+nombre_val+"&email="+email_val+"&comentario="+comentario_val);
	frm.nombre.value = '';
	frm.email.value = '';
	frm.comentario.value = ''
	return;
}
 
function isValidEmail(email) {
	// User
	var atom = "[a-z0-9!#$%&'*+\\-\\/=?^_`{|}~]+",
		quoted = '"([^"]|\\")+"',
		user = "("+ atom +"(\\."+ atom +")*|"+ quoted +")";
	// Domain
	var label = "[a-z](-?[a-z0-9]+)*",
		tld = "[a-z]{2,6}",
		domain = label +"(\\."+ label +")*\\."+ tld +"\\.?";
	// Full regexp
	var re = eval("/^"+ user +"@"+ domain +"$/i");
	return re.test(email);
}


function trim(valor) {
	var re = /^(\s)*|(\s)*$/;
	var str = (valor? valor: this);
	return str.replace(re, "");
}
String.prototype.trim = trim;

function $() {
	var elements = new Array(), i, e;
	for (i = 0; i < arguments.length; ++i) {
		e = arguments[i];
		if (typeof element == "string")
			e = document.getElementById(e);
		if (arguments.length == 1)
			return e;
		elements.push(e);
	}
	return elements;
}

/* Debug */
function isMSIE() {
	return (navigator.appName == "Microsoft Internet Explorer");
}

function dump(o, func) {
	var str = "";
	for (p in o) {
		if (typeof o[p]!="function" || func)
			str += "\t" + p + " => " + o[p] + "\r\n";
	}
	str = "(" + typeof(o) + ") " + o + " \r\n{\r\n" + str + "}";
	return str;
}

function dumpWindow(o, nombre, func) {
	func = func == true;
	nombre = (typeof(nombre) == "undefined")? "Debug":nombre;
	var hw = popup("", nombre, 600, 600, "yes", "yes");
	var htmlDump = dump(o, func).replace(/<(\/)?script/gi, "< $1script");
	var htmlDoc = '<html><body><pre style="font:13px \'Courier New\'">'+ htmlDump +'</pre></body></html>';
	hw.document.open();
	hw.document.write(htmlDoc);
	hw.document.close();
}

function sumVisitasAdjunto(idAdjunto) {
	_post("../_post/contar_adjunto.php?idAdjunto="+ idAdjunto);
}

function popup(url, name, width, height, isResizable, hasScrollbars, hasToolbar, hasMenubar, hasStatus) {
	isResizable = typeof(isResizable)   =='undefined'? 'no':isResizable;
	hasScrollbars = typeof(hasScrollbars) =='undefined'? 'auto':hasScrollbars;
	hasToolbar = typeof(hasToolbar)    =='undefined'? 'no':hasToolbar;
	hasMenubar = typeof(hasMenubar)    =='undefined'? 'no':hasMenubar;
	hasStatus = typeof(hasStatus)     =='undefined'? 'yes':hasStatus;

	var top = (screen.height - height) / 2;
	var left = (screen.width - width) / 2;
	var settings = 'width='+width+', height='+height+', top='+top+', left='+left+', resizable='+isResizable+', scrollbars='+hasScrollbars+', toolbar='+hasToolbar+', menubar='+hasMenubar+', status='+hasStatus;
	return window.open(url, name, settings);
}
/* Fin Debug */

function _attachEvent(element, name, observer) {
	if (element.addEventListener)
		element.addEventListener(name.replace("on", ""), observer, true);
	else if (element.attachEvent)
		element.attachEvent(name, observer);
}

var request = new Object();
var aParams = document.location.search.substr(1).split('&');
for (i = 0; i < aParams.length; i++) {
	var aParam = aParams[i].split('=');
  var sParamName = aParam[0];
  var sParamValue = aParam[1];
	request[ sParamName ] = sParamValue;
}
/**/
function swapLang(idCMSIdioma) {
	if (typeof parent.window.objPortales != 'undefined') parent.window.objPortales._reload();
	document.cookie = "idCMSIdioma="+idCMSIdioma+"; path=/; ";
	window.location.reload();
}

function cambioIdioma(idCMSIdioma) {
	if (typeof parent.window.objPortales != 'undefined') parent.window.objPortales._reload();
	document.cookie = "idCMSIdioma="+idCMSIdioma+"; path=/; ";
	window.location.reload();
}

function runSWF(archivo, ancho, alto, version, bgcolor, id, idm, menu, FlashVars, quality, allowScriptAccess, writeScript) {
  if (version!="") {
  	var version_data=version;
  }else{
  	var version_data="6, 0, 0, 0";
  }
  if (menu!="") {
  	menu_data=menu;
  }else{
  	menu_data=false;
  }
  if (bgcolor!="") {
  	var bgcolor_data=bgcolor;
  }else{
  	var bgcolor_data="#FFFFFF";
  }
  if (id!="") {
  	id_data=id;
  }else{
  	id_data="flashMovie";
  }
  if (quality!="") {
  	quality_data=quality;
  }else{
  	quality_data="high";
  }
  if (allowScriptAccess!="") {
  	allowScriptAccess_data=allowScriptAccess;
  }else{
  	allowScriptAccess_data="always";
  }
  if (typeof(writeScript) == "undefined") {
    writeScript = "1";
  }
//alert(archivo);
  var quality="high"; // calidad de visualización de la peli
  html = "";
  html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n';
  html += '<param name="movie" value='+archivo+'>\n';
  html += '<param name="allowScriptAccess" value='+allowScriptAccess_data+'>\n';
  html += '<param name="quality" value='+quality_data+'>\n';
  html += '<param name="FlashVars" value='+FlashVars+'>\n';
  html += '<param name="bgcolor" value='+bgcolor_data+'>\n';
  html += '<param name="menu" value='+menu_data+' >\n';
  html += '<param name="wmode" value="transparent">\n';
  html += '<embed wmode="transparent" src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect="true" id='+idm+' ></embed>';
  html += '</object>\n';

  if (writeScript == "1") {
    document.write(html);
  }else{
    return html;
  }
}

function IrAPagina(pagina) {
	var url = "../interior/index.php?pagina="+pagina;
	for (var i in request) {
		if (i != 'pagina')	{
			url += "&" + i +"=" + request[i];
		}
	}
	window.location = url;
}

function setRequest(campo, valor) {
	request[campo] = valor;
	IrAPagina(0);
}

/** [EA 15/05/2007 16:17] - Esta funcion la utiliza el flash del cabezal de MD
	* Por favor, no modificar
	*/
function search(text) {
	var page = page || "resultado";
	window.location = '../interior/index.php?p='+page+'&text='+text+'&dinamica=1';
}


function _search(text, page) {
	if (text.length < 1) {
		alert("Por favor, ingrese un texto para buscar.");
	}
	else {
		var page = page || "resultado";
		window.location = '../interior/index.php?p='+page+'&text='+text;
	}
}

var objBlock = null;

function block() {
	if (objBlock == null) {
//		document.body.scroll = "no";
		document.body.style.overflow = "hidden";
		objBlock = document.createElement("iframe");
		objBlock.frameborder = "0";
		objBlock.src = "../interior/block.html";
		objBlock.style.position = "absolute";
		objBlock.style.border = "0";
		objBlock.style.top = "0px";
		objBlock.style.left = "0px";
		objBlock.style.width = document.body.offsetWidth +"px";
		objBlock.style.height = (document.body.offsetHeight + document.body.scrollHeight) +"px";
		objBlock.className = "blockPage";
		document.body.appendChild(objBlock);
	}
}

function unblock() {
	if (objBlock != null) {
//		document.body.scroll = "yes";
		document.body.style.overflow = "auto";
		objBlock.parentNode.removeChild(objBlock);
		delete(objBlock);
		objBlock = null;
	}
}

window.openGaleria = function(src) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		block();
		var strFrame = isMSIE()? '<iframe frameborder="0" scrolling="no">': "iframe";
		objPopup = document.createElement(strFrame);
		objPopup.style.position = "absolute";
		objPopup.setAttribute("frameborder", "0");
		objPopup.setAttribute("scrolling", "no");
		objPopup.src = src;
		document.body.appendChild(objPopup);
	}
	else
		window.location = src;
}

window.closeGaleria = function() {
	unblock();
	objPopup.parentNode.removeChild(objPopup);
	delete(objPopup);
	objPopup = null;
}

window._post = function(url) {
	var _objPost = document.createElement("iframe");
	_objPost.style.display = "none";
	_objPost.style.width = "100%";
	_objPost.style.height = "200px";
	_objPost.src = url;
	document.body.appendChild(_objPost);
}

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  var end = -1;

  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
    end = dc.indexOf('; ');
  }
  else {
  	begin += 2;
  	var end = document.cookie.indexOf("; ", begin);
  	if (end == -1) {
    	end = dc.length;
    }
  }
  return unescape(dc.substring(begin + prefix.length, end));
}

function responder(idTextarea) {
	document.getElementById(idTextarea).focus();
}

function insertar_comentario(idPortal, idModulo, idContenido, idNota, tipoEnvio) {
  
  
  var autor					= document.getElementById('autor_'+idContenido);
	var comentario 		= document.getElementById('comentario_'+idContenido);
	var randomUsuario = document.getElementById('randomUsuario_'+idContenido);
	var randomSistema = document.getElementById('random_'+idContenido);
	
	var autorTxt 					= autor.value;
	var comentarioTxt 		= comentario.value;
	var randomUsuarioTxt 	= randomUsuario.value;
	
	
	
	bool = true;

	if (bool && !autorTxt.trim()) {
		alert("Por Favor, ingrese su Nombre");
		autor.focus();
		bool = false;
	}

	if (bool && !comentarioTxt.trim()) {
		alert("Por Favor, ingrese su comentario");
		comentario.focus();
		bool = false;
	}

	if (bool && !randomUsuarioTxt.trim()) {
		alert("Por Favor, ingrese el Codigo de Validación");
		randomUsuario.focus();
		bool = false;
	}

	if (bool && (randomUsuario.value != randomSistema.value)) {
		alert("Por Favor, reingrese el Codigo de Validacion Correcto");
		randomUsuario.focus();
		bool = false;
	}

	if (bool) {
		var src = "../_post/insertar_comentario.php?idPortal="+idPortal+"&idModulo="+idModulo+"&idContenido="+idContenido+"&autor="+autorTxt+"&comentario="+comentarioTxt+"&idNota="+idNota+"&tipoEnvio="+tipoEnvio;
		window._post(src);
	}
	
}

function votar_encuesta(idForm, idEncuesta) {
	var opcion = false;
	var form = document.forms[idForm];
	for (i=0; i < form.elements.length; i++) {
		if (form.elements[i].name.substr(0, 6) == "opcion") {
			if (form.elements[i].checked == true) {
				var opcion = true;
	 			if (getCookie("CMSVotosEncustas["+idEncuesta+"]") != idEncuesta) {
	 				var expire = new Date('2049, 08, 12'); // Este dia voy a a tener.... 69:P
	 				window._post("../_post/votar_encuesta.php?encuesta_opcion="+form.elements[i].value);
	 				document.cookie = "CMSVotosEncustas["+idEncuesta+"]=" + idEncuesta + "; path=/; expire="+expire.toGMTString();
	 				habilitar_encuesta(idEncuesta);
	 				alert("Gracias por participar.");

	 			}
	 			else alert("Usted ya voto esta encuesta");
				break;
			}
		}
	}
	if (!opcion)	alert("Debe seleccionar una opcion para votar");
}

function habilitar_encuesta(idEncuesta) {
	var div_encuesta = document.getElementById("encuesta_"+idEncuesta);
	var div_resultadoEncuesta = document.getElementById("resultadoEncuesta_"+idEncuesta);

	if (getCookie("CMSVotosEncustas["+idEncuesta+"]") != idEncuesta) {
 		div_resultadoEncuesta.style.display = "none";
 		div_encuesta.style.display = "block";
	}else{
		div_encuesta.style.display = "none";
		div_resultadoEncuesta.style.display = "block";
	}
}

/** [EA 28/04/2007 15:28]
 * Crea un iframe, y lo hubica en el centro de la pagina
 */
window.PopUp = function(src, iframeName) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		block();
		if (!iframeName)
			iframeName = (Math.random() * 10000).toString();
		var strFrame = isMSIE()? '<iframe name="'+iframeName+'" frameborder="0">': "iframe";
		objPopup = document.createElement(strFrame);
		objPopup.setAttribute("frameborder", "0");
		objPopup.setAttribute("scrolling", "no");
		objPopup.name = iframeName;
		objPopup.src = src;
		objPopup.style.position = "absolute";
		objPopup.style.top = "100px";
		objPopup.style.left = "100px";
		document.body.appendChild(objPopup);
	}
	else
		window.location = src;
}
/** [EA 28/04/2007 15:28]
 * Cierro el iframe creado por la funcion PopUp
 */
window.closePopUp = function() {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		unblock();
		objPopup.parentNode.removeChild(objPopup);
		delete(objPopup);
		objPopup = null;
	}
	else
		history.back();
}

function enviar_error(tipoEnvio) {
		window.PopUp("../_post/enviar_email.php?tipoEnvio="+tipoEnvio);
}

/* Guille: para que sirve esta funcion???? */
/* dentro del cuerpo de la nota, abajo de todo, esta COMPARTIR, la funcion te redirije a la url de cada Icono*/
function link(url) {
	window.open(url);
}


window.imprimirNota = function(src) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		PopUp(src);
	}
	else {
		window.location = src;
	}
}

window.recomendarNota = function(src) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		PopUp(src);
	}
	else {
		window.location = src;
	}
}

String.prototype.pad = function (c, l) {
   var s = String(this);
   c = String(c);
   l = parseInt(l, 10);
   while (s.length < l) {
       s = c + s;
   }
   return s;
}

function Combo_clear(form, id) {
	if (form != '') {
		var o = document.forms[form][id];
	}
	else {
		var o = $(id);
	}
	if (o) o.options.length = 0;
}

function Combo_add(form, id, text, value, selected) {
	if (form != '') {
		var o = document.forms[form][id];
	}
	else {
		var o = $(id);
	}

	var opt = null;
	if (o) {
		o.options[o.options.length] = new Option(text, value);
		opt = o.options[o.options.length-1];
		opt.selected = selected;
	}
	return opt;
}

function Combo_clearAndFill(form, id, options, keyText, keyValue, valueSelected) {
	Combo_clear(form, id);
	Combo_fill(form, id, options, keyText, keyValue, valueSelected);
}

function Combo_fill(form, id, options, keyText, keyValue, valueSelected) {
	for (var i=0; i<options.length; i++) {
		Combo_add(form, id, options[i][keyText], options[i][keyValue], valueSelected==options[i][keyValue]);
	}
}

window.SwitchLogin = function() {
	var CMSLoginBox = document.getElementById("CMSLoginBox"),
		CMSLoginBoxUser = document.getElementById("CMSLoginBoxUser"),
		CMSLogoutBox = document.getElementById("CMSLogoutBox");
	if (CMSLoginBox && CMSLoginBoxUser && CMSLogoutBox) {
		var loginCookie = getCookie("CMSFrontendLogin");
		if (loginCookie != null && loginCookie != "") {
			var CMSFrontendLogin = loginCookie.split(/\|/);
			CMSLoginBoxUser.innerHTML = CMSFrontendLogin[0];
			CMSLoginBox.style.display = "none";
			CMSLogoutBox.style.display = "";
		}
		else {
			CMSLoginBoxUser.innerHTML = "";
			CMSLoginBox.style.display = "";
			CMSLogoutBox.style.display = "none";
		}
	}
}

getCookieData = function(intKey) {
	var loginCookie = getCookie("CMSFrontendLogin");
	if (loginCookie != null && loginCookie != "") {
		var CMSFrontendLogin = loginCookie.split(/\|/);
		return CMSFrontendLogin[intKey];
	}
	return "";
}


window.LogOut = function() {
	document.cookie = "CMSFrontendLogin=; expire=Tue, 01 May 1970 02:49:50 GMT";
	window.SwitchLogin();
	_post("../_post/logout.php");
}

function toogleMarquee(sourceImgPlay, sourceImgPause) {
	if ($('bt_marquee').src.indexOf('play') == -1) {
		$('bt_marquee').src = sourceImgPlay;
		$('marquee').stop();
	}else{
		$('bt_marquee').src = sourceImgPause;
		$('marquee').start();
	}
}

function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue) {
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all: oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\s)" + strAttributeValue + "(\s|$)"): null;
	var oCurrent;
	var oAttribute;

	for (var i=0; i<arrElements.length; i++) {
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if (typeof oAttribute == "string" && oAttribute.length > 0) {
			if (typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))) {
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

function openEdicionElectronica() {
  var width = screen.width;
  var height= screen.height;
  window.open('../edicion_impresa/index.php', 'EdicionImpresa', 'top=0, left=0, width='+width+', height='+height+', toolbar=no, menubar=no, scrollbars=no');
}

tamanio0=11;
tamanio1=12;

function tamFuente (operacion) {

    if (operacion == 0) {
      if (tamanio0 > 8) tamanio0=tamanio0 - 1;
      if (tamanio1 > 8) tamanio1=tamanio1 - 1;

    }
    else {
      if (tamanio0 < 20) tamanio0=tamanio0 + 1;
      if (tamanio1 < 20) tamanio1=tamanio1 + 1;
    }

  document.getElementById('cuerpo').style.fontSize = tamanio0;
  document.getElementById('copete').style.fontSize = tamanio1;
}


function addNota(stitle, slink, flag) {
	var strTypeAux = getCookie('favorito');
	if (strTypeAux) {
  	var arrNota = strTypeAux.split('@@');
  	var cantidad = arrNota.length;
  	var agregar = true;

  	for (var i=0; agregar && i < cantidad; i++) {
    	arrItem = arrNota[i].split('##');
    	if (arrItem.length == 2 && slink == unescape(unescape(arrItem[0]))) {
        agregar = false;
      }
    }

  	if (agregar) {
  	  var strType = escape(escape(slink)) + '##' + stitle + '@@' + strTypeAux;
      setCookie('favorito', strType, new Date(2010, 1, 1));
  	}

  }else{
    var strType = escape(escape(slink)) + '##' + stitle + '@@' + strTypeAux;
	  setCookie('favorito', strType, new Date(2010, 1, 1));
  }

	if (!flag)
		loadFavorito();
}

function CambiarVisibility(obj) {
  loadFavorito();
  var obj = document.getElementById(obj);
  if (obj.style.visibility == "hidden") {
    obj.style.visibility = "visible";
  }
  else {
    obj.style.visibility = "hidden";
  }
}

function setCookie(nombre, valor, caducidad) {
	document.cookie = nombre + "=" + escape(valor) + ((caducidad == null)? "": ("; expires=" + caducidad.toGMTString())+"; path=/; ")
}

function getCookie(nombre) {
	var buscamos = nombre + "=";
	try{
		if (document.cookie.length > 0) {
			var i = document.cookie.indexOf(buscamos);
			if (i != -1) {
				i += buscamos.length;
				var j = document.cookie.indexOf("; ", i);
				if (j == -1) {
				  j = document.cookie.length;
				}
  	  return unescape(document.cookie.substring(i, j));
  	  }
  	}
	}catch(e) {};
}

function loadFavorito() {
	var cHTMLClip = "";
	var strTypeAux = getCookie('favorito');
	var cantidad = 1;
	var can = 0;

	if (strTypeAux) {
		var arrNota = strTypeAux.split('@@');
		var cantidad = arrNota.length;
		cHTMLClip = '<table width=100% cellspacing=0 cellpadding=0 border=0>';
		for (var i=0; i < cantidad; i++) {
			arrItem = arrNota[i].split('##');

			if (typeof(arrItem[1]) != 'undefined') {
				cHTMLClip += "<div id=div"+i+"><tr bgcolor=#FFFFFF>";
				cHTMLClip += "	<td valign=top><input value2='"+arrItem[0]+"' id=chkNota[] name=chkNota[] value='"+ arrItem[1]+"' type=checkbox></td>";
				cHTMLClip += "	<td width=2></td>";
				cHTMLClip += "	<td><a class='arial s10 c048382' href="+ unescape(unescape(arrItem[0])) +">"+ arrItem[1] +"</a></td>";
				cHTMLClip += "</tr>";
				cHTMLClip += "<tr bgcolor=#FFFFFF>";
				cHTMLClip += "	<td colspan=3 height=10><td>";
				cHTMLClip += "</tr></div>";
				can++;
			}
    }
		cHTMLClip += "<tr><td colspan=3 style=padding:3px; bgcolor=#EBEBEB align=right><a class=arial s11 c4F5E66 b href=javascript:deleteFavorito()>Borrar</a></td></tr>";
    cHTMLClip += '</table>';
	}
  if (document.getElementById('DNotas')) {
    document.getElementById('DNotas').innerHTML = cHTMLClip;
  }
  if ($('countMisNotas')) $('countMisNotas').innerHTML = can;
}

function deleteFavorito() {
	var strTypeAux = setCookie('favorito', '', new Date(1970, 1, 1));

	var arrChk = document.getElementsByName('chkNota[]');
	var cantDelete = arrChk.length;
	var arrDel = new Array();

	for (var i=0; i < cantDelete; i++) {
		if (!arrChk[i].checked) {
			addNota(arrChk[i].value, arrChk[i].getAttribute('value2'), true);
		}
	}
	loadFavorito();
}

function PDF(strUrl) {
	var url = '../html2pdf/demo/html2ps.php?';
			url += 'process_mode=single';
			url += '&URL='+escape(strUrl);
			url += '&pixels=800';
			url += '&scalepoints=1';
			url += '&renderimages=1';
			url += '&renderlinks=1';
			url += '&renderfields=1';
			url += '&media=A4';
			url += '&cssmedia=screen';
			url += '&lm=2';
			url += '&rm=2';
			url += '&tm=2';
			url += '&bm=2';
			url += '&smartpagebreak=1';
			url += '&method=fpdf';
			url += '&pdfversion=1.3';
			url += '&output=0';
	window.open(url);
}

function HideMenu(id, n) {
	var displayMenu = document.getElementById(id);
	if (displayMenu) {
		displayMenu.style.display		='none';
		displayMenu.style.position	='absolute';
	}
}

function ShowMenu(id, n) {
	var displayMenu = document.getElementById(id);
	if (displayMenu) {
		displayMenu.style.display		='block';
		displayMenu.style.position	='absolute';

	}
}

function styleMenu(idelement, bgcolor, classFont) {

	var bg = document.getElementById('mnu_'+idelement);
	var ln = document.getElementById('lnk_'+idelement);
	bg.style.backgroundColor = bgcolor;
	ln.className = classFont;
}

function resizePopup() {
  var width = document.getElementById('tablaPopup').offsetWidth;
  var height = document.getElementById('tablaPopup').offsetHeight;
  if (window.frameElement) {
  	//window.document.body.scroll = "yes";
  	window.frameElement.style.width = width;
  	window.frameElement.style.height = height;
  	window.frameElement.style.top = ((parent.document.body.scrollTop+(screen.height/2))-(height/2))-80;
  	window.frameElement.style.left = (parent.document.body.firstChild.offsetWidth/2)-(width/3);
  }
}

function esCUITValido(cuit) {
    var tablaMul = new Array(5, 4, 3, 2, 7, 6, 5, 4, 3, 2);
    var sumatoria = 0;
    var diferencia = 0;
    var digito = 0;

    var resultado = /^\d{2}\-\d{8}\-\d$/.test(cuit);

    if (resultado) {
        cuit = cuit.replace(/\-/g, '');

        for (var i=0; i<10; i++) {
            sumatoria += Number(cuit.charAt(i)) * tablaMul[i];
        }

        diferencia = sumatoria - Math.floor(sumatoria / 11) * 11;
        digito = diferencia > 0? 11 - diferencia: diferencia;
        resultado = digito==cuit.charAt(10);
    }
    return resultado;
}