function getMouseXY(e) {
	var IE = document.all?true:false;
	var tempX = 0;
	var tempY = 0;
	if (IE) {
		tempX = event.clientX + document.body.scrollLeft;
		tempY = event.clientY + document.body.scrollTop;
	} else {
		tempX = e.pageX;
		tempY = e.pageY;
	}	
	if (tempX < 0){tempX = 0}
	if (tempY < 0){tempY = 0}	
	document.show.mouseX.value = tempX + 10;
	document.show.mouseY.value = tempY + 10;
}

function showHeaderMenu() {
	var i = document.getElementById('hummeny');
	var left = document.show.mouseX.value;
	var top = document.show.mouseY.value;
	i.style.top = top + 'px';
	i.style.left = left + 'px';
	i.style.visibility = 'visible';
}

function hideHeaderMenu() {
	var i = document.getElementById('hummeny');
	i.visibility = 'hidden';
}




function showThumb(s) {
	var i = document.getElementById('thumb');
	var left = document.show.mouseX.value;
	var top = document.show.mouseY.value;
	i.src = s;
	i.style.top = top + 'px';
	i.style.left = left + 'px';
	i.style.visibility = 'visible';
}

function showThumbFixed(s) {
	var i = document.getElementById('thumb');
	i.src = s;
	i.style.visibility = 'visible';
}

function hideThumb() {
	var i = document.getElementById('thumb');
	i.src = '/webadmin/images/transp.gif';
	i.visibility = 'hidden';
}

function resizeDocTextArea(a,b,c) {
	if (b == 'dk' || b == 'dd') {
		var d1='docForm:docKeywords'; 
		var d2='docForm:docDescription';
	} else if (b == 'mk' || b == 'md') {
		var d1='docForm:metaKeywords'; 
		var d2='docForm:metaDescription';
	}
	b = b.substring(0,1);
	document.getElementById(d1).style.height=a;
	document.getElementById(d2).style.height=a;
	document.getElementById(b+'k1').style.backgroundImage=c;
	document.getElementById(b+'k2').style.backgroundImage=c;
	document.getElementById(b+'d1').style.backgroundImage=c;
	document.getElementById(b+'d2').style.backgroundImage=c;
}


function resizeImageMetaData(a,b,c) {
	document.getElementById('imageForm:metadata').style.height=a;
	document.getElementById(b+'1').style.backgroundImage=c;
	document.getElementById(b+'2').style.backgroundImage=c;
}




function validateMenu() {

	var nodename = document.frmForm['frmForm:nodename'].value;

	var did = document.frmForm['frmForm:nodedocument'];
	var nodedocument = "";
	for (var i = 0 ; i < did.length; i++) {
		if (did[i].selected) {
			nodedocument = did[i].value;
		}
	}

	var tid = document.frmForm['frmForm:template'];
	var template = "";
	for (var i = 0 ; i < tid.length; i++) {
		if (tid[i].selected) {
			template = tid[i].value;
		}
	}

	if (nodename != "" && nodedocument != "" && template != "") {
		return true;
	} else {
		var str = "";
		var str1 = "";
		var str2 = "";
		var str3 = "";
		if (nodename == "") str1 = "Navn må fylles ut.";
		if (nodedocument == 0 || nodedocument == "") str2 = "Dokument må velges.";
		if (template == 0 || template == "") str3 = "Layout-mal må velges.";
		if (str1 != "") str = str1 + "\n";
		if (str2 != "") str = str + str2 + "\n";
		if (str3 != "") str = str + str3 + "\n";
		alert(str);
		return false;
	}
}


function popup() {
	var w = screen.availWidth, h = screen.availHeight;
	var popW = 440, popH = 550;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var loc = "";
	var imgChoice = open(loc,"imgChoice","top="+topPos+",left="+leftPos+",height="+popH+",width="+popW+",status=no,toolbar=no,menubar=no,location=no,resizable=yes");
}



function helpWin() {
	var w = screen.availWidth, h = screen.availHeight;
	var popW = 650, popH = 500;
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	var loc = "";
	var imgChoice = open(loc,"help","top="+topPos+",left="+leftPos+",height="+popH+",width="+popW+",status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");
	imgChoice.focus();
}



function cycle(a) {
	var b = document.userForm['userForm:userRoles'];
	for (var i = 0; i < b.length; i++) {
		if (b[i].value == a) {
			b[i].checked = true;
		} else {
			b[i].checked = false;
		}
	}
}



