// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

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";
			}
		}
	}
	
	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 = "#314860";
		bg.style.opacity="0.75";
		bg.style.filter="alpha(opacity=75)";
	}
	else{
		bg.style.backgroundImage="url(/images/video-player-lb/lb_page_background.png)";	
	}*/

	//div.appendChild(bg);
	div.appendChild(o);
	
	document.getElementsByTagName("BODY")[0].appendChild(div);
	
	/*document.getElementsByTagName("HTML")[0].style.overflow = "hidden";
	if(window.innerHeight){
		document.getElementsByTagName("BODY")[0].style.overflow = "hidden";
	}*/
	window.scrollTo(0,0);
}

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 track(url){
	pageTracker._trackPageview(url);
}

function clearSubmenu(subMenu){
	
	if(!window.innerHeight){
		var subMenus = subMenu.getElementsByTagName("UL");
		for(var i = 0;i < subMenus.length;i++){
			subMenus[i].style.display = "none";
		}
	}
	
	var parent_node = subMenu.parentNode;

	while(parent_node.tagName != "LI") {
		parent_node = parent_node.parentNode;		
	}
	var target_element = parent_node.getElementsByTagName("A")[0];
	//alert(target_element.className., "current");
	if(target_element.className.indexOf("current") != -1){
		target_element.className = "current title";
	}
	else{
		
		target_element.className = "title";
		
	}

	
}

function showSubmenu(subMenu){
	if(!window.innerHeight){
		var subMenus = subMenu.getElementsByTagName("UL");
		for(var i = 0;i < subMenus.length;i++){
			subMenus[i].style.display = "block";
		}
	}
	var parent_node = subMenu.parentNode;

	while(parent_node.tagName != "LI") {
		parent_node = parent_node.parentNode;		
	}
	
	var target_element = parent_node.getElementsByTagName("A")[0];
	
	target_element.className += " a_hover";
	
}