//set up the appends the simpleRollover function to window.onload
var currentWindowOnload =(window.onload)?window.onload:function(){};
window.onload = function(){
	currentWindowOnload();
	if(document.getElementsByTagName){
		matchHeight();
	}
	setupRollover();
	}
	
//iterates img collection, appends simple swap to omouseover/mouseout
//Assumes standard format imgname_0 is rolloff, imgname_1 is rollover
//images are assumed to be in the same folder.
function setupRollover(){
	var imgs,i;
	// Loop through all images, and check if their classes contain the class roll
	imgs=document.getElementsByTagName('img');
	for(i=0;i<imgs.length;i++){
		if(/roll/.test(imgs[i].className)){
			// add the function roll to the parent Element of the image
			imgs[i].parentNode.onmouseover=function(){roll(this);};
			imgs[i].parentNode.onmouseout=function(){roll(this);};
			imgs[i].parentNode.onfocus=function(){roll(this);};
			imgs[i].parentNode.onblur=function(){roll(this);};
		}//end if
	}//end for
}//end func

function roll(o){
	var i,isnode,src,ftype,newsrc,nownode;
	// loop through all childNodes
	for (i=0;i<o.childNodes.length;i++){
		nownode=o.childNodes[i];
		// if the node is an element and an IMG set the variable and exit the loop
		if(nownode.nodeType==1 && /img/i.test(nownode.nodeName)){
			isnode=i;
			break;
		}//end if
	}//end for
	// check src and do the rollover
	src = o.childNodes[isnode].src;
	ftype = src.substring(src.lastIndexOf('.'), src.length);
	if(/_0/.test(src)){
		//newsrc = src.replace('_on','');
		newsrc = src.replace('_0','_1');
	}else{
		//newsrc = src.replace(ftype, '_on'+ftype);
		newsrc = src.replace(ftype, '_on'+ftype);
		newsrc = src.replace('_1','_0');
	}//end if
	o.childNodes[isnode].src=newsrc;
}//end func

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=250,height=400,left = 770,top = 320');");
}

function printWindow(){
	browserVersion = parseInt(navigator.appVersion)
	if (browserVersion >= 4) window.print()
	else window.alert('Your browser does not support this feature');
}

function bookmark(bookmarkurl,bookmarktitle){
	if (document.all){
		window.external.AddFavorite(bookmarkurl,bookmarktitle);
	}else{
		window.alert('Netscape browsers do not support this feature. Pressing Ctrl + D will bookmark this page.');
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function matchHeight(){
	var divs,contDivs,maxHeight,divHeight,d;
	// get all <div> elements in the document
	divs=document.getElementsByTagName('div');
	contDivs=[];
	// initialize maximum height value
	maxHeight=0;
	// iterate over all <div> elements in the document
	for(var i=0;i<divs.length;i++){
		// make collection with <div> elements with class attribute 'matchedheight'
		if(/\bmatchedheight\b/.test(divs[i].className)){
			d=divs[i];
			contDivs[contDivs.length]=d;
			// determine height for <div> element
			if(d.offsetHeight){
				divHeight=d.offsetHeight;
			}else if(d.style.pixelHeight){
				divHeight=d.style.pixelHeight;
			}
			// calculate maximum height
			maxHeight=Math.max(maxHeight,divHeight);
		}
	}
	if(!maxHeight || maxHeight < 20) maxHeight = 20;
	//alert(contDivs.length+' : '+maxHeight);
	// assign maximum height value to all of container <div> elements
	for(var i=0;i<contDivs.length;i++){
		contDivs[i].style.height=maxHeight+'px';
	}
}

