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 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/suscribir_newsletter.php?email="+ email_val+"&dest="+dest);
		return;
	}
	// Validación falló
	frm.email.focus();
	window.alert(msg);
}

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 EnviarComentario(idContenido)
{
  var frm          	= document.getElementById("formComentarios");
  var comentario 		= document.getElementById("comentario_"+idContenido);
  var autor					= document.getElementById("autor_"+idContenido);
	var parms					= '1&';
	
	for(i = 0 ; i < frm.length ; i++ )
	{
	  parms += frm.elements[i].name+"="+frm.elements[i].value+"&";
	}
	
	
	autorTxt 					= autor.value;
	comentarioTxt 		= comentario.value;

	bool = true;

	if(bool && autorTxt == 0)
	{
		popup_login(parms);
		bool = false;
	}

	if(bool && !comentarioTxt.trim())
	{
		alert("Por Favor, ingrese su comentario");
		comentario.focus();
		bool = false;
	}
	

	if(bool)
	{
  	var query_string = "../_post/infobrand/insertar_comentario.php?"+parms;
  	_post(query_string);
  	frm.reset();
  	window.location = '#comments';
	}  

}


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.setAttribute("frameborder"	,	"0");
		objBlock.setAttribute("scrolling"		,	"no");
		
		if(isMSIE()){
			objBlock.style.filter = 'alpha(opacity=50)';
			objBlock.style.width			= document.body.offsetWidth;
			objBlock.style.height   	= document.body.offsetHeight+document.body.scrollHeight;
		}else{
			objBlock.style.MozOpacity = 0.5;
			objBlock.style.width			= document.body.offsetWidth+'px';
			objBlock.style.height   	= parseInt(document.body.offsetHeight+document.body.scrollHeight)+'px';
		}
		
		//document.body.style.overflow = 'hidden';
		document.body.scroll = 'no';
		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.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';
		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;
	}
}



window.PopUp = 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';
		
		
		if(isMSIE()){
			objPopup.style.top 	= 100;
			objPopup.style.left = 100;
		}else{
			objPopup.style.top 	= '100px';
			objPopup.style.left = '100px';
		}
		
		document.body.appendChild(objPopup);
	}
	else
	{
		window.location = src;
	}
}

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';
			
		}
	}
}


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 checkCaracteres( inputElement, cantidad ) {
if( inputElement.value.length > cantidad ) {
inputElement.value = inputElement.value.substr(0, cantidad);
}
document.getElementById("checkCaracteres_counter").innerHTML = inputElement.value.length;
}







































function trim(str) {
	var re = /^(\s)*|(\s)*$/;
	var str = (str ? str : 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 dump(o,func) {
	var str = "";
	for(p in o) {
		if(typeof o[p]!='function' || func){
			str += "\t" + p + " => " + o[p] + "\n";
		}
	}
	str = "(" + typeof(o) + ") " + o + " \n{\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;
	return 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 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" ;
  }
  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';
}




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.style.left     	= '150px';
    objPopup.setAttribute("frameborder"	,	"0");
		objPopup.setAttribute("scrolling"		,	"no");
		objPopup.src = src;
		objPopup.style.zIndex   	= "999";
		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);
}

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) {
  var autor						= $("autor_"+idContenido);
	var comentario 			= $("comentario_"+idContenido);
	var randomUsuario 	= $("randomUsuario_"+idContenido);
	var randomSistema 	= $("random_"+idContenido);
	autorTxt 					= autor.value;
	comentarioTxt 		= comentario.value;
	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;
		window._post(src);
	}

}

function votar_encuesta(idForm, idEncuesta) {
	var form = document.forms[idForm],
		opcion = false, i;
	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),
		div_resultadoEncuesta = document.getElementById("resultadoEncuesta_"+ idEncuesta),
		cookieVal = getCookie("CMSVotosEncustas["+idEncuesta+"]");
	if (cookieVal != idEncuesta) {
 		div_resultadoEncuesta.style.display	= "none";
 		div_encuesta.style.display = "";
	}
	else {
		div_encuesta.style.display = "none";
		div_resultadoEncuesta.style.display	= "";
	}
}

/** [EA 28/04/2007 15:28]
	* Crea un iframe, y lo hubica en el centro de la pagina
	*/
window.PopUpOLD = 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'>" : "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.top	= '100';
		objPopup.style.left	= '100';
		document.body.appendChild(objPopup);
	}
	else {
		window.location = src;
	}
}
/*
window.PopUp = 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'>" : "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.top	= '100px';
		objPopup.style.left	= '100px';
		objPopup.style.zIndex	= '999';
		document.body.appendChild(objPopup);
	}
	else {
		window.location = src;
	}
}
*/

