// jrc012-wwwjuanrodrigueznet.js - Copyright (C) 2002-2010 by Juan Rodríguez [Consultor] & Begues Internet, s.l.

window.onload=function() {Pagina()};
window.onresize=Resize;
var AncDis; var AltDis; var Opacidad; var Ancho=0; var AnchoSc=0; var Medio=0; var AncPreRed=0;

function Resize() {
if (window.innerHeight) {Ancho=window.innerWidth}
else if (document.documentElement && document.documentElement.clientHeight) {Ancho=document.documentElement.offsetWidth}
else if (document.body) {Ancho=document.body.clientWidth}
AncDis=parseInt(Ancho) -21;
if (AncDis != AncPreRed) {AncPreRed=AncDis; window.location.reload()} }

function Pagina(pag) {
document.getElementById("CapaOpaca").style.display="block"
if (window.innerHeight) {Ancho=window.innerWidth; Alto=window.innerHeight; AnchoSc=document.documentElement.clientWidth}
else if (document.documentElement && document.documentElement.clientHeight) {Ancho=document.documentElement.offsetWidth; AnchoSc=document.documentElement.clientWidth; Alto=document.documentElement.clientHeight}
else if (document.body) {Ancho=document.body.clientWidth; Alto=document.body.clientHeight}
AncDis=parseInt(Ancho) - 21; AltDis=parseInt(Alto);  Medio=parseInt(AncDis/2);
if (AncPreRed==0) {AncPreRed=AncDis}
PagCuerpo(pag) } 

function PagCuerpo(pag) {
if (AncDis >= 1280) {posMed=Medio-(596/2); posIzq=Medio -(596/2) -40 - 195;  posDer=Medio+(596/2)+40}
if ((AncDis >= 1008) && (AncDis < 1280)) {Sobrante=AncDis-986; Sep=parseInt(Sobrante/3); posIzq=Medio-(596/2)-195-Sep; posMed=Medio-(596/2); posDer=Medio+(596/2)+Sep}
if (AncDis < 1008) {Sobrante=AncDis-986; if (Sobrante < 3) {Sobrante=0}; Sep=parseInt(Sobrante/3); posIzq=Sep; posMed=Sep+195+Sep; posDer=Sep+195+Sep+596+Sep}
if ((AncDis < 965) || (AltDis < 500)) {document.getElementById("Menu").style.position="absolute"; document.getElementById("Consultor").style.position="absolute";}

document.getElementById("Consultor").style.left=posIzq +"px"; 
document.getElementById("Cuerpo").style.left=posMed +"px"; 
document.getElementById("Menu").style.left=posDer +"px"; 
// alert("AncDis: "+AncDis+" Sobrante. "+Sobrante+ " Medio; "+Medio+" posIzq: "+posIzq+" posMed: "+posMed+" posDer: "+posDer);
PosMenu="";
PosMenu=leerCookie('JRc_Menu'); if ( PosMenu !=null) {PosMenu=PosMenu} else {PosMenu="Derecha"};
if (PosMenu=="Derecha") {document.getElementById("Menu").style.left=posDer +"px"; document.getElementById("Consultor").style.left=posIzq +"px"}
if (PosMenu=="Izquierda") {document.getElementById("Menu").style.left=posIzq +"px"; document.getElementById("Consultor").style.left=posDer +"px"}
posPiePag();
Opacidad=1; setOpacidad(1);
AperturaLinkExterno()
 }

function posPiePag() {
if (document.getElementById("PiePosicionado")) {
document.getElementById("PiePosicionado").style.position="absolute";
if (AltDis > 760) {document.getElementById("PiePosicionado").style.top=AltDis-85+"px"}; 
document.getElementById("PiePosicionado").style.visibility="visible"} }

function setOpacidad(Opacidad) {document.getElementById("CapaOpaca").style.opacity=Opacidad; document.getElementById("CapaOpaca").style.filter = 'alpha(opacity=' + Opacidad*100 + ')'; cambiarOpacidad() }
function cambiarOpacidad() {Opacidad=Opacidad-0.05; Opacidad=Math.round(Opacidad*100)/100; if (Opacidad >= 0) {setTimeout("setOpacidad(Opacidad)",100);} else {document.getElementById("CapaOpaca").style.display="none"}; }

function CamMenu(pag) {if (PosMenu=="Derecha") {crearCookie('JRc_Menu', 'Izquierda'); PosMenu="Izquierda"} else {crearCookie('JRc_Menu', 'Derecha'); PosMenu="Derecha"}; PagCuerpo(pag) }
function crearCookie(nombre, valor) {var caducidad = new Date(); caducidad.setTime(caducidad.getTime() + ( 60*24*60*60*1000) ); document.cookie=nombre + "=" + escape(valor) + "; expires="+caducidad.toGMTString()}

function leerCookie(name) {
var cname=name + "="; var dc=document.cookie;
if (dc.length > 0) {begin=dc.indexOf(name); 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 AperturaLinkExterno() { 
if (!document.getElementsByTagName) return; 
var anchors=document.getElementsByTagName("a"); 
for (var i=0; i < anchors.length; i++) {
var anchor=anchors[i]; 
if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "WE") {anchor.target="self"}  
if (anchor.getAttribute("rel") && anchor.getAttribute("rel") == "nofollow") {anchor.target="self"}  }  } 

// BLOQUES
function aBloque(bq) {document.getElementById("Bloque"+bq).style.height="auto"; document.getElementById("Bloque"+bq).style.visibility="visible"; document.getElementById("Bloque"+bq).style.display="block"}
function cBloque(bq) {document.getElementById("Bloque"+bq).style.height=1+"px"; document.getElementById("Bloque"+bq).style.visibility="hidden"; document.getElementById("Bloque"+bq).style.display="none"}

// CORREO
function CJRc() {return "consultor" + "@" + "juan-rodriguez.net" }
function CorreoJRc(asunto) {document.write("<a href='mailto:"+ CJRc() + "?subject=" + asunto + " '>" + CJRc() + "</a>") }
