var shownCategory = null;
var z_phone = null;
var z_shown = null;

function doLoad(str) {

	if(shownCategory != null)
		shownCategory.className = "";
	
	shownCategory = document.getElementById(str + "Item");
	if(shownCategory != null)
		shownCategory.className = "on";
	
	var fl = document.getElementById('phones');
	var ph = fl.loadPhones(str); 
	if(ph != null && ph + "" != "")
		showPhone(ph);
	return false;
}

function showPhone(ph) {

	var id = ph.replace(/\s/gi, "");
	id = id.replace(/'/gi, "");
	id = id.replace(/\((trade|amp|reg)\)/gi, "");
	
	var newPhone = document.getElementById(id);
	
	if(newPhone != null && typeof newPhone != "undefined") {

		if(z_phone != null && typeof z_phone != "undefined")
			z_phone.style.display = "none";
		
		z_phone = newPhone;
		
		var images = z_phone.getElementsByTagName("div");	
		var imgCount = 0;
		for(var i=0; i<images.length; i++) {
		
			if(images[i].className == "fullImage") {
				images[i].style.display = (imgCount == 0) ? "block" : "none";	
				if(imgCount == 0)
					z_shown = document.getElementById(images[i].id);
				imgCount++;
			}
		}
		z_phone.style.display = "block";
		if(typeof pngfix != "undefined") {
			pngfix.fix(z_phone.id);
			window.setTimeout("pngfix.fix('" + z_phone.id + "')", 1000);
			window.setTimeout("pngfix.fix('" + z_phone.id + "')", 2000);
		}
	}
}

function showImage(img) {

	if(z_phone == null || typeof z_phone == "undefined")
		return;
		
	var images = z_phone.getElementsByTagName("div");	
	for(var i=0; i<images.length; i++) {
	
		if(images[i].className == "fullImage") {
			images[i].style.display = (images[i].id == img) ? "block" : "none";
			if(images[i].id == img) 
				z_shown = images[i];
		}
	}
	if(typeof pngfix != "undefined") {
		pngfix.fix(z_phone.id);
		window.setTimeout("pngfix.fix('" + z_phone.id + "')", 1000);
		window.setTimeout("pngfix.fix('" + z_phone.id + "')", 2000);
	}
}
