var baseurl = "http://x-tra.pax.ch";

function appPopup(url)
{
	var w = window.open(url,'App','width=950,height=750,resizable=yes,scrollbars=yes');
}

function appCustPopup(url, wid, hei)
{
	var w = window.open(url,'App', 'width='+wid+', height='+hei+',resizable=yes,scrollbars=yes');
}

function reportAJAXError(e)
{
	document.getElementById(e).innerHTML = 'error: can\'t load data...';
}

var DictionarySelectedLetter = "";

function switchDictionaryLanguage(obj)
{
	if(this.DictionarySelectedLetter.length > 0)
	{
		this.loadDictionary(this.DictionarySelectedLetter,$F('ddlSourceLanguage'),$F('ddlTargetLanguage'));
	}
}

function loadDictionary(letter,sourceLanguage,targetLanguage)
{
	this.DictionarySelectedLetter = letter;
	
	$('DictionaryResults').innerHTML = 'loading...';
	var requestUrl = baseurl + '/aj-dictionary.html?letter=' + letter + '&source=' + sourceLanguage + '&target=' + targetLanguage;
	var ajaxrequest = new Ajax.Updater({success: 'DictionaryResults'},requestUrl,{method: 'get', encoding: 'iso-8859-2', contentType: 'text/html',parameters: null, onFailure: reportAJAXError('DictionaryResults')});	
}

var visibleMenu = "";
var activeNavElement;

function showActiveNavElement(obj)
{
	activeNavElement = obj;
	obj.style.borderLeftColor = "#009349";
	obj.style.borderTopColor = "#009349";
	obj.style.borderBottomColor = "#009349";
	obj.style.borderRightColor = "#ffffff";
	obj.style.backgroundColor = "#ffffff";
	obj.style.borderStyle = 'solid';
	obj.style.padding = '0px';
	obj.style.borderWidth = '1px';
}

function hideActiveNavElement()
{
	if(activeNavElement)
	{
		var o = activeNavElement;
		o.style.borderStyle = 'none';
		o.style.backgroundColor = "transparent";
		o.style.padding = '1px';
		
		activeNavElement = null;
	}
}

function showSubNavigation(viewtreeid, obj)
{

	hideActiveNavElement();
	$('FooterPart').style.visibility = 'hidden';
	
	this.visibleMenu = 'nav_' + viewtreeid;
	
	var subNav = null;
	
	if(document.getElementById("SubNav"))
	{
		subNav = document.getElementById("SubNav");
	}
	else
	{
		subNav = document.createElement("div");
		subNav.id = "SubNav";
	}
	
	subNav.style.position = "absolute";
	subNav.style.display = "block";
	subNav.style.top = (obj.offsetTop ? obj.offsetTop : obj.x) - 6;
	subNav.innerHTML = "loading...";
	
	
	if(document.addEventListener)
	{
		subNav.addEventListener("mouseout",createNavTimeout,false);
		subNav.addEventListener("mouseover",removeNavTimeout, false);
	}
	else if(document.attachEvent)
	{
		subNav.attachEvent('onmouseout',createNavTimeout);
		subNav.attachEvent('onmouseover',removeNavTimeout);
	}
	
	
	var requestUrl = baseurl + '/aj-subnav.htm?lang=3&viewtreeid=' + viewtreeid;
	
	var Body = document.getElementById("Body");
	Body.appendChild(subNav);
	
	var ajax = new Ajax.Updater({success: 'SubNav'},requestUrl,{method: 'get', parameters: null, onFailure: reportAJAXError('SubNav')});	
	this.removeNavTimeout();
}

function createNavTimeout()
{
	if(window.navTimeout) clearTimeout(navTimeout);				
	navTimeout = setTimeout('hideSubNavigation()',2000);
}

function removeNavTimeout()
{
	if(window.navTimeout)
		clearTimeout(navTimeout);
}

function hideSubNavigation()
{
	if(document.getElementById("SubNav"))
	{
		document.getElementById("SubNav").style.display = 'none';
		document.getElementById("SubNav").innerHTML = "";
		
	}
	$('FooterPart').style.visibility = 'visible';
	hideActiveNavElement();
}

function showFormPanel()
{
	if ( !document.getElementById("InlineWindowHeader") )
	{
		//Create Header
		var header = document.createElement("div");
		header.id = "InlineWindowHeader";
		
		var closebtn = document.createElement("img");
		closebtn.src = "lay-btn-closelayer.gif";
		closebtn.onclick = function()
		{
			document.body.removeChild(inlineWindow);
			$('ContentPart').style.visibility = 'visible';
			$('FooterPart').style.visibility = 'visible';
		}
		
		header.appendChild(closebtn);
		
		var inlineWindow = document.createElement("div");
		inlineWindow.id = "InlineWindow";
		
		inlineWindow.appendChild(header);
		
		document.body.appendChild(inlineWindow);
		
		var formpanel = document.createElement("div");
		
		formpanel.setAttribute("id","PopupContent");
		
		var loadingImg = document.createElement("img");
		loadingImg.setAttribute("src","lay-loading.gif");
		loadingImg.setAttribute("alt","loading...");
		
		formpanel.appendChild(loadingImg);
		
		inlineWindow.appendChild(formpanel);
		
		
	}
	
	var ajax = new Ajax.Updater({success: 'PopupContent'},baseurl + '/aj-quicklinks-forms.htm',{method: 'get', parameters: null, onFailure: reportAJAXError});	
	
	$('ContentPart').style.visibility = 'hidden';
	$('FooterPart').style.visibility = 'hidden';
	
}

function showToolPanel()
{
	if ( !document.getElementById("InlineWindowHeader") )
	{
		//Create Header
		var header = document.createElement("div");
		header.id = "InlineWindowHeader";
		
		var closebtn = document.createElement("img");
		closebtn.src = "lay-btn-closelayer.gif";
		closebtn.onclick = function()
		{
			document.body.removeChild(inlineWindow);
			$('ContentPart').style.visibility = 'visible';
			$('FooterPart').style.visibility = 'visible';
		}
		
		header.appendChild(closebtn);
		
		var inlineWindow = document.createElement("div");
		inlineWindow.id = "InlineWindow";
		
		inlineWindow.appendChild(header);
		
		document.body.appendChild(inlineWindow);
		
		var formpanel = document.createElement("div");
		
		formpanel.setAttribute("id","PopupContent");
		
		var loadingImg = document.createElement("img");
		loadingImg.setAttribute("src","lay-loading.gif");
		loadingImg.setAttribute("alt","loading...");
		
		formpanel.appendChild(loadingImg);
		
		inlineWindow.appendChild(formpanel);
		
		
		$('ContentPart').style.visibility = 'hidden';
	}
	
	var ajax = new Ajax.Updater({success: 'PopupContent'},baseurl + '/aj-quicklinks-tools.htm',{method: 'get', parameters: null, onFailure: reportAJAXError});	
	
}



