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();
	for (var i = 0; i < arguments.length; i++)
	{
		var element = arguments[i];
	  if (typeof element == 'string') element = document.getElementById(element);
	  if (arguments.length == 1) return element;
	  elements.push(element);
	}
	return elements;
}

/* Debug */
function isMSIE()
{
	return (navigator.appName == "Microsoft Internet Explorer");
}

function isSafari()
{
	var agt=navigator.userAgent.toLowerCase();
	return ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1)) ? true : false;
}

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 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;
	window.open(url, name, settings);
}
/* Fin Debug */

function _attachEvent( element, name, observer)
{
	if( element.addEventListener )
	{
		name = name.replace("on","");
		element.addEventListener( name, 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, idIe, idMz, menu, FlashVars, quality, allowScriptAccess, writeScript, wmode) {
	var version_data = (version? version: "6,0,0,0");
	var menu_data    = (menu?    menu:    false);
	var bgcolor_data = (bgcolor? bgcolor: "#FFFFFF");
	var idIe_data    = (idIe?    idIe:    "flashMovIe");
	var idMz_data    = (idMz?    idMz:    "flashMovMz");
	var quality_data = (quality? quality: "high");
	var allowScriptAccess_data = (allowScriptAccess? allowScriptAccess: "always");
	var agt                    = navigator.userAgent.toLowerCase();
	var is_safari              = ((agt.indexOf('safari')!=-1))?true:false;

	if (typeof(writeScript) == "undefined" || writeScript == "") {
		writeScript = "1";
	}
	if (typeof(wmode) == "undefined") {
		wmode = "transparent";
	}

	quality_data = "high"; // Calidad de visualización del Flash

	var html = "";
	html += '<object id="'+idIe_data+'" width="'+ancho+'" height="'+alto+'" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+version_data+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">\n';
	html += '<param name="movie" value="'+archivo+'">\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="'+wmode+'">\n';
	html += '<param name="allowScriptAccess" value="'+allowScriptAccess_data+'">\n';
	html += '<param name="allowFullScreen" value="true">\n';
	html += '<embed src="'+archivo+'" id="'+idMz_data+'" width="'+ancho+'" height="'+alto+'" quality="'+quality_data+'" wmode="'+wmode+'" bgcolor="'+bgcolor_data+'" FlashVars="'+FlashVars+'" menu="'+menu_data+'" allowScriptAccess="'+allowScriptAccess_data+'" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" swLiveConnect="true"></embed>';
	html += '</object>\n';

	if (typeof(document.readyState) == "undefined" || document.readyState == "interactive" || is_safari || document.readyState == "loading") {
		if (writeScript == "1") {
			document.write(html);
		}
		else {
			return html;
		}
	}
}

function IrAPagina(pagina)
{
	var url  = "../interior/index.php?pagina="+pagina;
	for( var i in request ){
		//alert(typeof(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, idCMSIdioma)
{
	if( text.length < 1 )
	{
			switch(idCMSIdioma)
			{
				case 1:
					alert("Por favor, ingrese un texto para buscar.");
					break;
				case 2:
					alert("Please, enter at least one word to search.");
					break;
				case 8:
					alert("検索するにはキーワードを入力して下さい。.");
					break;
				default:
					alert("Por favor, ingrese un texto para buscar.");
					break;
			}
	}
	else
	{
		var page = page || "resultado";
		window.location = '../interior/index.php?p='+page+'&text='+text;
	}
}

var objBlock = null;
function block() {
	if (objBlock == null) {
		objBlock = document.createElement("iframe");
		objBlock.src            = "../interior/block.html";
		objBlock.style.position = "absolute";
		objBlock.style.top      = "0px";
		objBlock.style.left     = "0px";
		objBlock.style.width    = screen.width+"px";
//		objBlock.style.height   = document.body.offsetHeight+document.body.scrollHeight;
		objBlock.style.height   = "5000px";
		if (isMSIE()) {
			objBlock.style.filter = "alpha(opacity=50)";
			objBlock.style.opacity = 0.5;
		}
		else {
			objBlock.style.MozOpacity = 0.5;
			objBlock.style.opacity = 0.5;
		}
//		document.body.scroll         = "no";
		document.body.style.overflow = "hidden";
		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  	= "200";
			_objPost.src 						= url;
	document.body.appendChild(_objPost);
}

window._postAjax = function(url)
{
	var ajax;
	try{
   ajax = new ActiveXObject("Msxml2.XMLHTTP");
  }catch(e){
    try {
      ajax = new ActiveXObject("Microsoft.XMLHTTP");
    }catch(E){
    }
  }
  if (!ajax && typeof XMLHttpRequest!='undefined') {
   ajax = new XMLHttpRequest();
  }

  if(ajax){
    ajax.open("GET", url , true);
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(null);
  }
}

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, idCMSIdioma)
{
	var comentario 			= $("comentario_"+idContenido);
	//var randomUsuario 	= $("randomUsuario_"+idContenido);
	//var randomSistema 	= $("random_"+idContenido);

	autorTxt 						= getCookieData(0) ;
	comentarioTxt 			= comentario.value;
	//randomUsuarioTxt	= randomUsuario.value;
	bool = true;


	if(bool && !autorTxt.trim())
	{
		if(idCMSIdioma){
			switch(idCMSIdioma)
			{
				case 1:
					alert("Para agregar un comentario necesita estar logueado");
					break;
				case 2:
					alert("To add a comment, please login");
					break;
				case 8:
					alert("コメントするにはログインが必要です。");
					break;
			}
		} else{
			alert("Para agregar un comentario necesita estar logueado");

		}
		bool = false;
	}

	if(bool && !comentarioTxt.trim())
	{
		if(idCMSIdioma){
			switch(idCMSIdioma)
			{
				case 1:
					alert("Por Favor, ingrese su comentario");
					break;
				case 2:
					alert("Please, insert your comment");
					break;
				case 8:
					alert("コメントする。");
					break;
			}
		}
		else{
			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, idCMSIdioma)
{
	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);
	 				switch(idCMSIdioma)
					{
						case 1:
							alert("Gracias por participar.");
							break;
						case 2:
							alert("Thanks for your participation");
							break;
						case 8:
							alert("ご参加ありがとうございます。.");
							break;
						default:
							alert("Gracias por participar.");
							break;
					}
	 			}
	 			else {
	 				switch(idCMSIdioma)
					{
						case 1:
							alert("Usted ya voto esta encuesta");
							break;
						case 2:
							alert("You just voted in this poll");
							break;
						case 8:
							alert("あなたはこのアンケートに投票されました。");
							break;
						default:
							alert("Usted ya voto esta encuesta");
							break;
					}
	 			}
				break;
			}
		}
	}
	if(!opcion){
		switch(idCMSIdioma)
			{
				case 1:
					alert("Debe seleccionar una opcion para votar");
					break;
				case 2:
					alert("You must select an option to vote");
					break;
				case 8:
					alert("投票するにはオプションを選択して下さい。");
					break;
				default:
					alert("Debe seleccionar una opcion para votar");
					break;
			}
	}
}

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, iframe_name) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		if (typeof(iframe_name) == "undefined") {
			iframe_name = (Math.random()*10000).toString();
		}
		window.scrollH = Number(document.documentElement.scrollTop || document.body.scrollTop);
		document.body.scroll = "no";
		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.setAttribute("allowtransparency", "true");
		objPopup.name = iframe_name;
		objPopup.src = src;
		objPopup.style.position = "absolute";
		objPopup.height = "800px";
		objPopup.style.top = "200px";
		objPopup.style.left = "600px";
		document.body.appendChild(objPopup);
	}
	else {
		window.location = src;
	}
}

