﻿function getScrollTop(){
    if(typeof pageYOffset!= 'undefined'){
        //most browsers
        return pageYOffset;
    }
    else{
        var B= document.body; //IE 'quirks'
        var D= document.documentElement; //IE with doctype
        D= (D.clientHeight)? D: B;
        return D.scrollTop;
    }
}


var ns4 = (document.layers)? true:false
var ie4 = (document.all)? true:false
var ns6 = (document.getElementById && !document.all) ? true: false;
var coorX, coorY, iniX, iniY;

if (ns6) document.addEventListener("mousemove", mouseMove, true)
if (ns4) {document.captureEvents(Event.MOUSEMOVE); document.mousemove = mouseMove;}

function mouseMove(e)
{
if (ns4||ns6) {coorX = e.pageX; coorY = e.pageY;}
if (ie4) {coorX = event.x; coorY = event.y; alert(event.x)}
return true;
}


function imprSelec(nombre) {  
	var ficha = document.getElementById(nombre);
	var ventimp = window.open(' ', 'popimpr');
	ventimp.document.write( ficha.innerHTML );
	ventimp.document.close();
	ventimp.print( );
	window.close();
	ventimp.close();  
} 
function f_trimmer(thisstring) {
	while(thisstring.charAt(0)==" ") {
		thisstring=thisstring.substring(1,thisstring.length);
	}
	return thisstring;
}
function VerficarForm(formulario_id, posicion_campo, alerta){
	var res = true;
	if (f_trimmer(document.forms[formulario_id].elements[posicion_campo].value)=="") {
		alert(alerta);
		document.forms[formulario_id].elements[posicion_campo].focus();
		res=false
	}
	return res;
}
function verNota() {
	window.open("legal.asp",'Legal','width=900, height=600, channelmode=no, directories=no, fullscreen=no, location=0, left=0, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=0, top=0');
}
function enviarAmigo() {
	window.open("tellafriend.asp",'Recomendar','width=400, height=400, channelmode=no, directories=no, fullscreen=no, location=0, left=0, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=0, top=0');
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function TooltipVerTodos(localn,nombre,colorfondo,plantan) {
    return "<div class='c_globo_big'><p style='background:"+colorfondo+"'>&nbsp;</p><p style='font-size:12px'><br>Local nº: "+localn+" - Planta "+plantan+"</p><p style='font-size:12px'>"+nombre+"</p></div>";
}
var h;
function parar2()
{
	clearTimeout(h);
}
function izquierda_derecha(dir,capa)
{
	if (dir==1)
	{
		d=document.getElementById(capa);
		d.scrollLeft=d.scrollLeft-1;
		
	}
	else
	{
		d=document.getElementById(capa);
		d.scrollLeft=d.scrollLeft+1;

	}
	h=setTimeout("izquierda_derecha("+dir+",'"+capa+"')",1);
}
function showLocal(id,ver) {
	var allHTMLTags=document.getElementsByTagName("*");
	for (i=0; i<allHTMLTags.length; i++) {
		if (allHTMLTags[i].className=="FichaLocal") {
			if (ver==1) {
				if (allHTMLTags[i].getAttribute("id") == "FichaLocal"+id) allHTMLTags[i].style.visibility="visible";
				else allHTMLTags[i].style.visibility="hidden";
			} else allHTMLTags[i].style.visibility="hidden";
		}
	}
}

var sumo=0;
function MM_preloadImages() { //v3.0
	var d=document;
	if(d.images){
		if(!d.MM_p) {
			d.MM_p=new Array();
			alert("nuevo vector");
		}
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		alert("argumentos->"+a.length);
		for(i=0; i<a.length; i++) {
			if (a[i].indexOf("#")!=0){ 
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
				a[i].onLoad=sumo++;
				
				//alert(j+"---"+d.MM_p.length);
			}
			//alert(sumo);
		}
		if (sumo == a.length) { alert("fgin de carga"); document.getElementById("mapa").style.visibility="visible"; }
	}
	
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3) {
		
		if ((x=MM_findObj(a[i]))!=null){
			document.MM_sr[j++]=x;
			if(!x.oSrc) x.oSrc=x.src;
			x.src=a[i+2];
		}
	}
}

// Función para mostrar el menu desplegable
var t;

function activar()
{
	clearTimeout(t);
}

/*function mostrar_equipo()
{
	var capa = document.getElementById('equipo');
    capa.style.visibility = "visible";
}*/
function mostrar_actividades() {
	document.getElementById('actividades_blog').style.visibility = "visible";
}
function mostrar_servicios()
{
	var capa = document.getElementById('servicios');
    capa.style.visibility = "visible";
}

function mostrar_productos()
{
	var capa = document.getElementById('productos');
    capa.style.visibility = "visible";
}

function mostrar_noticias()
{
	var capa = document.getElementById('noticias');
    capa.style.visibility = "visible";
}
function mostrar_faq()
{
	var capa = document.getElementById('faq');
    capa.style.visibility = "visible";
}

function ocultar_submenus()
{
	/*var capa1 = document.getElementById('equipo');
    capa1.style.visibility = "hidden";*/
	var capa2 = document.getElementById('actividades_blog');
    capa2.style.visibility = "hidden";/*
	var capa3 = document.getElementById('productos');
    capa3.style.visibility = "hidden";
	var capa4 = document.getElementById('noticias');
    capa4.style.visibility = "hidden";
	var capa5 = document.getElementById('faq');
    capa5.style.visibility = "hidden";*/
}
function retardo()
{
	t=setTimeout('ocultar_submenus()',100);
}

// fin del menú desplegable

//popup's imagenes

function PopUp(img){
	foto1= new Image();
	foto1.src=(img);
	Control(img);
}

function Control(img){
	if((foto1.width!=0)&&(foto1.height!=0)){
		verFoto(img);
	}
	else{
		funcion="Control('"+img+"')";
		intervalo=setTimeout(funcion,20);
	}
}

function verFoto(img){
	ancho=foto1.width+20;
	alto=foto1.height+20;
	anchoPantalla=screen.width;
	altoPantalla=screen.height;
	cadena="width="+ancho+",height="+alto+",left="+(anchoPantalla-foto1.width)/2+",top="+(altoPantalla-foto1.height)/2;
	ventana=window.open(img,"",cadena);
	ventana.document.writeln ('<html>');
	ventana.document.writeln ('<head>'); 
    ventana.document.writeln ('<title></title>');
	ventana.document.writeln ('</head>');
	ventana.document.writeln ('<body>');
	ventana.document.writeln ('<img src="'+img+'" style="border:2px #e5e5e5 solid;";');
	ventana.document.writeln ('</body>');
	ventana.document.writeln ('</html>');
}
function frmBuscarInside_cambiarAction() {
	if (document.frmBuscarInside.buscaren.value=="Tiendas") document.frmBuscarInside.action="buscador.asp";
	else if (document.frmBuscarInside.buscaren.value=="Actividades") {
		document.frmBuscarInside.action="blog/tags.asp";
	} else document.frmBuscarInside.action="whatsnew.asp";
}
