///////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTION FOR CREATING POPUPS ///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
var pupupBlockedMessage='You are using popup blocker software. This application needs to open a window ... please disable your popup blocker.';

function newPopup(popupHref, popupWidth, popupHeight, props) {

	///////////////////////////////////////////////////////////////////////////////////////////////////
	// SET DEFAULT POPUP PROPERTIES ///////////////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////////////////////////////

	if (!popupWidth)
		popupWidth=500;
	if (!popupHeight)
		popupHeight=300;

	popupStatus="no";
	popupResizable="no";
	popupScroll="no";
	popupLocation="no";
	popupMenubar="no";
	popupModal="no";

	if (props) {
		// popup status
		if (props.status) popupStatus='yes';
		// resizable window
		if (props.resizable) popupResizable='yes';
		// scrollbar
		if (props.scrollbars) popupScroll='yes';
		// location
		if (props.location) popupLocation='yes';
		// menubar
		if (props.menuBar) popupMenubar='yes';
		// modal window
		if (props.modal) popupModal='yes';
	}

	// position window
	popupLeft=Math.abs(screen.width-popupWidth)/2;
	popupTop=Math.abs(screen.height-popupHeight)/2;


	//////////////////////////////////////////////////////////////////////////////////////////////////////
	// SET REAL WINDOW PROPERTIES ////////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////////

	// handle properties
	popupProps="width=" + popupWidth + ", height=" + popupHeight;
	popupProps+=", status="+popupStatus+", resizable="+popupResizable+", scrollbars="+popupScroll+", location="+popupLocation+", menubar="+popupMenubar;
	popupProps+=", top="+popupTop+", left="+popupLeft;
	popupProps+=", modal="+popupModal;

	// handle window name
	if (!props.name) {
		thisPopupUniqueId=Math.random().toString();
		thisPos=thisPopupUniqueId.indexOf(".");
		randomNumber=thisPopupUniqueId.substr(thisPos+1);

		windowName="newPopupWindow_"+randomNumber;
	}
	else
		windowName=props.name;

	//////////////////////////////////////////////////////////////////////////////////////////////////////
	// CREATE NEW WINDOW (MODAL - if the case) ///////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////////////////////////////////////
	if (window.showModalDialog && popupModal=='yes') {
		thisPopup=window.showModalDialog(popupHref, windowName, "dialogWidth:"+popupWidth+"px; dialogHeight:"+popupHeight+"px");

		if (thisPopup==null || typeof(thisPopup)=="undefined") {
			alert(pupupBlockedMessage)
		}
	}
	else {
		thisPopup=window.open(popupHref, windowName, popupProps);
		if (thisPopup==null || typeof(thisPopup)=="undefined") {
			alert(pupupBlockedMessage)
		}else{
			thisPopup.focus();

			if (!thisPopup.opener)
			thisPopup.opener = self;
		}
	}

	return thisPopup;

}


function openLiveWindow(){
	newPopup(
		'index.php?meniu=popup',
		800,600,
		{
			name:'listenLivePopup',
			scrollbars:true
		}
	);
}


