/* FONDOTOP©2007 v LAST */
var debug = 1;
var ayudactiva = 0;
var particular4 = "/fondotop?"
var paganterior = "none";
var hash = null;
var alertactiva = 0;
var urlanterior;
var tipoanterior;
var tipoenvio = 0;
function historyChange(newLocation, historyData) {
    var historyMsg = historyData;   
    urlanterior = newLocation;
    tipoanterior = historyData;
    $.goto(newLocation,{tipo:historyMsg}); 

}
$(document).ready(function(){
	$.globales('content')
});


$.aperturacuenta = function() {
	$.alertas({titulo:'No disponible',mensaje:'Para acceder a esta sección debe ser cliente de fondotop<br/><br/><a onclick=\'$.alertasremove(); abrir_apertura_cliente(1);\');><b>Hágase cliente ></b></a>'});
}

$.globales = function(cont) {

$.limpieza(cont);

	$('ul.jd_menu').jdMenu();
	$(document).bind('click', function() {
		$('ul.jd_menu ul:visible').jdMenuHide();
	}); 

	 $.ttips();  $.calendario(); $.cambioestilos(); $.ayudavisual();
	 $.botonera(); $.validarforma();
	 
	$('form[@name]').each(function() {
		$.validarenvio($(this).attr('name'));
	})
		
 	 $('a').mouseover(function(){
			$(this).css("cursor","pointer");
	 });

	if ((cont != null) && (cont == 'content')) {
		$.NiceJForms.build();
	}

}
$.volver = function() {
/*	if (tipoenvio == 1) {
		return urlanterior;
	} else {
		history.go(-4);
		return dhtmlHistory.getCurrentLocation();
	} */
	return "back";
}

$.recogerscript = function(script) {
	$.getScript(script);
}
$.limpieza = function(cont) {
		$('.optionsDivVisible').remove();
}

$.cambioestilos = function() {
		$('table.tabla > tbody.cabecera > tr > td').addClass('tabla_tbody');
		$('table.tabla > tbody.contenido > tr > td').addClass('tabla_td');

		$('table.tablaxml > tbody.cabeceraxml > tr > td').addClass('tablaxml_tbody');
		$('table.tablaxml > tbody.contenidoxml > tr > td').addClass('tablaxml_td');

		$(".cajaredondeada").each(function(i){
			var cajaredondeadaant = $(this).html();
			$(this).html('<div id="boxtopleft"><div id="boxtopright"><div id="boxdownleft"><div id="boxdownright"><div  style="width: 100% ; margin: 5px;"><div style=" margin: 20px;">'+cajaredondeadaant+'</div></div></div></div></div></div>');
			$(this).attr('class','cajaredondeadaback');
		});

		$('td').each(function(i){
			if ( $(this).html() == '' ) {
				$(this).html('&nbsp;');
			}
		});

		$('a[@href]').each(function(i){
				if ($(this).attr('href') == "#") {
					$(this).attr('href','javascript:;');
				}
		});

}


$.buscadorespecial = function(id,xml,contenedor,parametros,options) {
        options = options || {};
        options.funcion = options.funcion || "selectItem";
        var param = null;
    if (parametros==null) {
        param = {
            limit:100
        }
    }
    else {
        eval("param = { "+parametros+", limit:100 }");
    }
    parametros=parametros+', limit:100';
    $('#'+contenedor).html("<input type='text' id='"+id+"' name='"+id+"' class='textboxbuscador' autocomplete='off'/>");
    eval("$('#'+id).autocomplete(xml, { minChars:3, matchSubset:1, delay:600, matchContains:1, cacheLength:10, onItemSelect:" + options.funcion + ", selectOnly:0, maxResults:10, extraParams:param });");
}

