function AbreVentana(sNombreVentana, sUrl, left, top, width, height) {
Ventana = window.open(sUrl, sNombreVentana,'top= ' + top +', left=' + left + ', toolbar=0,location=0,directories=0,status=1,scrollbars=1,resizable=1,width='+width+',height='+height);
Ventana.opener = self;
}
function getStyle(el, style) {
   if(!document.getElementById) return;
   
     var value = el.style[toCamelCase(style)];
   
    if(!value)
        if(document.defaultView)
            value = document.defaultView.
                 getComputedStyle(el, "").getPropertyValue(style);
       
        else if(el.currentStyle)
            value = el.currentStyle[toCamelCase(style)];
     
     return value;
}
function setStyle(objId, style, value) {
    document.getElementById(objId).style[style] = value;
}
function toCamelCase( sInput ) {
    var oStringList = sInput.split('-');
    if(oStringList.length == 1)    
        return oStringList[0];
    var ret = sInput.indexOf("-") == 0 ? 
       oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) : oStringList[0];
    for(var i = 1, len = oStringList.length; i < len; i++){
        var s = oStringList[i];
        ret += s.charAt(0).toUpperCase() + s.substring(1)
    }
    return ret;
}
function setsty(addToWidth, whichDiv, param){
    var theDiv = document.getElementById(whichDiv);
    var currWidth = parseInt(getStyle(theDiv, param));
    var newWidth = parseInt(addToWidth);
    setStyle(whichDiv, param, newWidth + "px");
}
function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}
function resi(){
fir = (document.getElementById && !document.all)? true:false;
ie4 = (document.all)? true:false;
ope = (window.opera && window.print)? true:false;
if (!ie4) {
	winW = window.innerWidth;
	winH = window.innerHeight;
}
if (ie4) {
	winW = document.body.offsetWidth;
	winH = document.body.offsetHeight;
}
if (winW < 742 || winH < 560) { 
resizeOuterTo(750,580);
} 
if (!ie4) {
	winW = window.innerWidth;
	winH = window.innerHeight;
}
if (ie4) {
	winW = document.body.offsetWidth;
	winH = document.body.offsetHeight;
}
if (winH < 460) {
tam="p";
if (ie4) { pequ(); }
else {
window.location=window.location; 
}
}
if (winH > 470) {
tam="g";
if (ie4) { gran(); }
else {
window.location=window.location; 
}
}
}

function pequ() {
setsty(67,"msp","top");
setsty(89,"cuer","top");
setsty(winH-89-20,"cuer","height"); 
setsty(89,"mniz","top");
setsty(285,"tick","top");
myReference = document.getElementById("nota");
if (myReference!=null) {
for (i=97; i<=116; i++){ setsty(105,"not" + String.fromCharCode(i),"top"); }
}
setsty(65,"cbc","height");
myReference = document.getElementById("icb");
if (myReference!=null) {
if (myReference.src=="images/logoi.gif") {
loy=myReference.style.marginTop;
lox=myReference.style.marginLeft;
}
myReference.src=("images/logod.gif");
myReference.style.marginTop=2+"px";
myReference.style.marginLeft=30+"px";
}
myReference = document.getElementById("cbc");
if (myReference!=null) {
myReference.style.background="url(images/cabec0.jpg)";
}
myReference = document.getElementById("NewsTicker0");
if (myReference!=null) {
myReference.style.left=(winW/2-360)+"px";
myReference.style.top=286+"px";
}
}

function gran() {
setsty(182,"msp","top");
setsty(204,"cuer","top");
setsty(winH-204-20,"cuer","height"); 
setsty(204,"mniz","top");
setsty(400,"tick","top");
myReference = document.getElementById("nota");
if (myReference!=null) {
for (i=97; i<=116; i++){ setsty(220,"not" + String.fromCharCode(i),"top"); }
}
setsty(180,"cbc","height");
myReference = document.getElementById("icb");
if (myReference!=null) {
myReference.src=("images/logoi.gif");
myReference.style.marginTop=loy;
myReference.style.marginLeft=lox;
}
myReference = document.getElementById("cbc");
if (myReference!=null) {
myReference.style.background=lou;
}
myReference = document.getElementById("NewsTicker0");
if (myReference!=null) {
myReference.style.left=(winW/2-360)+"px";
myReference.style.top=401+"px";
}
}

function notalegal(ii){
window.open('avileg'+ii+'.htm','AVISOLEGAL','top=0, left=0,width=636,height=400,scrollbars=1');
}
function imagen(sPicURL) { 
     iepu=window.open( "pop.htm?"+sPicURL, "iepu",  
     "resizable=1,HEIGHT=1,WIDTH=1,LEFT=2000,TOP=2000");
}
function abrir(idi,map){
window.open("local.asp?la="+idi+"&ma="+map,"LOCALIZACION","top=10,left=0,width=1250,height=660,menubar=0,resizable=1,scrollbars=1");
}
var indx=1;
function fi() {
indx=indx+1;
if (indx==4) indx=1;
if (indx==1) indc="loccerca";
if (indx==2) indc="locmedio";
if (indx==3) indc="loclejos";
document.images[1].src = "images/" + indc + ".gif";
}

function findPosX(obj)
{
  var curleft = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curleft += obj.offsetLeft;
      obj = obj.offsetParent;
    }
  }
  else if (obj.x)
    curleft += obj.x;
  return curleft;
}

function findPosY(obj)
{
  var curtop = 0;
  if (obj.offsetParent)
  {
    while (obj.offsetParent)
    {
      curtop += obj.offsetTop;
      obj = obj.offsetParent;
    }
  }
  else if (obj.y)
      curtop += obj.y;
  return curtop;
}

