function rollover(el) {
	el.className = "selected";
}

function rollout(el) {
	el.className = "";
}

function changecategory(categorynumber, li) {
	document.getElementById("currcat").innerHTML = categorynumber;

	var done = false;

	ul = document.getElementById("items");
	ul.innerHTML = "";

	var items = mainitems[categorynumber];

	for (x in items) {
		var split = items[x].split("|");
		addnewitem('<img src="' + split[1] + '" alt="" />', split[0], done);
		done = true;
	}

	resetcategories(li);
}

function setcategory(categorynumber) {
	document.getElementById("currcat").innerHTML = categorynumber;

	var done = false;

	ul = document.getElementById("items");

	ul.innerHTML = "";

	var items = mainitems[categorynumber];

	for (x in items) {
		var split = items[x].split("|");
		addnewitem('<img src="' + split[1] + '" alt="" />', split[0], done);
		done = true;
	}
}

function addnewitem(inner, liid, done) {
	var items = document.getElementById("items");
	var newli = document.createElement("li");
	newli.innerHTML = inner;
	newli.id = liid;

	newli.onmouseover = function() { rollover(this); };
	newli.onmouseout = function() { rollout(this); };
	newli.onclick = function() { changeitem(liid); };

	if(!done) {
		newli.onmouseover = function() {};
		newli.onmouseout = function() {};
		newli.className = "selected";

		var thearray = mainitems[document.getElementById("currcat").innerHTML];

		for(x in thearray) {
			var splitup = thearray[x].split("|");

			if(splitup[0] == liid) {
				document.getElementById("itemname").innerHTML = splitup[3];
				document.getElementById("itemdescription").innerHTML = splitup[4];
				document.getElementById("itemimage").src = splitup[2];
			}
		}

		document.getElementById("itemid").value = liid;
	}

	items.appendChild(newli);	
}

function resetcategories(keep) {
	lis = document.getElementById("categories").getElementsByTagName("li");

	for(x in lis) {
		if(lis[x] == keep) {
			lis[x].onmouseover = "";
			lis[x].onmouseout = "";
			lis[x].className = "selected";
		} else {
			lis[x].className = "";
			lis[x].onmouseover = function() { rollover(this); };
			lis[x].onmouseout = function() { rollout(this); };
		}
	}
}

function changeitem(itemid) {
	resetitems();
	document.getElementById(itemid).onmouseover = function() {};
	document.getElementById(itemid).onmouseout = function() {};
	document.getElementById(itemid).className = "selected";

	var thearray = mainitems[document.getElementById("currcat").innerHTML];

	for(x in thearray) {
		var splitup = thearray[x].split("|");

		if(splitup[0] == itemid) {
			document.getElementById("itemname").innerHTML = splitup[3];
			document.getElementById("itemdescription").innerHTML = splitup[4];
			document.getElementById("itemimage").src = splitup[2];
		}
	}

	document.getElementById("itemid").value = itemid;
}

function isInt(x) {
  var y = parseInt(x);
  if (isNaN(y)) return false;
  return x==y && x.toString()==y.toString();
}

function resetitems() {
	var thearray = mainitems[document.getElementById("currcat").innerHTML];

	for(x in thearray) {
		var splitup = thearray[x].split("|");
		document.getElementById(splitup[0]).className = "";
		document.getElementById(splitup[0]).onmouseover = function() { rollover(this); };
		document.getElementById(splitup[0]).onmouseout = function() { rollout(this); };
	}
}

function toggle() {
	var button = document.getElementById("submit");

	if(button.disabled) {
		button.disabled = false;
	} else {
		button.disabled = true;
	}
}

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=550,height=400');");
}

Image1 = new Image(123,28);
Image1.src = "http://70.86.72.114/~realnet/apple/images/colournav1.png";
Image2 = new Image(123,28);
Image2.src = "http://70.86.72.114/~realnet/apple/images/colournav2.png";
Image3 = new Image(123,28);
Image3.src = "http://70.86.72.114/~realnet/apple/images/colournav3.png";
Image4 = new Image(123,28);
Image4.src = "http://70.86.72.114/~realnet/apple/images/colournav4.png";