
var prodListAnchors=[];
var prodNavAnchors=[];
var activeLink = null;

onload = function(){
	// clear background images if values in text boxes
	//if (document.getElementById){
	//	var elUsername = document.getElementById("username");
	//	if (elUsername && elUsername.value=="") elUsername.className="ipUsername";
    //
	//	var elPassword = document.getElementById("password");
	//	if (elPassword && elPassword.value=="") elPassword.className="ipPassword";
	//}
	
	n = document.getElementById("productList");
	if (n) getChildAnchors(n,prodListAnchors);
	
	n = document.getElementById("auxContent");
	if (n) getChildAnchors(n,prodNavAnchors);

	// helper
	function getChildAnchors(n,o){
		var children = n.childNodes; 
		for(var i=0; i < children.length; i++) {
			getChildAnchors(children[i],o);
			if (children[i].tagName=="A") o[o.length] = children[i];
		}
	}
}

function findIndOfAnchor(o,anchorAr){
	// move to A element
	while (o.tagName!="A" && o!=document.body)
		o = o.parentNode;

	if (o.tagName!="A" || o.className=="selected") return -1;
		
	for (var i=0;i<anchorAr.length;i++)
		if (anchorAr[i]==o) return i;

	return -1;
}


function rollOver(e,src,tgt){
	rollOut();
	// get obj triggering event
	var o = (document.all) ? e.srcElement : e.target;
	var ind = findIndOfAnchor(o,src);
	if (ind==-1 || ind>=tgt.length) return;
	tgt[ind].className="on";
	activeLink = tgt[ind];
}

function rollOut(){
	if (activeLink) activeLink.className="";
	activeLink = null;
}