// JavaScript Document

	function php_check(name, value, reference, action){
		var php_success = function(o){
			if(o.responseXML !== undefined){
				var objXML = o.responseXML.documentElement;
				var result = objXML.getElementsByTagName("result")[0].firstChild.nodeValue.trim();
				php_return(action, result);		
			}
			else{
				php_return(action, "failed");	
			}
		};

		var php_failure = function(o){
			php_return(action, "failed");
		};

		var php_cb = {
			success:php_success,
			failure:php_failure
		};
		
		var post_string = encodeURIComponent(name) + "=" + encodeURIComponent(value);
		if(post_string == "="){
			post_string = "";	
		}
		if(arguments[4]){
			post_string += arguments[4];	
		}

		YAHOO.util.Connect.asyncRequest("POST",reference,php_cb,post_string);
	}
	
	function php_get(name, value, reference, action){
		var php_success = function(o){
			if(o.responseXML !== undefined){
				var objXML = o.responseXML.documentElement;
				php_return(action, objXML);			
			}
			else{
				php_return(action, false);	
			}
		};

		var php_failure = function(o){
			php_return(action, false);
		};

		var php_cb = {
			success:php_success,
			failure:php_failure
		};
		
		var post_string = encodeURIComponent(name) + "=" + encodeURIComponent(value);
		if(post_string == "="){
			post_string = "";	
		}
		if(arguments[4]){
			post_string += arguments[4];	
		}
		YAHOO.util.Connect.asyncRequest("POST",reference,php_cb,post_string);
	}
	
	function 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;
				php_return(action, objHTML);			
			}
			else{
				php_return(action, false);	
			}
		};

		var php_failure = function(o){
			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);
	}	
	
	
	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);
	}	
	
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}

String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

String.prototype.trim = function() {
	return this.ltrim().rtrim();
};


function rmObj(myObj){
	if(myObj){
		if(myObj.hasChildNodes()){
			for(var i = 0;i < myObj.childNodes.length;i++){
				rmObj(myObj.childNodes[i]);
			}
		}
		myObj.parentNode.removeChild(myObj);
	}
}
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";
			}
		}
	}
		
	if(window.innerHeight + window.scrollMaxY){
		var page_height = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight){
		var page_height = document.body.scrollHeight;	
	}
	else{
		var page_height = document.body.offsetHeight + document.body.offsetTop;
	}
		
	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";
	
	document.getElementsByTagName("BODY")[0].style.width = "100%";
	var bg = document.createElement("DIV");
/*	if(!window.innerHeight){
		bg.style.width = document.getElementsByTagName("BODY")[0].offsetWidth + "px";	
	}
	else{*/
		bg.style.width = "100%";
//	}
	bg.style.height = page_height + "px";
	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 = "#000000";
		bg.style.opacity="0.80";
		bg.style.filter="alpha(opacity=80)";
	}
	else{
		bg.style.backgroundImage="url(/media/images/lb_page_background.png)";	
		//bg.style.backgroundColor = "#000033";
		//bg.style.opacity="0.84";
		//bg.style.filter="alpha(opacity=84)";
	}

	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;
	}
	
	//document.getElementsByTagName("HTML")[0].style.overflow = "hidden";
	if(window.innerHeight){
		//document.getElementsByTagName("BODY")[0].style.overflow = "hidden";
	}
	window.scrollTo(0,0);
	
	window.setTimeout(cleanPopup, 0);
}

var cleanPopup = function () { 
	var objEmbeds = document.getElementById("popup_framework").getElementsByTagName("EMBED");
	
	var myFlashVars = false;
	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";
			}
			if(objEmbeds[i].attributes[j].name.toLowerCase() == "flashvars" && objEmbeds[i].attributes[j].value){
				myFlashVars = objEmbeds[i].attributes[j].value;
			}
		}
	}

	if(myFlashVars && !window.innerHeight){
		var objParams = document.getElementsByTagName("PARAM");
		for(var i=0;i<objParams.length;i++){
			if(objParams[i].name.toLowerCase() == "flashvars"){
				objParams[i].value = myFlashVars;
			}
		}
	}
}

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);
		}
	}
}