// JavaScript Document
function getRef(obj) { //devuelde el objeto entero en formato document.getElementByID
      if(typeof obj == "string") {
         obj= document.getElementById(obj);
		}
      return obj;
}

function BW_reload() {location.reload();}

function centerLayers() { //v4.1.1
	if (document.layers || document.all || document.getElementById){
		var winWidth, winHeight, i, horz, vert, width, height, offsetX, offsetY, negX, negY, group, x, y, args;
		args = centerLayers.arguments;
		
		//onresize = BW_reload;

				
		winWidth = (document.all)?document.body.clientWidth:window.innerWidth;
		winHeight = (document.all)?document.body.clientHeight:window.innerHeight;
				
		for (i=0; i<(args.length-9); i+=10) {
			horz    = args[i+1];
			vert    = args[i+2];
			width   = parseInt(args[i+3]);
			height  = parseInt(args[i+4]);
			offsetX = parseInt(args[i+5]);
			offsetY = parseInt(args[i+6]);
			negX    = args[i+7];
			negY    = args[i+8];
		
			x = ((winWidth - width)/2) + offsetX;
			y = ((winHeight - height)/2) + offsetY;
						
			x = (negX=='false' && (x < 0))?0:x;
			y = (negY=='false' && (y < 0))?0:y;
				
			layerObj = (document.getElementById)?document.getElementById(args[i]):MM_findObj(args[i]);
			
			if (layerObj!=null) {
				layerObj = (layerObj.style)?layerObj.style:layerObj;
				layerObj.left = (horz=="true")?x:layerObj.left;
				layerObj.top = (vert=="true")?y:layerObj.top;
			}
		}
	}
}

function verifyCompatibleBrowser(){ 
    this.ver=navigator.appVersion 
    this.dom=document.getElementById?1:0 
    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
    this.ie4=(document.all && !this.dom)?1:0; 
    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
 
    this.ns4=(document.layers && !this.dom)?1:0; 
    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
    return this 
} 
bw=new verifyCompatibleBrowser() 
 
var speed=50  
var loop, timer 
function ConstructObject(obj,nest){ 
    nest=(!nest) ? '':'document.'+nest+'.' 
    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
    this.up=MoveAreaUp;this.down=MoveAreaDown; 
    this.MoveArea=MoveArea; this.x; this.y; 
    this.obj = obj + "Object" 
    eval(this.obj + "=this") 
    return this 
} 


function MoveArea(x,y){ 
    this.x=x;this.y=y 
    this.css.left=this.x 
    this.css.top=this.y 
} 

function MoveAreaDown(move){ 
	if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
	} 
} 


function MoveAreaUp(move){ 
	if(this.y<0){ 
    this.MoveArea(0,this.y-move) 
    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
	} 
} 
 

function PerformScroll(speed){ 
	if(initialised){ 
		loop=true; 
		if(speed>0) objScroller.down(speed) 
		else objScroller.up(speed)
	} 
} 
 

function CeaseScroll(){ 
    loop=false 
    if(timer) clearTimeout(timer) 
} 
var initialised; 
function InitialiseHomeScroll(){ 
    objContainer=new ConstructObject('container') 
    objScroller=new ConstructObject('content') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true;
	// 
} 

function InitialiseInnerScroll(){ 
    objContainer=new ConstructObject('innerContainer') 
    objScroller=new ConstructObject('innerContent') 
    objScroller.MoveArea(0,0) 
    objContainer.css.visibility='visible' 
    initialised=true;
	// 
} 

function resaltarBg(obj){
	getRef(obj).className = "bgGrey";
	//alert("hola")
}

function restaurarBg(obj){
	getRef(obj).className = "bgGreen";
}

function Show(id, mostrar) {
	id2 = id+"base";
	if (getRef(id).style.display == "none") {
		getRef(id).style.display = "";
	} 
	if (mostrar == 1) {
		getRef(id2).style.fontWeight = "bold";
	}
}

function Hide(id, mostrar) {
	id2 = id+"base";
	if (getRef(id).style.display == "") {
	getRef(id).style.display = "none";
	}
	if (mostrar == 1){
	getRef(id2).style.fontWeight = "normal";
	} 
}

function abrirPopup(imagen, directorio) {
	cadena = "imagen="+imagen+"&directorio="+directorio;
	//alert(cadena);
	window.open('../noticias/ver_imagen.asp.19.html'+cadena, 'imagen', 'width=480, height= 480')
}

function abrirPopupPromocion(imagen, directorio) {
	cadena = "imagen="+imagen+"&directorio="+directorio;
	//alert(cadena);
	window.open('../promociones/ver_imagen.asp.20.html'+cadena, 'imagen', 'width=480, height= 480')
}
//Muestra los submenu de las distintas provincias del entorno
function mostrarSubmenu(ciudad){
	div_albacete=getRef('albacete');
	div_alicante=getRef('alicante');
	div_almeria=getRef('almeria');
	switch(ciudad){
		case 'albacete':
			div_albacete.style.display="";
			div_alicante.style.display="none";
			div_almeria.style.display="none";
		break;
		case 'alicante':
			div_albacete.style.display="none";
			div_alicante.style.display="";
			div_almeria.style.display="none";
		break;
		case 'almeria':
			div_albacete.style.display="none";
			div_alicante.style.display="none";
			div_almeria.style.display="";
		break;
		default:
			alert('Error!! Entorno no reconocido.')
		break;
		
	}
}
function mostrarImagenPromocion(promocion){
	//Ocultamos todas las promociones
	ocultarImagenPromocion();
	//Mostramos la imagen de la promocion seleccionada
	getRef(promocion).style.display="";
}

function ocultarImagenPromocion(){
	//Ocultamos todas las imágenes
	getRef('laspalmeras').style.display="none";
	getRef('amarion3').style.display="none";
	getRef('penyarrubia').style.display="none";
	getRef('alcazar').style.display="none";
	getRef('albaicin').style.display="none";
	getRef('idella').style.display="none";
	getRef('idella2').style.display="none";
	getRef('mariana').style.display="none";
	getRef('meridian').style.display="none";
	getRef('urbamar').style.display="none";
}
//Amplia una imagen
function popup_promocion(imagen,w,h){
	var width;
	var height;
	var s=false;
	if(w>screen.width){
		width=screen.width;
		s=true;
	}else{
		width=w;
	}
	if(h>screen.height){
		height=screen.height;
		s=true;
	}else{
		height=h;
	}
	if(s==true){
		opciones="width="+width+",height="+height+",scrollbars=yes";	
	}else{
		opciones="width="+width+",height="+height+",scrollbars=no";	
	}
	window.open("http://www.grupourbasa.com/ver_imagen2.asp?imagen="+imagen, "imagen",opciones);
}
