/*
 * A collection of functions for use in get2dom.com and indeed many other
 * places. This is a dHTML library. basic functionality for non DOM
 * compliant browsers, fun with DOM browsers (document.getElementByID),
 * and a little extra for MS Internet Explorer 5.5 & later.
 *
 * AUTHOR: Dominic Winsor, get2dom.com
 * VERSION: 1.0
 * LAST UPDATED: 10 Nov 2002
*/
 
 
 
 
 /* GET OBJECT REFERENCE (GENERIC)
 *   Return an object reference, first DOM, then UA specific
 *   Warning:  object must exist!
 *   Author:   Dominic Winsor, www.get2dom.com
*/
function getRef( element ) {

	if ( document.getElementById( element ) )
		return document.getElementById( element );
		
	if ( document.all )
		return document.all[element];
	
	if ( document.layers )
		return document.layers[element];

}
 
  
 
/*
 * NEW WINDOW OPENER
 *   Author: Dominic Winsor, www.get2dom.com
 *   Usage:  page=document location; x/y=dimensions of window
*/
 
function popupWindow( href,x,y ) {
	LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
	window.open(href,"","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width="+x+",height="+y+',left='  +LeftPosition +  ',top='  +TopPosition +"");
}

 
 
 
/* 
 * CHANGE THE CLASS OF AN ELEMENT
 *   Author: Dominic Winsor, www.get2dom.com
 *   Usage:  index=layer id, if not supplied then it will return to
 *           previous class. class=stylesheet class to apply
*/

lastChange = new String();
lastClass = new String();

function swapClass(index,className) {
	if( index ) {
		lastChange = index;
		lastClass = getRef(index).className;
		getRef(index).className = className;
	} else {
		getRef(lastChange).className = lastClass;
	}
}




/* 
 * NEW WINDOW OPENER FOR IMAGES THAT FIT THE WINDOW EXACTLY
 * Author: Dominic Winsor
 * Usage:  filename=image location (href); x/y=dimensions;
 *         pageTitle=window title
*/

 function popPhoto(filename,x,y) {
   LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
   myWindow = window.open("","Picture","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width="+x+",height="+y+',left='  +LeftPosition +  ',top='  +TopPosition +"");
   myWindow.document.write("<html><head>");
   myWindow.document.write("<title>Image</title>");
   myWindow.document.write("</head><body marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' onload=\"window.focus();\">");
   myWindow.document.write("<a href=\"javascript:window.close()\"><img border=0 hspace=0 vspace=0 height=" + y + " width=" + x + " src='" + filename + "'></a>");
   myWindow.document.write("</body></html>");
   myWindow.document.close();
}
