// ----------------------------------------------------------------
//    Copyright e-point.S.A.
// ----------------------------------------------------------------

var windows = {};
var UNDEF = window._undefined_;

function openPopUp(url, name, width, height) {
	var top  = (screen.height-height-40)/2;
	var left = (screen.width-width-10)/2;
	if(!windows[name] || windows[name].closed) {
		windows[name] = window.open (url, name, 'top='+top+',left='+left+',toolbar=no,directories=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height);
	} else
	{
		windows[name].document.location.href = url;
		windows[name].focus();
	}
}

function portalScreen(url) {
	var width  = 775;
	var height = 470;
	var top  = (screen.height-height-40)/2;
	var left = (screen.width-width-10)/2;
	var name = 'portalScreen';
	if(!windows[name] || windows[name].closed) {
		windows[name] = window.open(url, name, 'top='+top+',left='+left+',width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');
	} else
	{
		windows[name].document.location.href = url;
		windows[name].focus();
	}
}

function popupScreen(url) {
	var width  = 535;
	var height = 550;
	var top  = (screen.height-height-40)/2;
	var left = (screen.width-width-10)/2;
	var name = 'popupScreen';
	if(!windows[name] || windows[name].closed) {
		windows[name] = window.open(url, name, 'top='+top+',left='+left+',width='+width+',height='+height+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
	} else
	{
		windows[name].document.location.href = url;
		windows[name].focus();
	}
}


var stopBubble = false;
function resetBubble() {
	stopBubble = false;
	if (window.event) 
		window.event.cancelBubble = false
}

/** 
Opens popup window with print-ready content. Checks #page_print for width.
@author "viper"
@returns false
*/
function printPopUp(url, contentWide) {
	if (!stopBubble) {
		stopBubble = true;
		var dummy = document.createElement('div');
		if (contentWide) { 
			dummy.className = "pageWidePrintDummyForJS";
			wh = 500;
		} else {
			dummy.className = "pagePrintDummyForJS";
			wh = 400;
		}
		dummy.innerHTML = '=&nbsp;=';
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(dummy);
		var dummy = body.getElementsByTagName('div');
		for (var i=0; i<dummy.length; i++) {
			if (dummy[i].className == "pagePrintDummyForJS" || dummy[i].className == "pageWidePrintDummyForJS") {
				dummy = dummy[i]
				break;
			}
		}
		w = dummy.offsetWidth;
		if (!w)
			w = '600';
		w = parseInt(w)
		
		if (navigator.userAgent.indexOf('Gecko'))
			w += 16;
		if (navigator.userAgent.indexOf('MSIE'))
			w += 1;
		
		body.removeChild(dummy);
		
		if (window.event) 
			window.event.cancelBubble = true
		
		window.setTimeout("resetBubble()", 3000);	
		
		window.open(url, 'print', 'width='+w+',height='+wh+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
		return false;
	}
	return false;
}