
<!--
/* ------------------------------------------------------------------------------
	DHTML Penetrator 1.0 
	
	** ** ** ** **
	
	This script allows you to keep a <div> based layer in one corner
	even if scrolled from top to bottom or right to left.
	if you want to implement it on your site and wanna have it at
	a different corner than right-bottom, just play around with the
	theight and twidth variables in the setPPos(String) and the 'regulator floats' 
	in the scrollPPos() function [0.997 and so on ...].

	-- notes --

	CALL IT FROM BODY:
	call the main method setPPos(String) and scrollPPos() first from the <body> tag by
	follwing syntax:
	
	<body onload="setPPos("onload");scrollPPos();">
	
	PUT A LAYER INTO YOUR HTML FILE TO GET IT WORK:
	put a <div> onto your site with the id and name 'Layer1'.
	
	<div id="Layer1" name="Layer1">watch me scrolling!<div>
	
	e.g. you can insert an image to it and see what happens. 
	please excuse my laziness to create the layer dynamically ... ;) 
	
	watch the script running on the demo 'prod_js.html'!
	
	** ** ** ** **

	tested with Netscape(>4,5)/Mozilla(>0.9), IE(>4),
	Opera6 (only if identifies as netscape 4.78, enable it via file -> preferendes -> network in opera)

	-- author --
	
	Markus 'beebob' Bopp, 3/2002
-------------------------------------------------------------------------------- */

var timer;
var match_rule;
var enableSiteRule;

function setPPos(state)
{
	loc  = new Array();
	
	// OPTIONS:
	// this variables manage the reversed (starting from right-bottom) 
	// relative positions
	if(document.all){
		// for the early microsoft internet explorer 4 versions
		theight = 50;
		twidth  = 146;
	}else if(document.layers){
		// for the good old netscape 4 family
		theight = 45;
		twidth  = 155;
	}else if(document.getElementById){
		// and finally for modern browsers that include
		// the newer dom (Netscape6, mozilla, ie)
		theight = 85;
		twidth  = 80;
	}

	// define wether the layer hast to disappear at a specific resolution
	// true = enable, false = do not enable
	enableSiteRule = false;

	// define here at which (inner) non-reversed resolution (top-left) the layer has to disappear
	// only if you have enabled thw site rule
	rule_width  = 750;
	rule_height = 300;

	// this array contains the sites where the resolution rules above will be affected
	// you can simply add a file where the rule has to be affected (no url, just the filename!)
	// if you want to define rules, uncomment this block out
	
	loc[0]   = "first_file.html";
	loc[1]   = "second_file.html";
	loc[2]   = "third_file.html";
	loc[3]   = "just_one_more_file_to_go.html";
	loc[4]   = "really_the_very_last_file_in_this_array.html";
	

	/* ---------------------------------------------------------------------------
	  OPTIONS END
	  
	  don't change anything from here if you don't know, what you do!
	  
	  remember: the layer that is used in the html-code must have the id 'Layer1'
	            until you don't change the layer name in code itself.
	--------------------------------------------------------------------------- */
	  
	// get the (crossbrowser)heights ...
	if(document.all){
		inner_height = document.body.clientHeight - theight;
		inner_width  = document.body.clientWidth  - twidth;
	}else if(document.layers || document.getElementById){
		inner_height = window.innerHeight - theight;
		inner_width  = window.innerWidth  - twidth;
	}
	
	// rules for sites which contain e.g. flash-movies, inputs etc.
	if(enableSiteRule){
		locl = loc.length;
		for(i=0;i<locl;i++){
			if(document.location.href.indexOf(loc[i])!=-1){
				if(inner_width < rule_width || inner_height < rule_height){
					match_rule = true;
				}else{
					match_rule = false;
				}
			}
		}
	}else{
		match_rule = false;
	}
	
	// crossbrowser starts here ...
	if(document.all){
		if(state=='onload'){
			Layer1.style.pixelTop   = inner_height;
			Layer1.style.pixelLeft  = inner_width;
		}
		if(match_rule==true){
			Layer1.style.visibility = "hidden";
		}else{
			Layer1.style.visibility = "visible";
		}
	}else if(document.layers){
		if(state=='onload'){
			document.Layer1.pageY = inner_height;
			document.Layer1.pageX = inner_width;
		}
		if(match_rule==true){
			document.Layer1.visibility = "hide";
		}else{
			document.Layer1.visibility = "show";
		}
	}else if(document.getElementById){
		if(state=='onload'){
			//alert(document.getElementById('Layer1'));
			document.getElementById('Layer1').style.top  = inner_height;
			document.getElementById('Layer1').style.left = inner_width;
		}
		if(match_rule==true){
			document.getElementById('Layer1').style.visibility = "hidden";
		}else{
			document.getElementById('Layer1').style.visibility = "visible";
		}
	}

	// return the heights of inner window
	positions = inner_width+"#"+inner_height;
	return positions;
}

function scrollPPos(){
	// get return value of setPPos where the window heights are defined
	positions      = setPPos("xxx");
	positionsArray = positions.split("#");
	inner_width    = positionsArray[0];
	inner_height   = positionsArray[1];
	
	// crossbrowser starts here ... discovering new ways of mathmatics
	if(document.all){
		Layer1.style.pixelTop  = document.body.scrollTop  + inner_height * 0.999;
		Layer1.style.pixelLeft = document.body.scrollLeft + inner_width  * 0.999;
	}else if(document.layers){
		document.Layer1.pageY = pageYOffset + inner_height * 0.997;
		document.Layer1.pageX = pageXOffset + inner_width  * 0.997;
	}else if(document.getElementById){
		document.getElementById('Layer1').style.top  = pageYOffset + inner_height * 0.997;
		document.getElementById('Layer1').style.left = pageXOffset + inner_width  * 0.997;
	}
	
	timer = setTimeout("scrollPPos();",1);
}



//-->





