// Enigheten JavaScripts

function popup( msg ) {
  alert( msg );
}

function getObjProp( objName, parentFrame, property ) {
	if ( parentFrame == "" ) { parentFrame = "document"; }
	if (document.getElementById && !document.all) {
		obj = eval( parentFrame + ".getElementById( objName )" );
		if ( obj == null ) { return "Object not found"; }
		else {
			if ( property == "visibility" ) {
				objVisibility = obj.style.visibility;
				return ( objVisibility  == "" ) ? "inherit" : objVisibility;
			}
			else if ( property == "clip" ) {
				objClip = obj.style.clip;
				if ( objClip == "" ) {
					returnWidth = eval( parentFrame + ".defaultView.getComputedStyle(obj, '').getPropertyValue('width')" );
					returnHeight = eval( parentFrame + ".defaultView.getComputedStyle(obj, '').getPropertyValue('height')" );
					return "rect(0px " + returnWidth + " " + returnHeight + " 0px)";
				}
				else return objClip;
			}
			else if ( property == "zIndex" ) {
				objzIndex = obj.style.zIndex;
				return ( objzIndex == "" ) ? "inherit" : objzIndex;
			}
			else {
				returnValue = eval( parentFrame +".defaultView.getComputedStyle(obj, '').getPropertyValue(property)" );
				return ( returnValue == "" ) ? "unknown" : returnValue;
			}
		}
	}
	else if ( document.all ) {
		if ( (eval(parentFrame + ".all." + objName)) == null ) { return "Object not found"; }
		else {
			if ( property == "top" ) { return eval( parentFrame + ".all." + objName + ".offsetTop") + "px"; }
			else if ( property == "left" ) { return eval( parentFrame + ".all." + objName + ".offsetLeft") + "px"; }
			else if ( property == "width" ) { return eval( parentFrame + ".all." + objName + ".offsetWidth") + "px"; }
			else if ( property == "height" ) { return eval( parentFrame + ".all." + objName + ".offsetHeight") + "px"; }
			else if ( property == "clip" ) {
				clipStyle =	eval(objName + ".style.clip");
				if ( clipStyle == "" ) {
					return "rect(0px " + eval( parentFrame + ".all." + objName + ".offsetWidth") + "px " + eval( parentFrame + ".all." + objName + ".offsetHeight") + "px " + "0px)";
				}
			}
			else return eval( parentFrame + ".all." + objName + ".currentStyle." + property);
		}
	}
	else {
		obj = eval ( parentFrame + ".layers[ objName ]" );
		if ( obj == null ) { return "Object not found"; }
		else {
			if ( property == "visibility" ) {
				if ( obj.visibility == "hide" ) { return "hidden"; }
				else if ( obj.visibility == "show" ) { return "visible"; }
				else return "inherit";
			}
			if ( property == "clip" ) {
				obj = obj.clip;
				return "rect(" + obj.top + "px "+ obj.right +"px "+ obj.bottom +"px "+ obj.left +"px)";
			}
			if ( property == "width" || property == "height" ) {
				return eval("obj.clip." + property) + "px";
			}
			else if ( property == "top" ) { return eval("obj." + pageY) + "px"; }
			else if ( property == "left" ) { return eval("obj." + pageX) + "px"; }
			else if ( property == "zIndex" ) { return eval("obj." + property); }
			else { return eval("obj." + property) + "px"; }
		}
	}
}

function changeProperty( objName, parentFrame, property, value ) {
	if ( parentFrame == "" ) { parentFrame = "document"; }
	if ( document.all ) {
		if ( (eval(parentFrame + ".all." + objName)) != null ) {
			if ( value == true || value == false ) {
				eval( parentFrame + ".all." + objName + "." + property + "=" + value );
			}
			else {
				eval( parentFrame + ".all." + objName + "." + property + "='" + value +"'" );
			}
		}
	}
	else {
		if (document.getElementById && !document.all) {
			obj = eval( parentFrame + ".getElementById( objName )" );
		}
		else {
			obj = eval ( parentFrame + ".layers[ objName ]" );
			if ( property.indexOf( "style." ) != -1 ) {	property = property.substring( 6 ); }
			if ( property == "visibility" ) {
				value = ( value == "visible" ) ? "show" : "hide";
			}
		}
		if ( obj != null ) {
			if ( value == true || value == false ) {
				eval( "obj." + property + "=" + value );
			}
			else {
				eval( "obj." + property + "='" + value +"'" );
			}
		}
	}
}

function showLayer( arg ) {
	var arg;
	if ( arg != "" ) { changeProperty( arg, "", "style.visibility", "visible" ); }
}

function hideLayer( arg ) {
	var arg;
	if ( arg != "" ) { changeProperty( arg, "", "style.visibility", "hidden" );	}
}

function showArray( args ) {
	var i,args;
	if ( args != "" ) {
		for (i=0; i<(args.length); i++) {
			changeProperty( args[i], "", "style.visibility", "visible" );
		}
	}
}
	
function hideArray( args ) {
	var i,args;
	if ( args != "" ) {
		for (i=0; i<(args.length); i++) {
			changeProperty( args[i], "", "style.visibility", "hidden" );
		}
	}
}

function makeVisibleAndSetHeight ( objName ) {
	if ( objName != "" ) {
		setHeight = getObjProp( objName, "", "height" );
		setHeight = setHeight.substring( 0, (setHeight.length)-2 );
		if ( setHeight < 300 ) { setHeight = 300; }
		changeProperty( "pageContainerLayer", "", "style.height", setHeight +'px' );
		showLayer( objName );
	}
}

function mail(prefix, host, username, suffix) {
	document.write(prefix + username + "@" + host + suffix);
}

