/*
depende de rmt.js
*/
var popContent = null;
document.writeln('<div id="popup" style="display:none;"></div>');

function wedge(event){ 
	return false 
} 
function showPopup(totWidth, l){
	//Effect.Appear('popup');
	if(popContent != null){		
		popContent.style.display = 'block';
		popContent.style.width = totWidth+'px';
		popContent.style.left = l+'px';
		
  		if(navigator.appVersion.indexOf("MSIE")!= -1){
    		var temp = navigator.appVersion.split("MSIE");
    		var versao = parseFloat(temp[1]);	
    	}
    	// Se for IE 6 ou mais antigo :|
    	if(versao<=6){
			if(document.compatMode=="CSS1Compat"){
				popContent.style.top = document.documentElement.scrollTop+100+"px"
			}else{
				popContent.style.top = body.scrollTop+100+"px"
			}
		}else{
			popContent.style.top = '100px';
		}
		

/*
		if(document.all){
			popContent.style.top = 'expression(document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+100+"px" : body.scrollTop+100+"px");';
		}
				*/
	}
}
function closePopup(){
	//Effect.Fade('popup');
	Effect.Shrink('popup');
	try{
    setTimeout("popupOnClose()",2000) ;
	}catch(err){}
}

function makeDraggable(){
new Draggable('popup', { 
	starteffect: false, endeffect: false, 
	onStart: function(){ 
		if (document.all){ 
			Event.observe(document.body, "drag", wedge, false); 
			Event.observe(document.body, "selectstart", wedge, false); 
		} 
	}, 
	revert: function(){ 
		if (document.all){ 
			Event.stopObserving(document.body, "drag", wedge, false); 
			Event.stopObserving(document.body, "selectstart", wedge, false); 
		} 
	} 
})
}

function popup(src, w, h, title){
	var totWidth = w + 14;
	var l = Math.round((screen.width / 2) - (totWidth / 2));
	cursorWait()
	new Ajax.Request('/popup.php?src='+ src + '&w='+w+'&h='+h+'&title='+title, {
		onSuccess: function(transport) {
			cursorNormal();
			popContent = document.getElementById('popup');
			if(popContent != null){			
				popContent.innerHTML = transport.responseText;
				showPopup(totWidth, l);
				makeDraggable();
			}
		},
		onFailure: function(transport) {
			cursorNormal();
		}
	});		
}