//pre-load images
var oldOnload = window.onload;
window.onload = myOnload;

function myOnload() {
	
	//array of up images
	var arUpImages = new Array( "submitSearch", "submitComment" );
	
	//array of down images
	var arDownImages = new Array( arUpImages.length );
	
	//loop through up images and pre-load down images based on filename
	for( var iCtr=0; iCtr<arUpImages.length; iCtr++ ) {
		var upImage = document.getElementById( arUpImages[iCtr] );
		if( upImage ) {
			arDownImages[iCtr] = new Image();
			arDownImages[iCtr].src = (upImage.src) ? upImage.src.replace( /-up\.png$/, "-down.png" ) : "";
		}
	}
	
	if( oldOnload && typeof( oldOnload ) == "function" ) {
		oldOnload();
	}
}


//replaces a down image with an up image based on src attribute of an image
function btnUp( ele ) {
	if( ele.src.match( /-down\.png$/ ) ) {
		ele.src = ele.src.replace( /-down\.png$/, "-up.png" );
	}
}

//replaces an up image with a down image based on src attribute of an image
function btnDown( ele ) {
	if( ele.src.match( /-up\.png$/ ) ) {
		ele.src = ele.src.replace( /-up\.png$/, "-down.png" );
	}
}

//traverses parent nodes until it hits a form element, then submits it
function doSubmit(ele) {
	//var ele = this;
	while( ele != null ) {
		if( ele.nodeType == 1 && ele.nodeName.toUpperCase() == "FORM" ) {
			ele.submit();
			return true;
		}
		
		ele = ele.parentNode;
	}
}