window.PopUpLogin = function(src, iframe_name) {
	if (typeof(window.parent.objAdministratorBar) == "undefined") {
		if (typeof(iframe_name) == "undefined") {
			iframe_name = (Math.random() * 10000).toString();
		}

		document.body.scroll = "no";
		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";
		var width = 400;
		var height = 400;
		objPopup.style.width  = width;
		objPopup.style.height = height;
		objPopup.style.top  = (screen.height - height) / 2;
		objPopup.style.left = (screen.width - width) / 2;
		document.body.appendChild(objPopup);
	}
	else {
		window.location = src;
	}
}


window.PopUpEnviarAdjunto = 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';
		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';
		var width		= '300';
		var height	= '400';
		objPopup.style.top 	= (screen.height - height) / 2;
		objPopup.style.left = (screen.width - width) / 2;
		objPopup.style.width	= width;
		objPopup.style.height	= height;

		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")
	{
		document.body.scroll = '';
		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);
}

/**/
var actual_font_size = 16;
function aumentar_tipografia(id)
{
	if( actual_font_size < 31 )	actual_font_size++;
	$(id).style.fontSize = actual_font_size;
}

function reducir_tipografia(id)
{
	if( actual_font_size > 9 )	actual_font_size--;
	$(id).style.fontSize = actual_font_size;
}

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 CMSFrontendLogin = getCookie("CMSFrontendLogin");
		if (CMSFrontendLogin) {
			var userData = CMSFrontendLogin.split("|");
			CMSLoginBoxUser.innerHTML = userData[0];
			CMSLoginBox.style.display = "none";
			CMSLogoutBox.style.display = "";
		}
		else {
			CMSLoginBoxUser.innerHTML = "";
			CMSLoginBox.style.display = "";
			CMSLogoutBox.style.display = "none";
		}
	}
}

