/*
//-------------------------------------------------------------------------------
// File: dhtml-lib.js - 
// Description: Dynamic HTML Library!
//-------------------------------------------------------------------------------
// Created:	15.Jun.2001
// LastUpd:	23.Okt.2001
//
// Author: Panos Galanis <pg@iap.de>
//-------------------------------------------------------------------------------
*/

//  Tested on
//  IE4, IE5, IE6, Netscape 4.x (Not 4.08), Netscape 6,
//  Mozilla 0.x, Opera 5.x
//-------------------------------------------------------------------------------
//
//  alertStatus()               	* Javascript Status Alert
//  hover(id,url)    	  			* Onmouseover="hover('ImageName','ImageSRC')"
//  wPop(url,specs)					* Window PopUp
//  getCookie(name)					* Returns The Value of a Cookie
//  setCookie(name,value,days,path)	* Set a Cookie
//  getscrollX(window)				* Returns Scroll-x in pixels
//  getscrollY(window)				* Returns Scroll-y in pixels
//  getWindowWidth()				* Returns Active Window (body) Width
//  getWindowHeight()				* Returns Active Window (body) Height
//  setWindow(width,height) 		* Resize the window (width,height)
//  setWindowMin() 					* (not working)
//  setWindowMax() 					* Emulate the Maximize 
//
//  startMouseCapture(handler)		* Start The Mouse Move Capture
//  getMouseMove(evt)				* Get The mouseX & mouseY values
//					  				  If the startMouseCapture is fired
//
//  writeLayer(id,txt)				* Write-Replace Text to a Layer
//  showLayer(id)					* Set Layers Visibility To Visible
//  hideLayer(id)					* Set Layers Visibility To hidden
//  moveLayer(id,x,y)				* Move the Layer
//  getLayerWidth(id)				* Returns Layer Width
//  getLayerHeight(id)				* Returns Layer Height
//  getLayer(id)					* Returns Layer
//
//-------------------------------------------------------------------------------

var ver=navigator.appVersion;
var dom=document.getElementById? true:false;
var ie=(ver.indexOf("MSIE")>-1)? true:false;
var ie4=(document.all && !dom)? true:false;
var ie5=(ver.indexOf("MSIE 5")>-1 && dom)? true:false;
var ie6=(ver.indexOf("MSIE 6")>-1 && dom)? true:false;
var ns=(navigator.appName.indexOf("Netscape")>-1)? true:false;
var ns4=(ns && (parseFloat(ver)> 4.08) && !dom)? true:false;
var ns6=(ns && dom)? true:false;
var op=((navigator.appName.indexOf("Opera")>-1) && (parseFloat(ver)> 5.00) && dom)? true:false;
var w3c=(dom && !ns6 && !ie5 && !ie6 && !op) ? true:false;
var old=(!dom && !ie4 && !ns4 ) ? true:false;

var mouseX=0;
var mouseY=0;

//var name,value,days,id;

///////////////////////////////////////////////////////////////////////////
//  Functions
///////////////////////////////////////////////////////////////////////////

function alertStatus(){

var str;
str ='Your Browser Claims to Be ...';
str+='\n\nBrowser : '+navigator.appName;
str+='\nVersion : '+navigator.appVersion;
str+='\nMonitor Resolution : '+screen.width+'x'+screen.height+'px';
str+='\nColor Depth : '+Math.pow(2,screen.colorDepth)+' - '+screen.colorDepth+'bit';
str+='\nActive Window : '+getWindowWidth()+'x'+getWindowHeight()+' px';
str+='\nScroller : '+getScrollX()+'x'+getScrollY()+' px';
str+='\nMouse Position : '+mouseX+'x'+mouseY+' px';
str+='\n\n* Javascript Detection\n';
if(ie)str+='\nis Internet Explorer';
if(ie4)str+='\nIE4 - document.all';
if(ie5)str+='\nIE5 - DOM';
if(ie6)str+='\nIE6 - DOM';
if(ns)str+='\nis Netscape Navigator';
if(ns4)str+='\nNetscape 4';
if(ns6)str+='\nNetscape 6';
if(op)str+='\nis Opera - DOM';
if(w3c)str+='\nis Unknown W3C - DOM';
if(old)str+='\nis Unknown - Old Browser';
alert(str);
}

// IE does not recognize push ... so we must have a function for this ... 
// Original at javascript.faqts.com
if (Array.prototype && !Array.prototype.push)  Array.prototype.push = IE_push;

function IE_push () {
  for (var a = 0; a < arguments.length; a++)   this[this.length] = arguments[a];
  return this.length;
  } 
  
  