function ImageExpander(oThumb, sImgSrc)
{
	// store thumbnail image and overwrite its onclick handler.
	this.oThumb = oThumb;
	this.oThumb.expander = this;
	this.oThumb.onclick = function() { this.expander.expand(); }
	
	// record original size
	this.smallWidth = oThumb.offsetWidth;
	this.smallHeight = oThumb.offsetHeight;	
	
	this.bExpand = true;
	this.bTicks = false;
	
	// self organized list
	if ( !window.aImageExpanders )
	{
		window.aImageExpanders = new Array();
	}
	window.aImageExpanders.push(this);

	// create the full sized image.
	this.oImg = new Image();
	this.oImg.expander = this;
	this.oImg.style.border='4px inset';
	this.oImg.style.zindex = 100;
	this.oImg.onload = function(){this.expander.onload();}
	this.oImg.src = sImgSrc;
}

ImageExpander.prototype.onload = function()
{
	this.oDiv = document.createElement("div");
	this.oDiv.id = "mpd";
	document.body.appendChild(this.oDiv);
	this.oDiv.appendChild(this.oImg);
	this.oDiv.style.position = "absolute";
	this.oDiv.style.zindex = 100;
	this.oDiv.expander = this;
	this.oDiv.onclick = function() {this.expander.toggle();};
	this.oImg.title = "Pulse para reducir";
	if (ln=="2") { this.oImg.title = "Click to reduce"; }
	else { this.oImg.title = "Pulse para reducir"; }
	this.bigWidth = this.oImg.width;
	this.bigHeight = this.oImg.height;
	
	if ( this.bExpand )
	{
		this.expand();
	}
	else
	{
		this.oDiv.style.visibility = "hidden";
		this.oImg.style.visibility = "hidden";
	}
}
ImageExpander.prototype.toggle = function()
{
	this.bExpand = !this.bExpand;
	if ( this.bExpand )
	{
		for ( var i in window.aImageExpanders )
			if ( window.aImageExpanders[i] !== this )
				window.aImageExpanders[i].reduce();
	}
}
ImageExpander.prototype.expand = function()
{
	// set direction of expansion.
	this.bExpand = true;

	// set all other images to reduce
	for ( var i in window.aImageExpanders )
		if ( window.aImageExpanders[i] !== this )
			window.aImageExpanders[i].reduce();

	// if not loaded, don't continue just yet
	if ( !this.oDiv ) return;
	
	// hide the thumbnail
	this.oThumb.style.visibility = "hidden";
	
	// calculate initial dimensions
	this.x = findPosX(this.oThumb);
	this.y = findPosY(this.oThumb);
	this.w = this.oThumb.clientWidth;
	this.h = this.oThumb.clientHeight;
	
	this.oDiv.style.left = this.x + "px";
	this.oDiv.style.top = this.y + "px";
	this.oDiv.style.zindex = 100;
	this.oImg.style.width = this.w + "px";
	this.oImg.style.height = this.h + "px";
	this.oImg.style.zindex = 100;
	this.oDiv.style.visibility = "visible";
	this.oImg.style.visibility = "visible";
	
	// start the animation engine.
	if ( !this.bTicks )
	{
		this.bTicks = true;
		var pThis = this;
		window.setTimeout(function(){pThis.tick();},10);	
	}
}
ImageExpander.prototype.reduce = function()
{
	// set direction of expansion.
	this.bExpand = false;
}
ImageExpander.prototype.tick = function()
{
	// calculate screen dimensions
	var cw = document.body.clientWidth;
	var ch = document.body.clientHeight;
	var cx = document.body.scrollLeft + cw / 2;
	var cy = document.body.scrollTop + ch / 2;

	// calculate target
	var tw,th,tx,ty;
	if ( this.bExpand )
	{
		tw = this.bigWidth;
		th = this.bigHeight;
		if ( tw > cw )
		{
			th *= cw / tw;
			tw = cw;
		}	
		if ( th > ch )
		{
			tw *= ch / th;
			th = ch;
		}
//		tx = cx - tw / 2;
//		ty = cy - th / 2; 
		tx = cw - tw - 10;
		ty = ch - th - 26; 
	}
	else
	{
		tw = this.smallWidth;
		th = this.smallHeight;
		tx = findPosX(this.oThumb);
		ty = findPosY(this.oThumb);
	}	
	// move 5% closer to target
	var nHit = 0;
	var fMove = function(n,tn) 
	{
		var dn = tn - n;
		if ( Math.abs(dn) < 3 )
		{
			nHit++;
			return tn;
		}
		else
		{
			return n + dn / 3;
		}
	}
	this.x = fMove(this.x, tx);
	this.y = fMove(this.y, ty);
	this.w = fMove(this.w, tw);
	this.h = fMove(this.h, th);
	
	this.oDiv.style.left = this.x + "px";
	this.oDiv.style.top = this.y + "px";
	this.oDiv.style.zindex = 100;
	this.oImg.style.width = this.w + "px";
	this.oImg.style.height = this.h + "px";
	this.oImg.style.zindex = 100;

	// if reducing and size/position is a match, stop the tick	
	if ( !this.bExpand && (nHit == 4) )
	{
		this.oImg.style.visibility = "hidden";
		this.oDiv.style.visibility = "hidden";
		this.oThumb.style.visibility = "visible";

		this.bTicks = false;
	}
	
	if ( this.bTicks )
	{
		var pThis = this;
		window.setTimeout(function(){pThis.tick();},10);
	}
}
function checkresize() { 
if (winW==window.innerWidth && winH==window.innerHeight){ 
chkresizetimer = setTimeout("checkresize()",100); 
} 
else { 
clearTimeout(chkresizetimer); 
window.location.reload(); 
} 
} 