// VARIABLE ESTADO
//0 Popup desactivado
//1 Popup activado
var popupStatus = 0;  

// Activar Popup con JQuery
function loadPopup(){  
	// Activa el Popup solo si su variable de estado esta desactivada
	if(popupStatus==0){  
		$("#backgroundPopup").css({  
			"opacity": "0.7"  
		});  
		$("#backgroundPopup").fadeIn("slow");  
		$("#popupContact").fadeIn("slow");  
		popupStatus = 1;  
	}  
}  

// Desactivar Popup con JQuery
function disablePopup(){
	// Desactiva el Popup solo si su variable de estado esta activada
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}

// Centramos el Popup 
function centerPopup(){  
	// Obtenemos datos ventana cliente
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#popupContact").height();  
	var popupWidth = $("#popupContact").width();  
	
	// Centramos Popup
	$("#popupContact").css({  
		"position": "absolute",  
		"top": windowHeight/2-popupHeight/2,  
		"left": windowWidth/2-popupWidth/2, 
	});  

	// Hack para IE6
	$("#backgroundPopup").css({  
		"height": windowHeight  
	});  
 
}

// Función de carga Mostrar
function mostrar(){
	centerPopup();  
	loadPopup();  
}  

// Función de carga Ocultar
function ocultar(){
	disablePopup();  
}

$(document).ready(function(){  
	// Temporizador para mostrar Popup
	setTimeout("mostrar()",1500);
	
	// Temporizador para ocultar Popup
	setTimeout("ocultar()",5000);
}); 

 





























//function mostrar() { 
   //$("#pop").fadeIn('slow'); 
   //$("#pop").css({  
	//	"opacity": "0.7"  
	//});  
	
//	centerPopup();
//	loadPopup();
//} //checkHover

//function ocultar() {
   //$("#pop").fadeOut('slow'); 
  // disablePopup();  
//}


/*function centerPopup(){  
	//request data for centering  
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight;  
	var popupHeight = $("#pop").height();  
	var popupWidth = $("#pop").width();  

	//centering  
	$("#pop").css({  
		"position": "absolute",  
		"top": windowHeight/2-popupHeight/2,  
		"left": windowWidth/2-popupWidth/2  
	});  
	//only need force for IE6  
	$("#backgroundPopup").css({  
		"height": windowHeight  
	});  
}  
*/
/*
//loading popup with jQuery magic!  
function loadPopup(){  
	//loads popup only if it is disabled  
    if(popupStatus==0){  
		$("#backgroundPopup").css({  
			"opacity": "0.7"  
		});  
		$("#backgroundPopup").fadeIn("slow");  
		$("#pop").fadeIn("slow");  
		popupStatus = 1;  
    }  
}  
*/
/*
//disabling popup with jQuery magic!  
function disablePopup(){  
	//disables popup only if it is enabled  
    if(popupStatus==1){  
		$("#backgroundPopup").fadeOut("slow");  
		$("#pop").fadeOut("slow");  
		popupStatus = 0;  
	}  
}  
*/


/*
$(document).ready(function (){
   //Conseguir valores de la img 
   var img_w = $("#pop img").width() + 10; 
   var img_h = $("#pop img").height() + 28; 
    
   //Darle el alto y ancho 
   $("#pop").css('width', img_w + 'px'); 
   $("#pop").css('height', img_h + 'px'); 
    
   //Esconder el popup 
   $("#pop").hide();
   
   //Consigue valores de la ventana del navegador 
   //var w = $(this).width(); 
   //var h = $(this).height(); 
   //var w = document.documentElement.clientWidth;  
   //var h = document.documentElement.clientHeight;  
   
   
    
   //Centra el popup    
   //w = (w/2) - (img_w/2); 
   //h = (h/2) - (img_h/2); 
   
   //centerPopup();
   //loadPopup();
   //$("#pop").css("left",w + "px"); 
   //$("#pop").css("top",h + "px");
   
   //temporizador, para que no aparezca de golpe 
   setTimeout("mostrar()",1500);

   //temporizador, para cerrar el popup
   setTimeout("ocultar()",4000);
   
   //Función para cerrar el popup manualmente
   //$("#pop").click(function (){ 
      $(this).fadeOut('slow'); 
   });

});   */
