function createPopupLayer(title, filename, mode) {
	var body = document.getElementsByTagName('body')[0];
	
	var documentHeight = $(document).height();
	var documentWidth = $(document).width();

	var bg = document.createElement('div');
	bg.setAttribute('id', 'disabledBg');
	bg.style.height = documentHeight + 'px';

	var popupContainer = document.createElement('div');
	popupContainer.setAttribute('id', 'popupcontainer');

	var popupContent = document.createElement('div');
	popupContent.setAttribute('id', 'popupcontent');

	var popupTitle = document.createElement('div');
	popupTitle.setAttribute('id', 'popuptitle');
	popupTitle.innerHTML = title;

	var spacer = document.createElement('div');
	spacer.setAttribute('class', 'spacer');

	var popupClose = document.createElement('a');
	popupClose.setAttribute('id', 'popupcloseglyph');
	popupClose.onclick = function() { destroyPopupLayer() };

	var popupBody = document.createElement('div');
	popupBody.setAttribute('id', 'popupbody');
	var iframe;
	if(mode == 'iframe') {
		iframe = document.createElement('iframe');
		iframe.src = filename;
		iframe.scrolling = 'auto';
		iframe.frameborder = '0';
		iframe.style.width = '100%';
		iframe.style.height = '100%';
		iframe.style.border = 'none';
		popupBody.appendChild(iframe);
		//popupBody,innerHMTL = '<iframe src="'+filename+'" frameborder="0" scrolling="auto" style="height:100%;width:100%;"></iframe>';
	} else {
		//popupBody.innerHTML = '<div id="flashcontent">'+filename+'</div>';
	}

	popupContent.appendChild(popupClose);
	popupContent.appendChild(popupTitle);
	popupContent.appendChild(spacer);
	popupContent.appendChild(popupBody);
	popupContainer.appendChild(popupContent);
	var windowHeight = $(window).height();
	var windowWidth = $(window).width();
	var top = Math.max(0, (windowHeight / 2) - (600 / 2));
	var left = Math.max(0, (windowWidth / 2) - (800 / 2));
	popupContainer.style.top = top + 'px';
	popupContainer.style.left = left + 'px';

	body.appendChild(bg);
	body.appendChild(popupContainer);
	var ch = $(popupContainer).height();
	var th = $(popupTitle).height();
	iframe.style.height = (ch - th - 8)+'px';
	
//	var so = new SWFObject("NoPlayer4.swf", "flash", "570", "486", "8", "#303030");
//	so.addVariable("xml", "settings.php?filename="+filename);
//	so.write("flashcontent");
}

function openFrame(src, title) {
	createPopupLayer(title, src, 'iframe');
	try{hideMenu();}catch(ex){}
	return false;
}

function destroyPopupLayer() {
	var body = document.getElementsByTagName('body')[0];
	var login = document.getElementById('popupcontainer');
	if (login) {
		body.removeChild(login);
	}

	var bg = document.getElementById('disabledBg');
	if (bg) {
		body.removeChild(bg);
	}
}
function evalScriptTags(elem) {
	try{
		var arr = elem.getElementsByTagName('SCRIPT');
		for(var i = 0; i < arr.length; i++) {
			try{eval(arr[i].innerHTML);}catch(Ex){}
		}
	}catch(Ex){}
}