getCookieData = function(intKey) {
	var CMSFrontendLogin = getCookie("CMSFrontendLogin");
	if (CMSFrontendLogin) {
		var userData = CMSFrontendLogin.split("|");
		return userData[intKey];
	}
	return "";
}

window.LogOut = function() {
	document.cookie = "CMSFrontendLogin=;expire=Tue, 01 May 1970 02:49:50 GMT";
	window.SwitchLogin();
	window._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 setTamFuente(nodo,tamanio)
{
	// nodo actual
	if(nodo && nodo.style)
	nodo.style.fontSize = tamanio;

	// tiene hijos?
	if(nodo.childNodes.length)
	{
		nodo = nodo.firstChild;

		// primer hijo
		if(nodo.style) nodo.style.fontSize = tamanio;
		setTamFuente(nodo,tamanio);

		// resto de los hijos
		while(nodo = nodo.nextSibling)
		{
			if(nodo.style) nodo.style.fontSize = tamanio;
			setTamFuente(nodo,tamanio);
		}
	}
}

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;
  }
	setTamFuente(document.getElementById('copete'),tamanio1);
	setTamFuente(document.getElementById('cuerpo'),tamanio0);
}


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 resizePopup() {
	if (window.frameElement) {
		var tablaPopup = document.getElementById("tablaPopup"),
			width  = tablaPopup.offsetWidth,
			height = tablaPopup.offsetHeight,
			wfs = window.frameElement.style,
/*
			scrollY = parent.scrollH || top.document.documentElement.scrollTop;
			wfs.width = width;
			wfs.height = height;
			wfs.top = scrollY + ((screen.height - height) / 2) - 80;
			wfs.left = (parent.document.body.firstChild.offsetWidth / 2) - (width / 3);
*/
			winSize = windowSize(parent),
			scrollY = scrollOffset(parent).getY();

		wfs.width = width+"px";
		wfs.height = height+"px";
		wfs.top = parseInt(scrollY + (winSize.getY() - height) / 2)+"px";
		wfs.left = parseInt((winSize.getX() - width) / 2)+"px";
	}
}

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;
}

function contarContenido(idCMSPortal, idCMSModulo, idContenido, visitas, votos) {
	_postAjax("../_post/count.php?idCMSPortal="+idCMSPortal+"&idCMSModulo="+idCMSModulo+"&idContenido="+idContenido+"&visitas="+visitas+"&votos="+votos);
}

function contarVisitaAdjunto(idCMSPortal, idContenido){
	contarContenido(idCMSPortal, 11, idContenido, 1, 0);
}

function doSomething(e) {
	if (!e) var e = window.event;
	e.cancelBubble = true;
	if (e.stopPropagation) e.stopPropagation();
}

function mostrarLinkPost(idPost) {
	var obj = $("link_post_"+idPost);
	if (obj) {
		obj.style.display = (obj.style.display == "none")? "block": "none";
	}
}

function clearInputValue(input) {
	if (input.value == input.defaultValue) {
		input.value = "";
	}
}

function restoreInputValue(input) {
	if (input.value == "") {
		input.value = input.defaultValue;
	}
}

function setInputDefaultValue(input, defVal) {
	var tmp = input.value;
	input.defaultValue = defVal;
	input.value = tmp;
}

function clearOnSocialLogin(){
  window.onSocialLogin = null;
}

function closeExternalLogin(win){
  if( typeof(window.onSocialLogin) == "function" ){
    window.onSocialLogin.call();
    clearOnSocialLogin();
  }else{
    window.location.reload();
  }
  win.close();
}
