/* --------------------------------------------------------------------------------------------------------------

Filename: navigation.js
Info:     This file contains JavaScript functions for the top frame. No other functions should be placed here.

-------------------------------------------------------------------------------------------------------------- */

// Update functions:

function ping(){

	var d = new Date();

	document.getElementById("pingFrame").src='/r3/frames/update.asp?nocache='+ escape(d.getTime());
	document.getElementById("pingFrame2").src='/section/common/ping.aspx?nocache='+ escape(d.getTime());

	setTimeout('ping();', 1000*60*5); // 5 minutes to next refresh 
}

function updateOnline(iCount){
	try {
		document.getElementById("online").innerHTML=iCount;
	}
	catch(err) {
		// error!
	}
}

function updateMail(iCount){
	try {
	document.getElementById("mail").innerHTML='I<u>n</u>dbakke&nbsp;(' + iCount + ')';
	}
	catch(err) {
		// error!
	}
}

function checkSecure() {

	var txt = "Denne funktion gemmer dit brugernavn og adgangskode på den computer du sidder ved nu. "
	txt = txt + "\nDerved kan andre let få adgang til din post m.m. hvis de har adgang til denne computer."
	txt = txt + "\n\nVil du stadig gemme adgangskoden?"

	if (document.getElementById("AutoLogin").checked != true) {
		return true;
	} else {
		return confirm(txt);
	}
}

function openSupport(){
	PopWin('/section/support/?fc=0','ArtoSupport',830,525,'yes');
}

var selectTimer;

function enableSelect(selectName, selectContent){

	clearTimeout(selectTimer); // Clear timer if already set
	selectTimer = setTimeout('disableSelects()',30000); // Set (new) timer

	disableSelects();

	document.getElementById(selectName + "Container").innerHTML = selectContent;

	if (!document.all) {
		document.getElementById(selectName + "Select").focus(); // Set focus in Firefox/Safari
	}
}

function disableSelects(){
	clearTimeout(selectTimer); // Clear reset timer
	document.getElementById("controlpanelContainer").innerHTML = '<a href="JavaScript:void(0);" onmouseover="enableSelect(\'controlpanel\', controlpanelSelectContent);" class="navLink">Kontrolpanel</a>';
	SelectManager.showTeaser('shortcutContainer');
	try {
		document.getElementById("adminContainer").innerHTML = '<a href="JavaScript:void(0);" onmouseover="enableSelect(\'admin\', adminSelectContent);" class="navLink">Admin</a>';
	} catch(e) {
		// Do nothing!
	}
}

function changePage(obj, type){

	var page = obj[obj.selectedIndex].value;

	if (page=='filter') {
		PopWin('/section/user/profile/mail/filter.aspx','filter',280,400,'yes');
	} else if (page=='addShortcut') {
		page = '/section/user/shortcuts/?url='+ escape(parent.hovedside.location.href) +'&title='+ escape(parent.hovedside.document.title);
		//alert(page);
		parent.hovedside.location.href = page;
	} else {
		try {
			parent.hovedside.location.href = page;
			parent.hovedside.document.body.focus(); // Set focus in main for increased usability (IE/Safari only)
		} catch(e) {
			// Nothing...
		}
	}

	disableSelects();
}	

function prepareQuickSearch() {
	obj = document.getElementById("quicksearch");
	if ((obj.value=='Find bruger')||(obj.value=='Find indhold')) {
		obj.value = '';
		obj.style.color = '#FAF5EB';
		setTimeout('timedQuickSearchReset()',5000);
	}
}

function timedQuickSearchReset() {
	obj = document.getElementById("quicksearch");
	if (obj.value=='') {
		obj.value = 'Find bruger';
		obj.style.color = '#c9c6bf';
		obj.blur();
	} else {
		setTimeout('timedQuickSearchReset',5000);
	}
}

function enableTranslation() {
	var langSys = new LangSys("/r2/icons/icon_bullet_r2.gif");
	langSys.registerTranslationListener(test);
	langSys.ShowTranslations();
}
