	
	//////////////////////////////////////////////////////////////////
	//
	//	INTERSTITIAL v0.1 - (c) GOWEB 2009
	//
	//	Requere: prototypejs >= 1.6.0.2
	//	interstitial ( width , height );
	//	
	//	Uso: 
	//		- Conteudo da janela devera ter o id "goweb_interstitial"
	//		- Link: onclick="interstitial(500,200);"
	//		- Loading: <body onload="interstitial(500,200);">
	//
	//////////////////////////////////////////////////////////////////
	
	var gogogointerstitial=0;
	
	function fechar_interstitial(){
		$('fullscreen').style.display = 'none';
		$('goweb_interstitial').style.display = 'none';
	}
	
	function detect_scroll(){
		actualizacao = setInterval("update_janela()",300);
		clearInterval(actualizacao);
	}
	
	function getPageSizeWithScroll(){
		if (window.innerHeight && window.scrollMaxY) {// Firefox
			yWithScroll = window.innerHeight + window.scrollMaxY;
			xWithScroll = window.innerWidth + window.scrollMaxX;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			yWithScroll = document.body.scrollHeight;
			xWithScroll = document.body.scrollWidth;
		} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
			yWithScroll = document.body.offsetHeight;
			xWithScroll = document.body.offsetWidth;
		}
		arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
		return arrayPageSizeWithScroll;
	}
	
	function update_fullscreen(){
		var tamanho_conteudo = getPageSizeWithScroll();
		var tamanho_janela = getWindowSize();
		
		if(tamanho_conteudo[1]<300){
			tamanho_conteudo = getWindowSize();
		}
		
		$('fullscreen').style.height = tamanho_conteudo[1];
		if(Prototype.Browser.IE){
			$('fullscreen').style.width = tamanho_janela[0];
		}
	}
	
	function update_janela(){
		var tamanho = getWindowSize();
		var top = (tamanho[1]/2)-($('interstitial').offsetHeight/2);
		var left = (tamanho[0]/2)-($('interstitial').offsetWidth/2);
		
		if(Prototype.Browser.IE){
			var mais = document.body.scrollTop;
		}else{
			var mais = window.pageYOffset;
		}
		
		$('interstitial').style.top = top+mais + 'px';
		$('interstitial').style.left = left + 'px';
	}
	
	function getWindowSize(){
		var myWidth = 0, myHeight = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			myWidth = window.innerWidth;
			myHeight = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			myWidth = document.documentElement.clientWidth;
			myHeight = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			myWidth = document.body.clientWidth;
			myHeight = document.body.clientHeight;
		}
		arrayWindowSize = new Array(myWidth,myHeight);
		return arrayWindowSize;
	}
	
	function fullscreen(){
		var div = document.createElement('div');
		div.id = 'fullscreen';
		
		if (document.body.firstChild){
		  document.body.insertBefore(div, document.body.firstChild);
		}else{
		  document.body.appendChild(div);
		}
		
		$('fullscreen').style.position = "absolute";
		$('fullscreen').style.top = "0";
		$('fullscreen').style.left = "0";
		$('fullscreen').style.width = "100%";
		var tamanho_conteudo = getPageSizeWithScroll();
		
		if(tamanho_conteudo[1]<300){
			tamanho_conteudo = getWindowSize();
		}
		$('fullscreen').style.height = tamanho_conteudo[1] + "px";
		$('fullscreen').style.zIndex = "500";
		update_fullscreen();
	}
	
	function janela(w,h){
		//$('goweb_interstitial').style.display = '';
		$('goweb_interstitial').show();
		$('goweb_interstitial').style.zIndex = "501";
		/*
		var interstitial = document.createElement('div');
		interstitial.id = 'interstitial';
		if (document.body.firstChild){
		  document.body.insertBefore(interstitial, document.body.firstChild);
		}else{
		  document.body.appendChild(interstitial);
		}
		
		if($('goweb_interstitial')){
			var goweb_interstitial = document.getElementById('goweb_interstitial');
			var novo = goweb_interstitial.cloneNode(true);
			novo.setAttribute('id', 'goweb_interstitial');
			var copia_para = document.getElementById('interstitial');
			copia_para.appendChild(novo);
			goweb_interstitial.parentNode.removeChild(goweb_interstitial);
			$('goweb_interstitial').style.visibility = 'visible';
		}else{
			alert('É necessário criar a DIV com o id="goweb_interstitial" para o funcionamento do script!!!');
		}
		
		$('interstitial').style.position = "absolute";
		$('interstitial').style.zIndex = "501";
		$('interstitial').style.width = w + "px";
		$('interstitial').style.height = h + "px";
		//$('interstitial').style.overflow = "auto";
		
		var tamanho = getWindowSize();
		var t = (tamanho[1]/2)-(h/2);
		var l = (tamanho[0]/2)-(w/2);
		
		$('interstitial').style.top = t + "px";
		$('interstitial').style.left = l + "px";
		*/
	}
	
	/**
	*	w = width (int)
	*	h = height (int)
	*/
	function interstitial(w,h){
		fullscreen();
		janela(w,h);
		detect_scroll();
		gogogointerstitial = 1;
		// A proxima linha envia o scroll para o topo da pagina. 
		// Corrigir no futuro para abrir a popup na posição do scroll.
		window.scrollTo(0,0);
	}
	
	onresize = function(){
		if(gogogointerstitial){
			update_fullscreen();
			//update_janela();
		}
	};