$.calendario = function() {

	if ( $('.date-picker').size() != 0 ) {
		$.datePicker.setDateFormat('dmy', '/');
		$.datePicker.setLanguageStrings(
			['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'],
			['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
			{p:'Anterior', n:'Siguiente', c:'Cerrar', b:'Seleccionar fecha'}
		);

		$('.date-picker').each(function(i){

			$(this).datePicker({firstDayOfWeek:1});

		});
	
	}
}

$.ayudavisual = function() {

		$("#ayudact").unbind();


	$("#ayudact").toggle(function(){ 
		ayudactiva=1;
		$(this).css({ background: "url(/images/topnl/helpon.gif) no-repeat" });
		$.ttips();
	},
	function(){ 
		ayudactiva=0;
		$(this).css({ background: "url(/images/topnl/helpoff.gif) no-repeat" });
		$.ttips();
	});
}

$.botonera = function() {

		$("#solapa").unbind();

		(function() {
				$("#solapa").toggle(function() {
						$('#buscad').slideUp();
				},
				function() {
						$('#buscad').slideDown();
				});
				
				
				 $('a[@opcion]').hover(function(){
						$('#opcsec').html($(this).attr('opcion'));
						$('#opcsec').show(); $('#botonera').show(); $('#botonera2').show();
				 },
				 function() {
						return false;
				})
				 
				 $('#botonera').hover(function(){
						return false;
				 },
				function() {
						$('#opcsec').hide(); $('#botonera2').hide();  $('#botonera').hide(); 
					});

				 $('#botonera2').hover(function(){
						return false;
				 },
				function() {
						$('#opcsec').hide(); $('#botonera2').hide(); $('#botonera').hide(); 
				});
				
		})();
	
}

$.ttips = function() {
	if (ayudactiva == 1) {
	 	 $('a, li, input, div, span, img').Tooltip({
			 extraClass: "tooltip",
			 delay: 0,
			 showURL: false,
			 showBody: " - ",
			 track: true
		 });

	} else {
	 	 $('a, li, input, div, span').Tooltip({
			 delay: 500000000000
		 });
	}
}

$.initfaq = function(idfaq) {
	if($('#'+idfaq).get(0)) {
		$('#'+idfaq+' > #answer').hide();
		$('#'+idfaq+' > #ask').css("cursor","pointer");
		$('#'+idfaq+' > #ask').css("color",$("#"+idfaq+" > faq").attr("col_a"));
		$('#'+idfaq+' > #ask').css("background",$("#"+idfaq+" > faq").attr("bg_a"));
		$('#'+idfaq+' > #ask').hover(function(){
			$(this).css("color",$("#"+idfaq+" > faq").attr("col_b"));
			$(this).css("background",$("#"+idfaq+" > faq").attr("bg_b"));
		},
		function() {
			$(this).css("color",$("#"+idfaq+" > faq").attr("col_a"));
			$(this).css("background",$("#"+idfaq+" > faq").attr("bg_a"));
		});
		$('#'+idfaq+' > #ask').click(function(){
			eval('$("#'+idfaq+' > #answer:visible").not( $(this).next()[0] ).slideUp('+$("faq").attr("fxhide")+');');
			eval('$(this).next().slideToggle('+ $("#"+idfaq+" > faq").attr("fxtoggle") +');');
		});
		if (($("#"+idfaq+" > faq").attr("def")>="1") && ($("#"+idfaq+" > faq").attr("def") <= $("#'+idfaq+' > #answer").length)) { 
				tempdef=$("#"+idfaq+" > faq").attr("def")-1;
				eval('$($("#faq > #answer", this).get(tempdef)).slideDown('+$("faq").attr("fxdef")+');');
		}
	}
}



$.goto = function(url, options) {
	if (url == "back") { history.go(-1); return false; }
	var hash = url;
	options = options || {};
	if (options.cache == null) { options.cache = false }
	if (options.loading == null) { options.loading = true }
	options.cont = options.cont || "content";
	options.tipo = options.tipo || "goto";
	
	if (options.cont != "content") {

			if (options.tipo == "goto") url=particular4 + url;
			if (options.cont == "goto") {
				if ($.validarhash(hash,options.cache) == true) { return false; }
			}
			setTimeout("$.gotofin('"+url+"','"+options.cont+"')",10); 
			
	} else {
		document.location.href = particular4+url;
	}

	if ($.browser.msie && $.browser.version.substr(0,1)<7) {
		if (window.event) {
			window.event.returnValue=false;
		}
	}
}

$.gotofin = function(url, cont) {
		$("#"+cont).load(url,function() { 
			$("#"+cont).show(); $.globales(cont); $.cargadatosremove();
		}); 
}


$.validarhash = function(hash,cache) {
	var definir = false;
	hash = hash.replace(/^.*FWD=/, '');
	hash = hash.replace(/^.*#/, '');
	if ((hash == paganterior) && (cache == true)) {
		paganterior = hash;
		definir = true;
	} else {
		paganterior = hash; 
		definir = false;
	}
	return definir;
}

$.gotoajax = function(url, options) {
	hash = url;
	options = options || {};
	options.tipo = options.tipo || "goto";
	options.cont = options.cont || "content";
	options.data = options.data || "html";
	options.envio = options.envio || "GET";
	options.processData = options.processData || true;
	$.ajax({
		type: options.envio,
		type: options.envio,
		url: url,
		processData: true,
		dataType: options.data,
	        beforeSend: function() {
						window.status = "";
	        	$.cargadatos();
	        },
		success: function(response) {
			$(document).ready(function() {
				if (options.cont == 'content') {
					scroll(0,0);
				}
				$("#"+options.cont).html(response);
			});
		},
	        error: function(response) {
	             	alertas('<span style="color:#990000">ERROR</span>','No se ha encontrado la página <b>'+ url +'</b>.<br/><br/>Rogamos disculpen las molestias');
	        },
		complete: function(response) {
			$.validarhash(hash);
			$.cargadatosremove();
		}
	})
}


    
$.enviar = function(url,forma,options) {
	
		tipoenvio = 0;
		hash = url;
		options = options || {};
		if (options.loading == null) { options.loading = false }
		options.cont = options.cont || "content";
		options.tipo = options.tipo || "goto";
		options.metodo = options.metodo || "post";
	
	if (options.cont == "content") {
		eval("document."+forma).submit();
	} else {
		if (options.tipo == "goto") url=url+particular4;
		
		/* Método simple
		var options = {
			target: '#'+options.cont
		};

		$('#'+forma).ajaxSubmit(options); 
		*/
				
		var options = {
			target: '#'+options.cont,
			processData: true,
			semantic: true,
			url: url,
			method: options.metodo,
			error: function(response) {
				// $.cargadatosremove();
			},
			beforeSubmit: function(formArray, jqForm) {
				if ($.validarenvio(forma) == false) {
					$.cargadatosremove();
					return false;
				}
				if (options.loading == true) { 
					$.cargadatos(); 
				}

			},
			success: function(responseText) {
				if (options.cont == 'content') {
						scroll(0,0);
				}
				$.globales();  
				// $.cargadatosremove(); 
				// $.validarhash(hash,false);
			}
		};
		
			$('#'+forma).ajaxSubmit(options,function() {
				return false;
			}); 

	}

} 

$.getdatos = function(url, options) {
	$.get(url, function(data){
		alert(data);
	});
}


$.validarenvio = function(forma) {
	var validacionfinal = true;
	var counterror = 0;
	var haygrupos= 0;
	$('#'+forma+'  input').each(function() {		
				if ($(this).attr('grupo')) { haygrupos=1; }
				if ( ($(this).attr('validacion')) || ($(this).attr('requerido')) ) {
					var formbusqueda = "";
					var formtitulo = "";
						if ($(this).attr('validacion') == "alpha") { var formbusqueda =  /^[a-zA-Z ñÑ]+$/;  var formtitulo = '<b>Caracteres Alpha</b><br/>De la <b>a</b> a la <b>z</b> y espacios';}
						if ($(this).attr('validacion') == "numerico") { var formbusqueda = /^[0-9]+$/;  var formtitulo = '<b>Caracteres Numéricos</b><br/>Del <b>0</b> al <b>9</b>, sin espacios';}
						if ($(this).attr('validacion') == "alphanumerico") { var formbusqueda = /^[a-zA-ZñÑ0-9 ]+$/;  var formtitulo = '<b>Caracteres Alphanuméricos</b><br/>De la <b>a</b> a la <b>z</b>, del <b>0</b> al <b>9</b> y espacios';}
						if ($(this).attr('validacion') == "digito") { var formbusqueda = /^[0-9.]+$/;  var formtitulo = '<b>Decimales</b><br/>Del <b>0</b> al <b>9</b> y separador de decimales \'<b>.</b>\', sin espacios';}
						if ($(this).attr('validacion') == "email") { var formbusqueda = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;  var formtitulo = '<b>E-mail</b><br/>p.e.: online@renta4.es';}
						if ($(this).attr('validacion') == "fecha") { var formbusqueda = /^(\d{2})\/(\d{2})\/(\d{4})$/;  var formtitulo = '<b>Fecha</b><br/>p.e.: 03/09/2006'; }
						if ($(this).attr('validacion') == "euros") { var formbusqueda = /^\$?\-?([1-9]{1}[0-9]{0,2}(\.[0-9]{3})*(\,[0-9]{0,2})?|[1-9]{1}\d*(\,[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\,[0-9]{1,2})?)$/;  var formtitulo = '<b>Euros</b><br/>p.e.: 2.658,25'; }
						if ($(this).attr('validacion') == "visa") { var formbusqueda = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;  var formtitulo = '<b>Visa</b><br/>p.e.: 4444 4444 4444 4444'; }
						if ($(this).attr('validacion') == "hora") { var formbusqueda = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;  var formtitulo = '<b>Hora</b><br/>p.e.: 18:45:58'; }
						if ($(this).attr('validacion') == "credito") { var formbusqueda = /^3[0,6,8]\d{12}$/;  var formtitulo = '<b>Tarjeta de crédito</b><br/>p.e.: 4567456745674567'; }
						if ($(this).attr('validacion') == "ernst") { var formbusqueda = /^[^\@|\;|\&|\||\:|\'|\"|\<|\>|\¡|\!|\$|\(|\)|\{|\}|\[|\]]*$/;  var formtitulo = 'Algunos caracteres especiales no son permitidos como @, !, $, etc.'; }

						if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
							if ($(this).val() == "") {
								formtitulo = formtitulo + "<br/><br/><span style='color:#aa0000'>Campo requerido</span>";
							}
						}					
	
						$(this).attr('title',formtitulo); $.ttips();
	
	
						var formbusquedalta = $(this).val().replace(formbusqueda, '');
						if (formbusquedalta != "") {
							$(this).css('border','1px solid #c76663');
							counterror++;
						} else {
							if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
								$(this).css('border','1px solid #c76663');
								counterror++;
							} else {
								$(this).css('border','1px solid #63abc7')
							}
						}
				}
	});
if (haygrupos == 1) {
	counterrorgrupo = 2;
	$('#'+forma+'  input[@grupo]').each(function(i) {		
		if ( ($(this).val() != null) && ($(this).val() != "") ) {  counterrorgrupo=0; }
		$(this).attr('title',"Es necesario indicar como mínimo un campo del grupo"); $.ttips();
	});
	if (counterrorgrupo==2) { counterror = 2; $('#'+forma+'  input[@grupo]').css('border','1px solid #c76663'); } else { $('#'+forma+'  input[@grupo]').css('border','1px solid #63abc7'); }
}
	
	if (counterror == 0) { return true; } else { return false; }
}

$.validarforma = function() {

	 if ( $('form').size() != 0 ) {
		$('input').attr('name',function() {
			if ($(this).attr('validacion')) {
					if ($(this).attr('validacion') == "alpha") { var formbusqueda =  /^[a-zA-Z ñÑ]+$/;  var formtitulo = '<b>Caracteres Alpha</b><br/>De la <b>a</b> a la <b>z</b> y espacios';}
					if ($(this).attr('validacion') == "numerico") { var formbusqueda = /^[0-9]+$/;  var formtitulo = '<b>Caracteres Numéricos</b><br/>Del <b>0</b> al <b>9</b>, sin espacios';}
					if ($(this).attr('validacion') == "alphanumerico") { var formbusqueda = /^[a-zA-ZñÑ0-9 ]+$/;  var formtitulo = '<b>Caracteres Alphanuméricos</b><br/>De la <b>a</b> a la <b>z</b>, del <b>0</b> al <b>9</b> y espacios';}
					if ($(this).attr('validacion') == "digito") { var formbusqueda = /^[0-9.]+$/;  var formtitulo = '<b>Decimales</b><br/>Del <b>0</b> al <b>9</b> y separador de decimales \'<b>.</b>\', sin espacios';}
					if ($(this).attr('validacion') == "email") { var formbusqueda = /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;  var formtitulo = '<b>E-mail</b><br/>p.e.: online@renta4.es';}
					if ($(this).attr('validacion') == "fecha") { var formbusqueda = /^(\d{2})\/(\d{2})\/(\d{4})$/;  var formtitulo = '<b>Fecha</b><br/>p.e.: 03/09/2006'; }
					if ($(this).attr('validacion') == "euros") { var formbusqueda = /^\$?\-?([1-9]{1}[0-9]{0,2}(\.[0-9]{3})*(\,[0-9]{0,2})?|[1-9]{1}\d*(\,[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\,[0-9]{1,2})?)$/;  var formtitulo = '<b>Euros</b><br/>p.e.: 2.658,25'; }
					if ($(this).attr('validacion') == "visa") { var formbusqueda = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;  var formtitulo = '<b>Visa</b><br/>p.e.: 4444 4444 4444 4444'; }
					if ($(this).attr('validacion') == "hora") { var formbusqueda = /^\d{1,2}[:]\d{2}([:]\d{2})?( [aApP][mM]?)?$/;  var formtitulo = '<b>Hora</b><br/>p.e.: 18:45:58'; }
					if ($(this).attr('validacion') == "credito") { var formbusqueda = /^3[0,6,8]\d{12}$/;  var formtitulo = '<b>Tarjeta de crédito</b><br/>p.e.: 4567456745674567'; }
					if ($(this).attr('validacion') == "ernst") { var formbusqueda = /^[^\@|\;|\&|\||\:|\'|\"|\<|\>|\¡|\!|\$|\(|\)|\{|\}|\[|\]]*$/;  var formtitulo = 'Algunos caracteres especiales no son permitidos como @, !, $, etc.'; }
				
					if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
						if ($(this).val() == "") {
							formtitulo = formtitulo + "<br/><br/><span style='color:#aa0000'>Campo requerido</span>";
						}
					}


					$(this).attr('title',formtitulo); $.ttips();

				$(this).click(function(){

					var formbusquedalta = $(this).val().replace(formbusqueda, '');

					if (formbusquedalta != "") {
						$(this).css('border','1px solid #c76663');
					} else {
						if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
							$(this).css('border','1px solid #c76663');
						} else {
							$(this).css('border','1px solid #00a8e6')
						}
					}


					
				});
				$(this).keyup(function(){

					var formbusquedalta = $(this).val().replace(formbusqueda, '');

					if (formbusquedalta != "") {
						$(this).css('border','1px solid #c76663');
					} else {
						if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
							$(this).css('border','1px solid #c76663');
						} else {
							$(this).css('border','1px solid #00a8e6')
						}
					}


					
				});
			} else {
					if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
						if ($(this).val() == "") {
							formtitulo = "<span style='color:#ff3300'>Campo requerido</span>";
						}
					$(this).attr('title',formtitulo); $.ttips();


					$(this).keyup(function(){
						if (($(this).attr('requerido') == "1") && ($(this).val() == "")) {
							$(this).css('border','1px solid #c76663');
						} else {
							$(this).css('border','1px solid #00a8e6')
						}
					});
					}			
					
			}
		});
	}
}


$.imprimir = function() {
	 top.impr=window.open('','imprimir', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=0,width=785,height=580')
	 top.impr.document.writeln(
	  '<html><head>'
	   +'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">'
	   +'<title>Fondotop</title>'
	   +'<script type="text/javascript" src="/script/lib/jquery.js"></script>'
	   +'<script type="text/javascript" src="/script/lib/r4.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXCommon.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXGrid.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXGrid_mcol.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXGrid_splt.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXGrid_srnd.js"></script>'
	   +'<script  src="/script/src/grid/dhtmlXGridCell.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/nicejforms.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/dragdrop.js"></script>'
		+'<script charset="iso-8859-1"  type="text/javascript" src="/script/src/jistory.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/autocomplete.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/idrag.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/iresizable.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/ifxtransfer.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/iutil.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/dimensions.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/cookies.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/form.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/tooltip.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/block.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/jq-innerfade.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/datePicker.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/recursos/js/window.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/lib/layers_r4.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/lib/abrir_r4.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/historico.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/lib/analisis_site.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/lib/popup_r4.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/menu.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/jquery.dimensions.js"></script>'
		+'<script charset="iso-8859-1" type="text/javascript" src="/script/src/jquery_history.js"></script>'
		+'<script charset="iso-8859-1"  type="text/javascript" src="/script/lib/r4.js"></script>'
		+'<script charset="iso-8859-1"  type="text/javascript" src="/recursos/js/general.js"></script>'
	   +'<link rel="stylesheet" type="text/css" href="/estilos/grid.css" />'
	   +'<link rel="stylesheet" type="text/css" href="/estilos/nl.css" />'
	   +'<body BGCOLOR=#FFFFFF text="#000000" LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0 bgcolor=white onLoad="self.focus()">'
	   +'<div class="textocopyright" align="right"><img src="/images/general/logoprint.gif"></div>'
	   +'<div class="textosaltos" align="left" style="font-size:12px; color:#909090"><b>fondotop.com</b>: bienvenido a la nueva era de los fondos de inversión.<br/></div>'
	   +'<div style="background: transparent url(/images/principalnl/linea.gif) repeat-x scroll 0%; width: 100%; height: 1px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"></div><br/>'
	   +$('#content').html()
	   +'<br/><br/><div style="background: transparent url(/images/principalnl/linea.gif) repeat-x scroll 0%; width: 100%; height: 1px; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"></div><br/>'
	   +'<div class="textocopyright" style="clear:both; float:left;"><br/><img src="/images/topnl/logor4.gif"> Renta 4 Copyright © 2007. All rights reserved.</div>'
	   +'<div class="textocopyright" style="clear:both; float:right;"><b>fondotop.com</b> es un servicio de Renta 4.<br/><br/></div>'
	   +'</body></html>'
	 )
	 // top.impr.window.print()
	 // setTimeout("top.impr.window.close()", 2000);
	 
}

$.loadgrid = function(namegrid,options) {
	options = options || {};
	options.filexml  = options.filexml || "/xml/pri.xml";
	options.sort     = options.sort || null;
	options.tipo     = options.tipo || null;
	options.titulos  = options.titulos || null;
	options.align    = options.align || null;
	options.ancho    = options.ancho || null;
	options.columnId = options.columnId || null;
	options.color    = options.color || null;
	
	options.skin           = options.skin || 'sok';
	options.attachHeader   = options.attachHeader || null;
	options.a_Styles       = options.a_Styles || null;	
	options.dateFormat     = options.dateFormat || null;
	options.a_NumberFormat = options.a_NumberFormat || null;	
	options.alterCSS1      = options.alterCSS1 || null;
	options.alterCSS2      = options.alterCSS2 || null;
	options.cssRowsHover   = options.cssRowsHover || null;	
	
	options.tipoancho = options.tipoancho || 'porc';
	options.AutoHeigth = options.AutoHeigth || true;
	options.ColumnAutoSize = options.ColumnAutoSize || true;
	options.Editable = options.Editable || false;
	options.ColumnMove = options.ColumnMove || true;
	options.Separar = options.Separar || false;
	options.SmartRender = options.SmartRender || false;
	options.LightMouse = options.LightMouse || true;

	options.enablePaging     = options.enablePaging || false;
	options.pageSize         = options.pageSize || '30';
	options.pagsInGrp        = options.pagsInGrp || '5';
	options.pagingArea       = options.pagingArea || null;
	options.infoArea         = options.infoArea || null;
	options.pagingSkin       = options.pagingSkin || 'bricks';
	options.attachEvent      = options.attachEvent || null;	
	options.attachEventFunc  = options.attachEventFunc || null;	

if(options.tipoancho == 'porc') {
	genanchos = null;
		totalesinit = 0;


	genanchos = (options.ancho).split(',');
	options.ancho = null;
	
	for(x=0; x<genanchos.length; x++) {
		totalesinit = (parseFloat(genanchos[x])) + totalesinit;
	}
	
	for(x=0; x<genanchos.length; x++) {
		newanchos = 0;

		newanchos=(parseFloat(genanchos[x])*100)/totalesinit;

		if (x == (genanchos.length-1)) {
			options.ancho = options.ancho + (newanchos) + '';
		} else {
			options.ancho = options.ancho + (newanchos) + ',';
		}
	}
	
}
	// $('body').css('height','150%');

	eval("grid_"+namegrid+" = new dhtmlXGridObject(namegrid); ");
	eval("grid_"+namegrid+".setImagePath('/images/grid/'); ");
  if (options.titulos != null) { eval("grid_"+namegrid+".setHeader(options.titulos); "); }
	if (options.tipoancho == 'porc') {
		if (options.ancho != null) { eval("grid_"+namegrid+".setInitWidthsP(options.ancho) "); }
	} else {
		if (options.ancho != null) { eval("grid_"+namegrid+".setInitWidths(options.ancho) "); }
	}
	if (options.align != null) { eval("grid_"+namegrid+".setColAlign(options.align) "); }
	if (options.tipo != null) { eval("grid_"+namegrid+".setColTypes(options.tipo); "); }
	if (options.sort != null) { eval("grid_"+namegrid+".setColSorting(options.sort) "); }
	if (options.color != null) { eval("grid_"+namegrid+".setColumnColor(options.color) "); }
	
	if (options.columnId != null) { eval("grid_"+namegrid+".setColumnIds(options.columnId); "); }
	
	if (options.attachHeader != null  &&  options.a_Styles != null) { 
		eval("grid_"+namegrid+".attachHeader(options.attachHeader, options.a_Styles); "); 
		eval("grid_"+namegrid+".setSizes(); "); 
	}
	
	if (options.dateFormat != null) { 
		eval("grid_"+namegrid+".setDateFormat(options.dateFormat); "); 
	}	
	
	if (options.a_NumberFormat != null) {
		eval("grid_"+namegrid+".i18n.decimal_separator = ',';"); 
		eval("grid_"+namegrid+".i18n.group_separator = '.';"); 
		for (i=0; i<options.a_NumberFormat.length; i++) {
			if (options.a_NumberFormat[i] != '') {
				eval("grid_"+namegrid+".setNumberFormat(options.a_NumberFormat[i], i); "); 
			}
		}
	}
	
 	eval("grid_"+namegrid+".enableAutoHeigth("+options.AutoHeigth+");");
	eval("grid_"+namegrid+".enableColumnMove("+options.ColumnMove+"); ");
	eval("grid_"+namegrid+".setSkin(options.skin);");
	
	if (options.enablePaging == true) {
		eval("grid_"+namegrid+".enablePaging(true, options.pageSize, options.pagsInGrp, options.pagingArea, true, options.infoArea); "); 
		eval("grid_"+namegrid+".setPagingSkin(options.pagingSkin);");
		eval("grid_"+namegrid+".preventIECaching(true);");
	}
	
	eval("grid_"+namegrid+".init(); ");
	
	if (options.alterCSS1 != null  &&  options.alterCSS2 != null) { 
		eval("grid_"+namegrid+".enableAlterCss(options.alterCSS1, options.alterCSS2); ");
	}
	
	if (options.cssRowsHover != null) { 
		eval("grid_"+namegrid+".enableRowsHover(true, options.cssRowsHover); "); 
	}		
	
	if (options.Separar == true) { eval("grid_"+namegrid+".splitAt(1);"); }
	eval("grid_"+namegrid+".enableSmartRendering("+options.SmartRender+");");
	if (options.Editable != null) { eval("grid_"+namegrid+".setEditable(!grid_"+namegrid+".isEditable);  "); }
	eval("grid_"+namegrid+".loadXML(options.filexml); ");

	if (options.attachEvent != null  &&  options.attachEventFunc != null) { 
		eval("grid_"+namegrid+".attachEvent(options.attachEvent, options.attachEventFunc); "); 
	}
	
	if (options.tipoancho == 'porc') {
			/* $('#'+namegrid).css('width','99.9%'); */
			/* $('#'+namegrid+'>table').css('width','101%');  */
	}
	/* $('body').css('width','100%'); */

	// $('body').css('height','100%');
	// eval("grid_"+namegrid+"=grid_"+namegrid+".destructor();");
} 

$.alertas = function(options) {
	alertactiva = 1;
	var alturaWindow = ($(window).height() / 2) + $(window).scrollTop();
 	 $('body').css('cursor','default');
	options = options || {};
	options.titulo = options.titulo || "fondotop";
	options.mensaje = options.mensaje || "<font style='color:#cc0000'>No se ha encontrado mensaje</font>";
	options.cerrar = options.cerrar || "Cerrar >";
	options.link = options.link || " ";
	options.link = "$.alertasremove(); " + options.link;
        $.blockUI('<p width="400" class="titazul" style="text-align:left;"><b>'+options.titulo+'</b></p><p style="font-size:13px; text-align:left; ">'+options.mensaje+'</p><p align="right" style=" font-weight: normal; font-size:13px;" class="linkazulsub"><a id="linkwin" href="javascript:;" onclick="'+options.link+'" class="linkazulsub">'+options.cerrar+'</a></p>',{
              backgroundColor: '#fffff6',
              width:'400px',
              minheight:'20px',
              textalign:'center',
              opacity: '0.95',
              left:'50%',
              border: '2px solid #cccccc',
              fontWeight: 'normal',
			  position: 'absolute',
			  top:alturaWindow,
              padding:'20px',
              margin:'-100px 0 0 -210px'
        }); 
				return false;
}

$.alertasremove = function() {
   $.unblockUI();
   $(".blockUI").remove();
		alertactiva = 0;
    return false;
}

$.cargadatos = function() {
        $('body').css('cursor','wait');
        $.blockUI('<img src="/images/general/loadcircle.gif" />',{
              // backgroundColor: '#ffffff',
              width:'80px',
              height:'80px',
              textalign:'center',
              opacity: '1',
              left:'50%',
              border: '0px solid #cccccc',
              fontWeight: 'normal',
              margin:'-40px 0 0 -20px'
        }); 
	
}

$.cargadatosremove = function() {
	if (alertactiva == 0) {
   $.unblockUI();
 	 $('body').css('cursor','default');
	}
}
			
$.ventana = function(activo, options) {
	options = options || {};
	options.url = options.url || "";
	if (options.resize == null) { options.resize = true; }
	if (options.minimize == null) { options.minimize = false; }
	options.link = options.link || "logo";
	options.tipo = options.tipo || "goto";
	options.ancho = options.ancho || "700";
	options.minW = options.minW || "700";
	options.maxW = options.maxW || "740";
	options.minH = options.minH || "410";
	options.maxH = options.maxH || "420";
	options.titulo = options.titulo || "fondotop";
	
	if ($('#'+activo).size() == 0) { 
		if ($('#'+options.link).size() != 0) {
				$("<div class='windowX' id='"+activo+"'><div class='windowXTop' id='"+activo+"Top'><div class='windowXTopContent'  id='"+activo+"TopContent'>"+options.titulo+"</div><img src='/images/general/window/window_min.jpg' id='"+activo+"Min' class='windowXMin'  /><img src='/images/general/window/window_max.jpg' class='windowXMax' id='"+activo+"Max' /><img src='/images/general/window/window_close.jpg' class='windowXClose' id='"+activo+"Close' /></div><div class='windowXBottom' id='"+activo+"Bottom'><div class='windowXBottomContent' id='"+activo+"BottomContent'>&nbsp;</div></div><div class='windowXContent' id='"+activo+"Content'>Cargando datos...</div><img src='/images/general/window/window_resize.gif' class='windowXResize'  id='"+activo+"Resize' /></div>").appendTo('body');
				$('#'+activo).css('width',options.ancho);
				$('#'+activo+'Content').css('width',options.ancho-25);
				if (options.resize == false) { $('#'+activo+'Resize').remove(); }
				if (options.minimize == false) { $('#'+activo+'Min').remove(); $('#'+activo+'Max').remove(); }
		}
	}
	
	if($('#'+activo).css('display') == 'none') {
	
/*		$('#'+options.link).TransferTo(
			{
				to: activo,
				className:'transferer2', 
				duration: 400
			}
		);  */
		$('#'+activo).show();
		$('#'+activo).css('top',$(document).scrollTop()+100);
		$.goto(options.url,{tipo:options.tipo,cont:activo+'Content',cache:false,loading:true}); 

	} 
	else {

/*		$('#'+options.link).TransferTo(
			{
				to: activo,
				className:'transferer2', 
				duration: 400
			}
		);  */
		$('#'+activo+'TopContent').html(options.titulo)
		$('#'+activo).css('top',$(document).scrollTop()+100);
		$.goto(options.url,{tipo:options.tipo,cont:activo+'Content',cache:true,loading:true});
	} 

        
	$('#'+activo+'Min').bind(
		'click',
		function()
		{
			$('#'+activo+'Content').SlideToggleUp(300);
			$('#'+activo+'Bottom, #'+activo+'BottomContent').animate({height: 10}, 300);
			$('#'+activo).animate({height:40},300).get(0).isMinimized = true;
			$(this).hide();
			$('#'+activo+'Resize').hide();
			$('#'+activo+'Max').show();
		}
	);
	$('#'+activo+'Max').bind(
		'click',
		function()
		{
			var windowXSize = $.iUtil.getSize(document.getElementById(activo+'Content'));
			$('#'+activo+'Content').SlideToggleUp(300);
			$('#'+activo+'Bottom, #'+activo+'BottomContent').animate({height: windowXSize.hb + 13}, 300);
			$('#'+activo).animate({height:windowXSize.hb+43}, 300).get(0).isMinimized = false;
			$(this).hide();
			$(this).unbind('click');
			$('#'+activo+'Min, #'+activo+'Resize').show();
		}
	);
	$('#'+activo+'Close').bind(
		'click',
		function()
		{
			if($('#'+options.link).size() == 0) { options.link = 'volver'};
			$('#'+activo).TransferTo(
				{
					to:options.link,
					className:'transferer2', 
					duration: 400
				}
			).hide(); 
		$('#'+activo).empty(); 
		$('#'+activo).remove(); 
		$('#'+options.link).unbind('click');
		}
	);


	$('#'+activo).Resizable(
		{
			minWidth: options.minW,
			minHeight: options.minH,
			maxWidth: options.maxW,
			maxHeight: options.maxH,
			dragHandle: '#'+activo+'Top',
			handlers: {
				se: '#'+activo+'Resize'
			},
			onResize : function(size, position) {
				eval("$('#"+activo+"Bottom, #"+activo+"BottomContent').css('height', size.height-33 + 'px');"+
				"var "+activo+"ContentEl = $('#"+activo+"Content').css('width', size.width - 25 + 'px');"+
				"if (!document.getElementById('"+activo+"').isMinimized) {"+
				"	"+activo+"ContentEl.css('height', size.height - 48 + 'px');"+
				"}");


			}
		}
	); 
}


$.ftcookie = function(cookie,options) {
	options = options || {};
	options.tipo = options.tipo || "leer";
	options.valor = options.valor || "";

	if (options.tipo == "leer") {
		return $.cookie(cookie);
	}
	if (options.tipo == "borrar") {
		$.cookie(cookie, '', {expires: -1});
	}
	if (options.tipo == "crear") {
		$.cookie(cookie, options.valor, {expires: 1000});
	}
}


/* Funciones antiguas */

function goto(url, contenedor) {
	$.goto(url,{cont:contenedor});
}

$.encriptar = function(texto) {
		texto = texto.replace('á', '&aacute;');
		texto = texto.replace('é', '&eacute;');
		texto = texto.replace('í', '&iacute;');
		texto = texto.replace('ó', '&oacute;');
		texto = texto.replace('ú', '&uacute;');
		texto = texto.replace('ñ', '&ntilde;');
    return texto;
}





$.leerxml = function(url,contenedor) {

	$.get(url, function(xml) { 



			// WIDTH ARRAY
			var widthxml = new Array;
			$('rows > width', xml).each(function(i) {
					$('cell',this).each(function(i2) {
								widthxml[i2] = $(this).text();
					});
			});

			// ALIGN ARRAY
			var alignxml = new Array;
			$('rows > align', xml).each(function(i) {
					$('cell',this).each(function(i2) {
								alignxml[i2] = $(this).text();
					});
			});

			// COLOR ARRAY
			var colorxml = new Array;
			$('rows > color', xml).each(function(i) {
					$('cell',this).each(function(i2) {
								colorxml[i2] = $(this).text();
					});
			});


				var contxml = "<table width='100%' border='0' align='center' cellpadding='3' cellspacing='0' class='tablaxml' style='width: 100%; table-layout: fixed;'>";			


			// CABECERA
			$('rows > cabecera', xml).each(function(i) {
					contxml = contxml + "<tbody class='cabeceraxml'><tr>";
					$('cell',this).each(function(i2) {
									contxml = contxml + "<td width='"+widthxml[i2]+"' align='"+alignxml[i2]+"' style='overflow: hidden; white-space: nowrap;'>"+$(this).text()+"</td>";
					});
					contxml = contxml + "</tr></tbody>";
			});

			// CONTENIDO
			contxml = contxml + "<tbody class='contenidoxml'>";
			$('rows > row', xml).each(function(i) {
					contxml = contxml + "<tr>";
					$('cell',this).each(function(i2) {							
								textofin = $(this).text();
								if ((colorxml[i2] != null) || (colorxml[i2] != '')) {  
										color = 'background-color:#'+colorxml[i2]+';';
								} else {
										color = ' ';
								}
								if ((textofin == null) || (textofin == '')) {  textofin = '&nbsp;'; }
								textodiv = textofin.split('^');
								if (textodiv[1] == null) {
										contxml = contxml + "<td  width='"+widthxml[i2]+"' align='"+alignxml[i2]+"' style='"+color+" overflow: hidden; white-space: nowrap;'>"+textofin+"</td>";
								} else {
										contxml = contxml + "<td  width='"+widthxml[i2]+"' align='"+alignxml[i2]+"' style='"+color+" overflow: hidden; white-space: nowrap;'><a href='javascript:;' onclick='"+textodiv[1]+"'>"+textodiv[0]+"</a></td>";
								}
					});
					contxml = contxml + "</tr>";
			});
					contxml = contxml + "</tbody>";
			contxml = contxml + "</table>";
			
			$('#'+contenedor).html(contxml);
			$.cambioestilos();

	});
	
}



/*
//Ahora estas tres funciones estan en /recursos/js/desconex.js
function CerrarSesion(nif)
{
        var cookies = getCookie('ventanas');
        if (cookies)
        {
                if (cookies.indexOf('r4win')!=-1){
                        window.open('https://195.53.90.60/arq/cerrar_ventanas.jsp');
                }
                if (cookies.indexOf('ftopwin')!=-1){
                        window.open('https://195.53.90.61/arq/cerrar_ventanas.jsp');
                }
                cookies = cookies.split('|');
                for (var i=0 ; i<cookies.length ; i++)
                {
                        window.open('',cookies[i],'').close();
                }
        }
        document.cookie='ventanas=';
}



function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    }
  }
  return null;
}



function desconectar(url) {
	CerrarSesion();
        location.href=url;
}
*/



/* Drag & Drop */


$.dragdropft = function(idft,xmlfile) {
	
$.ajax({
	type: "GET",
	url: xmlfile,
	dataType: "xml",
	success: function(xml){
		

/*			$('config',xml).each(function() {
				for(x=1; x<=$('columnas', this).text(); x++) {
					$('#'+$('contenedor', this)).SortableDestroy();
				}
			}); */


		if ($.ftcookie('dragdrop_'+idft) != null) {
			
			var arraycookie = $.descompserial(idft);


			
			$('config',xml).each(function() {
				for(x=1; x<=$('columnas', this).text(); x++) {
					$('#'+$('contenedor', this).text()).append('<div id="ddcol'+idft+x+'" class="groupWrapper" style="width:'+$('anchocolporc', this).text()+'%; font-size:1px">&nbsp;</div>');
				}
			});
	
		    for (x=0; x < arraycookie.length; x++) {
			$('bloque',xml).each(function() {
	
				if ($('tipo', this).text() == 'texto') {
						if (arraycookie[x][0] == "ddbloque_"+$('id', this).text() ) {
							$('#'+arraycookie[x][1]).append('<div id="ddbloque_'+$('id', this).text()+'" grupodd="grupo_'+idft+'" class="groupItem"><div class="itemHeader">'+$('titulo', this).text()+'<a href="javascript:;" class="closeEl">[-]</a></div><div class="itemContent">'+$('contenido', this).text()+'</div></div>');
						}
				} else {
						if (arraycookie[x][0] == "ddbloque_"+$('id', this).text() ) {
							$('#'+arraycookie[x][1]).append('<div id="ddbloque_'+$('id', this).text()+'" grupodd="grupo_'+idft+'" class="groupItem"><div class="itemHeader">'+$('titulo', this).text()+'<a href="javascript:;" class="closeEl">[-]</a></div><div id="ddbloquedin_'+$('id', this).text()+'" class="itemContent"></div></div>');
							urldin = $('contenido', this).text();
							$( "#ddbloquedin_"+$('id', this).text() ).load(urldin);
						}
				}
	
			});
			    }
			
			activarddrop(idft);
			$.cambioestilos();

		} else {

			$('config',xml).each(function() {
				for(x=1; x<=$('columnas', this).text(); x++) {
					$('#'+$('contenedor', this).text()).append('<div id="ddcol'+idft+x+'" class="groupWrapper" style="width:'+$('anchocolporc', this).text()+'%; font-size:1px">&nbsp;</div>');
				}
			});
	
			$('bloque',xml).each(function() {
	
				if ($('tipo', this).text() == 'texto') {
					$('#ddcol'+idft+$('columna', this).text()).append('<div id="ddbloque_'+$('id', this).text()+'" grupodd="grupo_'+idft+'" class="groupItem"><div class="itemHeader">'+$('titulo', this).text()+'<a href="javascript:;" class="closeEl">[-]</a></div><div class="itemContent">'+$('contenido', this).text()+'</div></div>');
				} else {
	
					$('#ddcol'+idft+$('columna', this).text()).append('<div id="ddbloque_'+$('id', this).text()+'" grupodd="grupo_'+idft+'" class="groupItem"><div class="itemHeader">'+$('titulo', this).text()+'<a href="javascript:;" class="closeEl">[-]</a></div><div id="ddbloquedin_'+$('id', this).text()+'" class="itemContent"></div></div>');
					urldin = $('contenido', this).text();
					$( "#ddbloquedin_"+$('id', this).text() ).load(urldin);
				}
	
			});
			// alert($('[@grupodd=grupo_'+idft+']').length);
			activarddrop(idft);
			$.cambioestilos();

		}


	}
})
}

function activarddrop(idft) {
		$('a.closeEl').bind('click', toggleContent);
		$('div.groupWrapper').Sortable(
			{
				accept: 'groupItem',
				// accept: '[@grupodd=grupo_'+idft+']',
				helperclass: 'sortHelper',
				activeclass : 	'sortableactive',
				hoverclass : 	'sortablehover',
				handle: 'div.itemHeader',
				tolerance: 'pointer',
				onChange : function(ser)
				{
					serializar(idft);
				},
				onStart : function()
				{
					$.iAutoscroller.start(this, document.getElementsByTagName('body'));
				},
				onStop : function()
				{
					$.iAutoscroller.stop();
				}
			}
		);
}

var toggleContent = function(e)
{
	var targetContent = $('div.itemContent', this.parentNode.parentNode);
	if (targetContent.css('display') == 'none') {
		targetContent.slideDown(300);
		$(this).html('[-]');
	} else {
		targetContent.slideUp(300);
		$(this).html('[+]');
	}
	return false;
};
function serializar(idft)
{	serial = $.SortSerialize();
	$.ftcookie('dragdrop_'+idft, {tipo:'crear',valor:serial.hash});
};

$.descompserial = function(cual) {
var xmlarray = new Array;
	var configuracion = $.ftcookie('dragdrop_'+cual);
	configuracion = configuracion.split('\&');
	
	$.each(configuracion, function(i,n) {
		var actual = n.split('[]=');
		xmlarray[i] = new Array;
		xmlarray[i][0] = actual[1];
		xmlarray[i][1] = actual[0];
	});
	return xmlarray;
}


$.menuxml = function(imenux, imulticuenta) {

imenux = imenux || "0";

if (imenux == "0") { ur = "/xml/mapasitionlg.xml"; } else { ur = "/xml/mapalogado.xml"; }
if (imulticuenta == "S"){imulticuenta = "1"; } else {imulticuenta = "0"; }


$.ajax({
	type: "GET",
	url: ur,
	dataType: "xml",
	success: function(xml){
			contenedormenu = 'menux';
			bLi = true;
			bLiM = true;


				/* Contenido inicial */
				contentx = '<ul id="opboton" class="jd_menu" style="width:100%">';

				$('SECCION',xml).each(function() {
 				  if ( ($('> TIPO',this).text() == "ALL") || ($('> TIPO',this).text() == "MENU") ) {
					contentx = contentx + '<li onclick="'+$('> LINKMENU', this).text()+'">' + $('> NOMBREMENU', this).text();
					$('> MENU',this).each(function() {
								contentx = contentx + '<ul>';
											$('> LINK',this).each(function() {
											 if ( ($('> TIPO',this).text() == "ALL") || ($('> TIPO',this).text() == "MENU") ) {
												if ( $('> URL',this).text() == "") {
													contentx = contentx + '<li style="text-decoration:none; cursor:default;" onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text(); 
												} else {
													if ( $('> MULTICUENTA',this).text() == "0")
													{
													 contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text();
													}
												  else if(imulticuenta == "1")
												  {
												   contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text();
												  }
												  else bLi = false; 													
												}
															$('> MENU',this).each(function() {
																contentx = contentx + '<ul>';
																			$('> LINK',this).each(function() {
															 				 if ( ($('> TIPO',this).text() == "ALL") || ($('> TIPO',this).text() == "MENU") ) {
																				if ( $('> URL',this).text() == "") {
																					contentx = contentx + '<li style="text-decoration:none; cursor:default;" onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text(); 
																				} else {
																				if ( $('> MULTICUENTA',this).text() == "0")
													              {
													               contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text(); 
												                }
												                else if(imulticuenta == "1")
												                {
												  	             contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text(); 
												                }
												                else bLiM = false;
																				}
																				
																				$('> MENU',this).each(function() {
																					contentx = contentx + '<ul>';
																								$('> LINK',this).each(function() {
																				 				 if ( ($('> TIPO',this).text() == "ALL") || ($('> TIPO',this).text() == "MENU") ) {
																									if ( $('> URL',this).text() == "") {
																										contentx = contentx + '<li style="text-decoration:none; cursor:default;" onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text() + '</li>'; 
																									} else {
																									if ( $('> MULTICUENTA',this).text() == "0")
           													              {
													                         contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text() + '</li>'; 
												                          }
												                          else if(imulticuenta == "1")
												                          {
												  	                       contentx = contentx + '<li onclick="'+$('> URL',this).text()+'">' + $('> NOMBRE',this).text() + '</li>'; 
												                          }
																									}
																				 				 }
																								});
																					contentx = contentx + '</ul>';
																				});
																			 if(bLiM)contentx = contentx + '</li>';
																			 bLiM= true;
															 				 }
																			});
																contentx = contentx + '</ul>';
															});
											 if(bLi)contentx = contentx + '</li>';
											 bLi= true;
									 	   }
										});
								contentx = contentx + '</ul>';
						});
					contentx = contentx + '</li>';
				
				}
				});


				/* Contenido final */
				contentx = contentx + '</ul>';
			
			$('#'+contenedormenu).append(contentx);
			// $('#buscafondo').val("entramos");
			// $('#content').text($('#'+contenedormenu).html());
			$('ul.jd_menu').jdMenu();

			}
	});
}




