// JavaScript Document
function parametros(url){
	var ret = new Object;
	var pos = url.indexOf("?");
	if(pos > 0) {
		url = url.substring(pos+1,url.length);
		var arraux = url.split("&");
		for(var i = 0; i < arraux.length; i++){
			var biv = arraux[i].split("=");
			ret[biv[0]] = biv[1];
		}
	}
	return ret;
}

function goto(href,target,historial){
	var hash = href;
	hash = hash.replace(/^.*#/, '');
	hash = (hash && hash.indexOf('?') == -1) ? hash + "?incluido=1" : hash + "&incluido=1";
	target.load(hash);
	
	if(typeof historial === 'undefined'){
		hash = base64Encode(hash);
		$.history.load(hash);
	}
	
	return false;
}

function gotoPagina(href,historial){
	var hash = href;
	hash = hash.replace(/^.*#/, '');
	hash = (hash && hash.indexOf('?') == -1) ? hash + "?incluido=1" : hash + "&incluido=1";
	var param = parametros(hash);
	
	if(!(typeof param['pagina'] === 'undefined')){
		$('[id^="pagina_"]').hide();
		$('#pagina_' + param['pagina']).show('slow');
		pagina = param['pagina'];
		$("#paginacion td.sel").removeClass("sel");
		$('#paginacion td.paginacion_' + param['pagina']).addClass("sel");
		$(document).scrollTop(0);
	}
	
	if(typeof historial === 'undefined'){
		hash = base64Encode(hash);
		$.history.load(hash);
	}
	return false;
}

function volver(){
	if(contenido.length == 0){
		history.go(-1);
	}else{
		$('#contenido').html(contenido.pop());
		$('#contenido').activateJFrame();
	}		
}
