// JavaScript Document

function showPopUp(o){
	if(navigator.userAgent.indexOf("Macintosh") != -1 && navigator.userAgent.indexOf("Firefox") != -1){
		var objInitEmbeds = document.getElementsByTagName("EMBED");	
		for(var i = 0;i < objInitEmbeds.length;i++){
			if(objInitEmbeds[i].className != "popupEmbed"){
				objInitEmbeds[i].style.visibility = "hidden";
			}
		}
	}
	
	var div = document.createElement("DIV");
	div.style.width = "100%";
	div.style.height = "100%";
	div.style.position = "absolute";
	div.style.top = "0px";
	div.style.left = "0px";
	div.style.zIndex = "10000";
	div.id = "popup_framework";
	
	var bg = document.createElement("DIV");
	bg.style.width = "100%";
	bg.style.height = "100%";
	bg.style.position = "absolute";
	bg.style.top = "0px";
	bg.style.left = "0px";
	bg.style.zIndex = "10000";
	if(!(navigator.userAgent.indexOf("Macintosh") != -1 && navigator.userAgent.indexOf("Firefox") != -1)){
		bg.style.backgroundColor = "#333333";
		bg.style.opacity="0.84";
		bg.style.filter="alpha(opacity=84)";
	}
	else{
		bg.style.backgroundImage="url(/images/lb_page_background.png)";	
	}

	div.appendChild(bg);
	
	var table = document.createElement("TABLE");
	table.style.width = "100%";
	table.style.height = "100%";
	table.border = 0;
	table.cellPadding = 0;
	table.cellSpacing = 0;
	table.style.position = "absolute";
	table.style.zIndex = "10000";
	
	if(window.innerHeight){
		table.style.display = "table";
	}
	else{
		table.style.display = "block";	
	}
	table.style.top = "0";
	table.style.left = "0";

	div.appendChild(table);
	
	var tr = document.createElement("TR");
	tr.style.width = "100%";
	tr.style.height = "100%";

	table.appendChild(tr);
	
	var td = document.createElement("TD");
	td.style.width = "100%";
	td.style.height = "100%";
	td.vAlign = "middle";
	td.style.verticalAlign = "middle";
	td.style.textAlign = "center";

	tr.appendChild(td);
	
	td.appendChild(o);
	
	document.getElementsByTagName("BODY")[0].appendChild(div);
	if(!window.innerHeight){
		if(document.getElementById("pop_video_player_bg")){
			document.getElementById("pop_video_player_bg").style.backgroundImage = "none";	
		}
		document.getElementById("popup_framework").innerHTML = document.getElementById("popup_framework").innerHTML;
	}

	var objEmbeds = document.getElementsByTagName("EMBED");
	for(var i=0; i < objEmbeds.length; i++){
		for(var j=0; j<objEmbeds[i].attributes.length; j++){
			if(objEmbeds[i].attributes[j].name == "wmode"){
				objEmbeds[i].attributes[j].value = "transparent";
			}
		}
	}

	document.getElementsByTagName("HTML")[0].style.overflow = "hidden";
	if(window.innerHeight){
		document.getElementsByTagName("BODY")[0].style.overflow = "hidden";
	}
	window.scrollTo(0,0);
	
	if(document.getElementById("txt_username")){
		document.getElementById("txt_username").focus();	
	}
}

function closePopup(){
	if(navigator.userAgent.indexOf("Macintosh") != -1 && navigator.userAgent.indexOf("Firefox") != -1){
		var objInitEmbeds = document.getElementsByTagName("EMBED");	
		for(var i = 0;i < objInitEmbeds.length;i++){
			if(objInitEmbeds[i].className != "popupEmbed"){
				objInitEmbeds[i].style.visibility = "visible";
			}
		}
	}

	var divs = document.getElementsByTagName("DIV");
	for(var i=0;i < divs.length;i++){
		if(divs[i].className == "delete_popup"){
			divs[i].style.display = "none";
		}
	}
	
	rmObj(document.getElementById("popup_framework"));
	
	document.getElementsByTagName("HTML")[0].style.overflow = "auto";
	if(window.innerHeight){
		document.getElementsByTagName("BODY")[0].style.overflow = "auto";
	}
	
	var objEmbeds = document.getElementsByTagName("EMBED");
	for(var i=0; i < objEmbeds.length; i++){
		for(var j=0; j<objEmbeds[i].attributes.length; j++){
			if(objEmbeds[i].attributes[j].name == "wmode"){
				objEmbeds[i].attributes[j].value = "window";
			}
		}
	}
}

function popupPage(url){
	global_php_getHTML("","",url,"popupPage");
}

function global_php_return(action, response){
	if(action == "popupPage"){
		if(response != 0 && response != false){
			showPopUp(response);
		}
	}
}

function global_php_getHTML(name, value, reference, action){
	var php_success = function(o){
		if(o.responseText !== undefined){
			var html = o.responseText;
			var objHTML = document.createElement("DIV");
			objHTML.innerHTML = html;
			global_php_return(action, objHTML);			
		}
		else{
			global_php_return(action, false);	
		}
	};

	var php_failure = function(o){
		global_php_return(action, false);
	};

	var php_cb = {
		success:php_success,
		failure:php_failure
	};
	
	var post_string = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	YAHOO.util.Connect.asyncRequest("POST",reference,php_cb,post_string);
}			