function hover(id,url)
	{
	if (old) return 0;
	eval("document."+id+".src=\""+url+"\"");
	}

function wPop(url,specs){
	if (!specs) specs="width=600,height=400,scrollbars=1,resizable=1";
	var wp=window.open(url,"MyPop",specs);
	wp.focus();
	}

function getCookie(name) {
	var re = new RegExp(name + "=([^;]+)");
	var value = re.exec(document.cookie);
	return (value != null) ? unescape(value[1]) : null;
	}

function setCookie(name,value,days,path) {
	if(!days) days=0;
	value=escape(value);
	path=(path)? path : "/";
	var today = new Date();
	var expiry = new Date(today.getTime() + (days * 24 * 60 * 60 * 1000));
	var ctext = name + "=" + value + "; path="+path+"; expires=" + expiry.toGMTString();
	//alert(ctext);
	document.cookie=ctext;
	//return true;
	}

function getScrollX(window) {
	if (!window)window="top";
	if (ns || w3c || op) return eval(window+'.pageXOffset');
	if (ie) return eval(window+'.document.body.scrollLeft');
	}

function getScrollY(window) {
	if (!window)window="top";
	if (ns || w3c || op) return eval(window+'.pageYOffset');
	if (ie) return eval(window+'.document.body.scrollTop');
	}

function getWindowWidth() {
	if (ie) return document.body.clientWidth;
	if ( ns || w3c || op) return window.innerWidth;
	}
function getWindowHeight() {
	if (ie) return document.body.clientHeight;
	if (ns || w3c || op) return window.innerHeight;
	}

function setWindow(w,h) {
	window.resizeTo(w,h);
	}
function setWindowMin() {
	//window.resizeTo(0,0);
	}
function setWindowMax() {
	window.moveTo(0,0)
	window.resizeTo(screen.availWidth,screen.availHeight);
	}


function getMouseMove(evt) {
	if (ns) {
		mouseX=evt.pageX;
		mouseY=evt.pageY;
		}
	if (ie||op) {
		mouseX=window.event.clientX;
		mouseY=window.event.clientY;
		}
	if (w3c){
		mouseX=evt.clientX;
		mouseY=evt.clientY;
		}
	//window.status="Capture Mouse Move Event Started : "+mouseX+"x"+mouseY;
	}

function startMouseCapture(handler) {
	if (ns4) document.captureEvents(Event.MOUSEMOVE);
	if (handler){
		document.onmousemove=handler;
		} else {
		document.onmousemove=getMouseMove;
		}
	}

function writeLayer(id,txt) {
	if (old) return 0;
	obj=getLayer(id);
	if (ns4){
		obj.document.open();
		obj.document.write(txt);
		obj.document.close();
		}else{
		obj.innerHTML=txt;
		}
	}

function showLayer(id) {
	if (old) return 0;
	obj=getLayer(id);
	if (ns4) {
		obj.visibility="visible";
		}else{
		obj.style.visibility="visible";
		}
	}

function hideLayer(id) {
	if (old) return 0;
	obj=getLayer(id);
	if (ns4) {
		obj.visibility="hidden";
		}else{
		obj.style.visibility="hidden";
		}
	}

function moveLayer(id,x,y) {
	if (old) return ;
	obj=getLayer(id);
	if (ie4){
		obj.pixelLeft=x;
		obj.pixelTop=y;
		}
	if (ns4){
		obj.moveTo(x,y);
		}
	if (dom){
		obj.style.left=x;
		obj.style.top=y;
		}
	}

function getLayerWidth(id) {
	if (old) return ;
	obj=getLayer(id);
	if(ns4) return obj.clip.width;
	if(ie) return obj.clientWidth;
	if(!ie && dom) return obj.offsetWidth;
	}
function getLayerHeight(id) {
	if (old) return ;
	obj=getLayer(id);
	if(ns4) return obj.clip.height;
	if(ie) return obj.clientHeight;
	if(!ie && dom) return obj.offsetHeight;
	}

function getLayer(id) {
	if (ns4){
  		var i, ii, layer, layerin;
	  	for (i = 0; i < document.layers.length; i++) {
  			layer = document.layers[i];
			if (layer.name == id) return layer;
			if (layer.document.layers.length > 0) {
			  	for (ii = 0; ii < layer.document.layers.length; ii++) {
		  			layerin = layer.document.layers[ii];
	  				if (layerin.name == id) return layerin;
	  				}
	  			}
			}
		return null;
	    	}
	if (ie4){
    		return eval('document.all.' + id);
    		}
	if (dom && !ie4){
		return eval('document.getElementById("' + id + '")');
		}
	return null;
	}
