var scrWidth = 0;
var scrHeight = 0;
var scrTotalHeight = 0;
var scrOfY = 0;

function GetWindowSize() {
    if (typeof (window.innerWidth) == 'number') {
        scrWidth = window.innerWidth;
        scrHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        scrWidth = document.documentElement.clientWidth;
        scrHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        scrWidth = document.body.clientWidth;
        scrHeight = document.body.clientHeight;
    }
    
    if (typeof (window.pageYOffset) == 'number') {
        scrOfY = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        scrOfY = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        scrOfY = document.documentElement.scrollTop;
    }
	
	if(navigator.appName.indexOf('Explorer')>0) {
		scrTotalHeight = jQuery('body').height();
	} else {
		scrTotalHeight = jQuery('html').height();
	}
	
	if(scrTotalHeight<scrHeight) {
		scrTotalHeight=scrHeight;
	}	
}

function popup(url) {
    GetWindowSize();
    if (url != "" ) {
        var popUpLeft = (scrWidth - 600) / 2;
        if (popUpLeft < 0) { popUpLeft = 0 }
        var popUpTop = ((scrHeight - 630) / 2) + scrOfY;
        if (popUpTop < 0) { popUpTop = 0 }

        jQuery('#overlaysurvey').css('height', scrTotalHeight + 'px').css('opacity', '0.75');        
        jQuery('#popupsurvey').css('top', popUpTop + 'px').css('left', popUpLeft + 'px');

        var currentIframe = jQuery('#popupsurvey iframe');
        var iframe = "";

        if (currentIframe.length > 0) {
            currentIframe[0].src = url;
        } else {
            iframe = document.createElement("IFRAME");
            iframe.src = url;
            iframe.height = "630px";
            iframe.width = "600px";
            iframe.scrolling = "no";
            iframe.allowTransparency = true;
            iframe.frameBorder = 0;
            jQuery('#popupsurvey').append(jQuery(iframe))
        }
        
        jQuery(iframe).load(function() {
			jQuery('#overlaysurvey, #popupsurvey').css('position', 'absolute');
			jQuery('#overlaysurvey,#popupsurvey').fadeIn("fast");
        });
    }
}


function resizePopUp() {
    GetWindowSize();
    var popUpLeft = (scrWidth - 600) / 2;
    if (popUpLeft < 0) { popUpLeft = 0 }
    var popUpTop = ((scrHeight - 630) / 2) + scrOfY;
    if (popUpTop < 0) { popUpTop = 0 }
    jQuery('#overlaysurvey').css('height', scrTotalHeight + 'px').css('opacity', '0.75');
    jQuery('#popupsurvey').css('top', popUpTop + 'px').css('left', popUpLeft + 'px');
}

function CloseOverlay() {
    jQuery('#overlaysurvey,#popupsurvey').fadeOut("fast");
}
