// FUNCIONES DE JQUERY

$(document).ready(function() {
		
		// Preload all rollovers
		$("#mainMenu img, li.casas img, p.tuCasa img, #siguiente img, #anterior img, a#mas_info img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.gif$/ig,"_over.gif");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#mainMenu li a, li.casas a, p.tuCasa a, #siguiente, #anterior, a#mas_info").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.gif$/ig,"_over.gif"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#mainMenu li a, li.casas a, p.tuCasa a, #siguiente, #anterior, a#mas_info").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});
				 
		  $(".opacify").hover(
			function () {
			  $(this).fadeTo("fast", 0.5);
			},
			function () {
			  $(this).fadeTo("fast", 1);
			}
		  );			
		  
		  // Preload all rollovers
		$("#tarjetaRegalo img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"_over.jpg");
			$("<img>").attr("src", rollON);
		});
		
		// Navigation rollovers
		$("#tarjetaRegalo a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);
			
			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"_over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}
			
		});
		$("#tarjetaRegalo a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});				
});

function email(direccion)
{
	var v_direccion = direccion.replace("A","@");
	document.location.href = 'mailto:'+v_direccion;
}

function lanzacentrado(url, nombre, atributos, ancho, alto)
{
            if(ancho>screen.availWidth) ancho=screen.availWidth;
            if(alto>screen.availHeight) alto=screen.availHeight;
                var str = ",height=" + alto + ",innerHeight=" + alto;
            str += ",width=" + ancho + ",innerWidth=" + ancho;
            if (window.screen)
            {
                        var ah = screen.availHeight - 30;
                        var aw = screen.availWidth - 10;
                        var xc = (aw - ancho) / 2;
                        var yc = (ah - alto) / 2;
                        str += ",left=" + xc + ",screenX=" + xc;
                        str += ",top=" + yc + ",screenY=" + yc;
//                      str += ",left=0,screenX=0";
//                      str += ",top=0,screenY=0";
            }
            atributos=atributos + str;
         // alert("Atributos -->"+atributos);
            popventana = window.open(url, nombre, atributos);
            popventana.focus();
}

function abrirImagen(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}

function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    verFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}

function verFoto(img){	
	anchoVentana = foto1.width+54;
	altoVentana = foto1.height+88;
	popup("/secciones/clubs/ver_imagen.asp?src=" + img,anchoVentana,altoVentana,'scrollbars=0');
}


function popup(url,ancho,alto,props)
{ 
            props = "status=0,scrollbars=0";
            lanzacentrado(url, "popup", props, ancho, alto);
}

function popupSinScroll(url,alto,ancho,tipo)
{ 

            props = "status=0,scrollbars=0";
            lanzacentrado(url, "popup", props, ancho, alto);
}
