/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
// OK DUDE
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

function getDocHeight() {

    var D = document;
    return Math.max(

        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),

        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),

        Math.max(D.body.clientHeight, D.documentElement.clientHeight)

    );
}




//loading popup with jQuery magic!
function loadPopup(){
	
	
	alert("cargando popup");
	
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	//if(popupStatus==1){
		
		alert("desactivando popup");
		
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		$("container_popup").fadeOut("slow");
		
		//popupStatus = 0;
	//}

        

}

function getScrollY() {

    var scrollY = 0;

    if( typeof( window.pageYOffset)  == 'number ') {

        // Netscape
        scrollY = window.pageYOffset;

    } else if( document.body &&  document.body.scrollTop ) {

        // DOM
        scrollY = document.body.scrollTop;

    } else if( document.documentElement && document.documentElement.scrollTop ) {

        // IE6
        scrollY = document.documentElement.scrollTop;
    }

    return scrollY;

}

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

        //var topOffset = document.body.parentNode.scrollTop;
        var topOffset = getScrollY();

	//centering
	$("#popupContact").css({
		"position": "absolute",
		"top": (windowHeight/2-popupHeight/2) + topOffset,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

        var docHeight = getDocHeight();

	$("#backgroundPopup").css({
		"height": docHeight
	});

}

function cargarIFrameLista() {

    var iframels = document.getElementById("framelscompras");

    //var selectedScreen = document.location.toString();

    //alert(selectedScreen);

    //var pathSplit = selectedScreen.split("/");
    

    var pathDef = "http://www.asemasa.es/content_change_popup.html"


    iframels.src = pathDef;


}