/* del cronista */
window.PopUp = function(src, iframe_name) {
	if(typeof(window.parent.objAdministratorBar) == "undefined") {
		document.body.scroll = "no";
		block();
		if (typeof(iframe_name) == "undefined")
			iframe_name = (Math.random() * 10000).toString();
		var strFrame = isMSIE()? '<iframe name="'+iframe_name+'" frameborder="0">': "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.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") {
		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 = 12;

function aumentar_tipografia(id){

	if( actual_font_size < 31 )	actual_font_size++;
	setTamFuente($(id),actual_font_size+'px');
}

function reducir_tipografia(id){
	if( actual_font_size > 9 )	actual_font_size--;
	setTamFuente($(id),actual_font_size+'px');
}

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);
		}
	}
}


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;
	}
}

window.verAviso = 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 		= $('CMSLoginBox');
	var CMSLogoutBox 		= $('CMSLogoutBox');

	if( CMSLoginBox && CMSLogoutBox) {
		if( getCookie('CMSFrontendLogin')!=null && getCookie('CMSFrontendLogin')!='' ) {

			CMSLoginBox.style.display 	= 'none';
			CMSLogoutBox.style.display 	= 'block';

		}
		else {
			
			CMSLoginBox.style.display 	= 'block';
			CMSLogoutBox.style.display 	= 'none';

		}
		CMSLoginBox 			= null;
		CMSLogoutBox 			= null;
	}
}

window.SwitchLoginOLD = function() {

	var CMSLoginBox 		= $('CMSLoginBox');
	var CMSLoginBoxUser	= $('CMSLoginBoxUser');
	var CMSLogoutBox 		= $('CMSLogoutBox');

	if( getCookie('CMSFrontendLogin')!=null && getCookie('CMSFrontendLogin')!='' ) {
		var CMSFrontendLogin 				= getCookie('CMSFrontendLogin').split(/\|/);
		CMSLoginBoxUser.innerHTML 	= CMSFrontendLogin[0] ;
		CMSLoginBox.style.display 	= 'none';
		CMSLogoutBox.style.display 	= 'block';
	}
	else {
		CMSLoginBoxUser.innerHTML = "";
		CMSLoginBox.style.display = 'block';
		CMSLogoutBox.style.display = 'none';
	}
	CMSFrontendLogin 	= null
	CMSLoginBox 			= null;
	CMSLogoutBox 			= null;
}

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 strTypeAux = getCookie('favorito'),
		cHTMLClip = '',
		can = 0, lmnt;
	if (strTypeAux) {
		var arrNota = strTypeAux.split('@@'),
			cantidad = arrNota.length, i;
		cHTMLClip = '<table cellpadding="0" cellspacing="0" width="100%" border="0">';
		for (i = 0; i < cantidad; ++i){
			arrItem = arrNota[i].split('##');
			if (typeof(arrItem[1]) != 'undefined') {
				cHTMLClip += '  <div id="div'+ i +'">';
				cHTMLClip += '    <tr>';
				cHTMLClip += '	    <td valign="top"><input type="checkbox" id="chkNota[]" name="chkNota[]" value="'+ arrItem[1] +'" value="'+ arrItem[0] +'"></td>';
				cHTMLClip += '	    <td width="2"></td>';
				cHTMLClip += '	    <td><a href="'+ unescape(unescape(arrItem[0])) +'" class="ffa s12 c666666">'+ arrItem[1] +'</a></td>';
				cHTMLClip += '    </tr>';
				cHTMLClip += '    <tr>';
				cHTMLClip += '	    <td colspan="3" height="10"><td>';
				cHTMLClip += '    </tr>';
				cHTMLClip += '  </div>';
				++can;
			}
    	}
    	cHTMLClip += '</table>';
	}
	lmnt = document.getElementById('DNotas');
	if (lmnt)
		lmnt.innerHTML = cHTMLClip;
	lmnt = document.getElementById('countMisNotas');
	if (lmnt)
		lmnt.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=1280';
			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';
			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(id) {
  var width  = document.getElementById(id).offsetWidth;
  var height = document.getElementById(id).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;
}

//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion() {
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version) {
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful.

			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version) {
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version) {
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version) {
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}

	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;

	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) {
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext) {
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) {
  var str = '';
  if (isIE && isWin && !isOpera) {
    str += '<object ';
    for (var i in objAttrs) {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params) {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else {
    str += '<embed ';
    for (var i in embedAttrs) {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

function changeDisplay(lmnt, show) {
	if (typeof lmnt == "string")
		lmnt = document.getElementById(lmnt);
	if (lmnt && lmnt.style)
		lmnt.style.display = show? "": "none";
}
