// ######### DHTML library #########

// browser sniffer
var ns6 = false;
var ns4 = (document.layers)? true:false;
var ie4 = (document.all)? true:false;
var opera = (window.opera)? true:false;
var mac = 	((navigator.appVersion.indexOf('Mac') != -1) || (navigator.appVersion.indexOf('PowerPC') != -1))? true:false;
if (ns4 == ie4 && opera == false) {
	ns6 = true;
	ie4 = ns4 = false;
}
var safari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false;

// initialise & return a layer object
function d_init_layer(name) {
	if (ie4) return eval(name+'.style');
	if (ns6) return eval('document.getElementById("'+name+'").style');
}

// switch object visibility on
function d_show_object(obj) {
	obj.visibility = 'visible';
}

// switch object visibility off
function d_hide_object(obj) {
	obj.visibility = 'hidden';
}

// move object to a certain coordinate
function d_move_object(obj,x,y) {
	obj.left = x + 'px';
	obj.top = y + 'px';
}

// write layer content (lay is layer name)
function d_write_layer(lay,txt) {
	if (ie4) {
		document.all[lay].innerHTML = txt;
	}
	if (ns6) {
		over = document.getElementById([lay]);
		range = document.createRange();
		range.setStartBefore(over);
		domfrag = range.createContextualFragment(txt);
		while (over.hasChildNodes()) {
			over.removeChild(over.lastChild);
		}
		over.appendChild(domfrag);
	}
}

// create new layer
function d_make_layer(lay,classn,x,y,w,h,bgcolor,visible,z) {
	if(document.createElement){ 
		var el = document.createElement("DIV"); 
		if (lay != '') {
			el.id = lay;
		}
		if (classn != '') {
			el.className = classn;
		}
		with(el.style){
			position = 'absolute';
			left = x + 'px';
			top = y + 'px';
			if (w != null) {
				width = w + 'px';
			}
			if (h != null) {
				height = h + 'px';
			}
			if (bgcolor != null) {
				backgroundColor = bgcolor;
			}
			if (visible) {
				visibility = 'visible';
			} else {
				visibility = 'hidden';
			}
			if (z != null) {
				zIndex = z;
			}
		} 
		document.body.appendChild(el); 
	}
}


// ######### DHTML library auxiliary functions #########

// layer opacity function
function d_change_opac(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
} 

// return the height of a layer in pixels - needs layer name
function d_layer_height(lay) {
	if(ie4 && !opera) return eval(lay+'.clientHeight');
	if(ns6) return eval('document.getElementById("'+lay+'").offsetHeight');
	if(opera) return eval(lay+'.style.pixelHeight');
}

// browser window width
function get_winwidth() {
	if (ie4 && !opera) {
		return document.body.offsetWidth;
	} else {
		return window.innerWidth;
	}
}

// browser window height
function get_winheight() {
	var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myHeight = document.body.clientHeight;
	}
	return myHeight;
}

// vertical scroll position
function get_scroll_y() {
  var scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }
  return scrOfY;
}


// ######### mouse event handler #########

// save mouse coordinates whenever the mouse moves
var mouse_x = 0;
var mouse_y = 0;
function save_mouse_coords(e) {
   if(e) {
      if( typeof( e.pageX ) == 'number' ) {
         mouse_x = e.pageX;
         mouse_y = e.pageY;
      } else {
         mouse_x = e.clientX;
         mouse_y = e.clientY;
      }
   } else {
      e = window.event;
      mouse_x = e.clientX;
      mouse_y = e.clientY;
      if( document.documentElement && ( document.documentElement.scrollTop || document.documentElement.scrollLeft ) ) {
         mouse_x += document.documentElement.scrollLeft;
         mouse_y += document.documentElement.scrollTop;
      } else if (document.body && ( document.body.scrollTop || document.body.scrollLeft ) ) {
         mouse_x += document.body.scrollLeft;
         mouse_y += document.body.scrollTop;
      }
	}
}







// popup presets (used as standard popup settings)

a = 'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=';
var wscr = a+'yes,';
var wnoscr = a+'no,';

