// JavaScript Document
//alert("here");
window.onload = initPage;
var url = window.location.href;

function initPage() {
	rolloverInit();
}

window.onbeforeunload = function () {};

function rolloverInit() {
	for (var i=0; i<document.images.length; i++) {
		if (document.images[i].parentNode.tagName == "A") {
			setupRollover(document.images[i]);
			
		}
	}
}

function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	thisImage.onmouseout = rollOut;
	
	thisImage.overImage = new Image();
	thisImage.overImage.src = "images/" + thisImage.id + "_over.jpg"; 
	thisImage.onmouseover = rollOver;
	
	thisImage.clickImage = new Image();
	thisImage.clickImage.src = "images/" + thisImage.id + "_on.jpg";
	thisImage.onclick = rollClick;
	
	if(url.indexOf("products.html") >= 0)
	{
		document.getElementById("button_3").src = "images/button_3_on.jpg";
		document.images.button_3.overImage = new Image();
		document.images.button_3.overImage.src = "images/button_3_on.jpg";
		document.images.button_3.overImage.onmouseover = rollOver;
	}
	
	else if(url.indexOf("history.html") >= 0)
	{
		document.getElementById("button_1").src = "images/button_1_on.jpg";
		document.images.button_1.overImage = new Image();
		document.images.button_1.overImage.src = "images/button_1_on.jpg";
		document.images.button_1.overImage.onmouseover = rollOver;
	}
	
	else if(url.indexOf("choose_a_category.html") >= 0)
	{
		document.getElementById("button_2").src = "images/button_2_on.jpg";
		document.images.button_2.overImage = new Image();
		document.images.button_2.overImage.src = "images/button_2_on.jpg";
		document.images.button_2.overImage.onmouseover = rollOver;
	}
	
}

function rollOut() {
	this.src = this.outImage.src;
}

function rollOver() {
	if(lastClick) {
		if(lastClick.id != this.id){
			this.src = this.overImage.src;	
		}
	}
	else {
		this.src = this.overImage.src;
	}	
}

function rollClick() {
	if(lastClick){
		lastClick.onmouseout = rollOut;
		lastClick.src = lastClick.outImage.src;
	}	
	this.src = this.clickImage.src;
	this.onmouseout = rollClick;
	lastClick = this;

}
var lastClick = null;

/*this.id == "txtUsername") {
		value="Username" onFocus="if(this.value == 'Username') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Username';}";
	}
	
this.id == "pwdPassword") {
        value="Password" onFocus="if(this.value == 'Password') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Password';}"
    }*/







