function toggle(div_id)
{
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}

var popupOn = false;
var playOnClose = false;
function popupPosition(windowname, contantId)
{
	if (!popupOn) {
		return;
	}
	var blanket_height = $("#" + contantId).height();
	var window_width = $("#" + contantId).width();

	var blanket = $("#blanket");

	var popup = $("#"+windowname);
	var popupHeight = popup.height();
	var popupTop = (blanket_height - popupHeight) / 2;
	popup.css({"top" : + popupTop +'px'});

	var popupWidth = popup.width();
	var popupLeft = (window_width - popupWidth) / 2;
	popup.css({"left" : + popupLeft +'px'});	
}

function popup(windowname, contantId)
{
	popupOn = !popupOn;
	popupPosition(windowname, contantId);
	toggle('blanket');
	toggle(windowname);
}

function openClosePopup() {
	if (popupOn) {
		if (!incPlayer.popSeq.playing && playOnClose) {
			incPlayer.ctrlPlay();
			playOnClose = false;
		}
	} else if (incPlayer.popSeq.playing) {
		incPlayer.ctrlPlay();
		playOnClose = true;
	}
	popup('popUpDiv', 'content');
}
