// JavaScript Document
window.onload = rolloverInit;

function rolloverInit() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName.toLowerCase() == "a") {
		    if(document.images[i].parentNode.className == "btn")
			    setupRollover(document.images[i]);
			else if(document.images[i].src.toLowerCase().indexOf("btn") != -1 && document.images[i].src.toLowerCase().indexOf("up") != -1)
			    setupRollover1(document.images[i]);
			else
			    document.images[i].className = "img-btn";
		}
		else if(document.images[i].src.toLowerCase().indexOf("/images/buttons/") != -1 && document.images[i].src.toLowerCase().indexOf("btn") != -1 && document.images[i].src.toLowerCase().indexOf("up") != -1)
			    setupRollover1(document.images[i]);
		
	}
	var inp = document.getElementsByTagName("input");
	for(var i=0;i<inp.length;i++)
	{	
	    if(inp[i].type.toLowerCase() != "image")
	        continue;	    	 
	    if(inp[i].src.toLowerCase().indexOf("/images/buttons/") != -1 && inp[i].src.toLowerCase().indexOf("btn") != -1 && inp[i].src.toLowerCase().indexOf("up") != -1)
			    setupRollover1(inp[i]);
	}
}

function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;

	thisImage.overImage = new Image();
	thisImage.overImage.src = appPath + "/images/buttons/" + thisImage.id + "-down.gif";
	thisImage.onmouseover = rollOver;	
}

function setupRollover1(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	
	thisImage.overImage = new Image();
	thisImage.overImage.src = thisImage.src.replace("-up", "-down");
	thisImage.onmouseover = rollOver;	
}


function rollOver() {
	this.src = this.overImage.src;
}

function rollOut() {
	this.src = this.outImage.src;
}

						
