function getID(varID) {
	if (document.all) {
		var d = document.all[varID];
	} else if (document.layers) {
		var d = document.ids.varID;
	} else {
		var d = document.getElementById(varID);
	}
	return d;
}

//var activeId;
document.onclick = clickHandler;
function clickHandler() {
	var targetId, srcElement, targetElement, activeId, targetImage;
	theEvent=window.event || arguments[0];
	srcElement = theEvent.srcElement || theEvent.currentTarget || theEvent.target;
	
	if ((srcElement.className == "thisside") || (srcElement.className == "startside")) {
		targetId = srcElement.id+"d";
		activeImage = srcElement.id+"p";
		activeId = srcElement;
		targetElement = getID(targetId);
		targetImage = getID(activeImage);
		
		if (activeId.className == "thisside") { //om siden er startside
			activeId.className = "thisside";
		} else { //om siden ikke er startside
			activeId.className = "startside";
		}
		//alert(targetImage);
		if (targetElement.className == "hideItem") { //om siden er startside
			targetElement.className = "showItem";
			targetImage.src = "./images/prikk5.gif";
		} else {
			targetElement.className = "hideItem";
			targetImage.src = "./images/prikk6.gif";
		}
	}
	
}
/*document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=function() {
alert(arguments[0].type) // "mousedown"
}*/

//document.onclick = clickHandler;
function apne(url) {
	var monkey = 1;
	apekatt = window.open(url, 'msgvindow1', 'height=420,width=480,scrollbars=2');
}
function apne2(url, x, y) {
	if (!x) {
		x = "420";
	}
	if (!y) {
		y = "480";
	}
	var monkey = 1;
	apekatt = window.open(url, '', 'height='+y+',width='+x+',scrollbars=yes,resizable=yes');
}
function apne3(url, x, y) {
	if (!x) {
		x = "420";
	}
	if (!y) {
		y = "480";
	}
	var monkey = 1;
	apekatt = window.open(url, 'msgvindow3', 'height='+y+',width='+x+',scrollbars=yes,resizable=yes');
}
function MM_reloadPage(init) {
	//reloads the window if Nav4 resized
	if (init == true) {
		with (navigator) {
			if ((appName == "Netscape") && (parseInt(appVersion) == 4)) {
				document.MM_pgW = innerWidth;
				document.MM_pgH = innerHeight;
				onresize = MM_reloadPage;
			}
		}
	} else if (innerWidth != document.MM_pgW || innerHeight != document.MM_pgH) {
		location.reload();
	}
}
MM_reloadPage(true);
// -->
function MM_findObj(n, d) {
	//v4.0
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && document.getElementById) {
		x = document.getElementById(n);
	}
	return x;
}
function MM_showHideLayers() {
	//v3.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i += 3) {
		if ((obj=MM_findObj(args[i])) != null) {
			v = args[i+2];
			if (obj.style) {
				obj = obj.style;
				v = (v == 'show') ? 'visible' : (v='hide') ? 'hidden' : v;
			}
			obj.visibility = v;
		}
	}
}
function PostCard_Validator(theForm) {
	if (theForm.to.value == "") {
		alert("Please enter a value for the \"E-mail address of postcard recipient\" field.");
		theForm.to.focus();
		return false;
	}
	if (theForm.to.value.length<7) {
		alert("Please enter at least 7 characters in the \"E-mail address of postcard recipient\" field.");
		theForm.to.focus();
		return false;
	}
	if (theForm.EMail.value == "" || theForm.EMail.value.indexOf('@') == 0) {
		alert("Please enter a value for the \"Your e-mail address\" field.");
		theForm.to.focus();
		return false;
	}
	if (theForm.EMail.value.length<7) {
		alert("Please enter at least 7 characters in the \"Your e-mail address\" field.");
		theForm.to.focus();
		return false;
	}
	if (theForm.MESSAGE.value == "") {
		alert("Please enter a value for the \"Message\" field.");
		theForm.MESSAGE.focus();
		return false;
	}
	if (theForm.SENDERNAME.value == "") {
		alert("Please enter a value for the \"Your name\" field.");
		theForm.SENDERNAME.focus();
		return false;
	}
	return true;
}
