var DHTML = (document.getElementById || document.all || document.layers);

function objExists(name) {
  if ((document.getElementById) && (document.getElementById(name))) {
	return true;
  } else if ((document.all) && (document.all[name])) {
	return true;
  } else if ((document.layers) && (document.layers[name])) {
	return true;
  } else
  	return false;
}


function getObj(name) {
  if (document.getElementById) {
  		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
  } else if (document.all) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
  } else if (document.layers) {
   		this.obj = document.layers[name];
   		this.style = document.layers[name];
  }
}

function switchImage(whichid) {
	if (!DHTML) return;
	imagesrc = document.images[whichid].src;
	if (imagesrc.indexOf("Open")!=-1) {
		document.images[whichid].src = imagePath + "roundButtonClosed.gif";
	} else {
		document.images[whichid].src = imagePath + "roundButtonOpen.gif";
	}
	updateToggleAll();
}

function hidestyle(whichid, justhide) {
if (!DHTML) return;
mainobject = new getObj(whichid);
//lineobject = new getObj(whichid + '_line');
	if (mainobject.style.display=='none' && justhide!=1){
		mainobject.style.display='';
		//lineobject.style.display='';
	} else {
		mainobject.style.display='none';
		//lineobject.style.display='none';
	}
}

function hideAll() {	

	var trs = document.getElementsByTagName('tr');
	for (var i=0,len=trs.length;i<len;i++){
		if (trs[i].className=='detailrow') {
			trs[i].style.display='none';
		}
	}
	
}

function updateToggleAll() {
	toggleText = new getObj("toggleAllText");
	toggleImg = new getObj("toggleAllImg");
	
	if (anyOpen()) {
		toggleText.obj.innerHTML = "Hide all";
		toggleImg.obj.src = imagePath + "spec_arrow_up.gif";
	} else {
		toggleText.obj.innerHTML = "Show all";
		toggleImg.obj.src = imagePath + "spec_arrow_down.gif";
	}
}

function toggleAll(evt) {
	if (!DHTML) return;
	if (evt==null && window.event) evt=event;
	if (anyOpen()) {
		closeAllImages();
		hideAll(evt);
	} else {
		objectnamearray = new Array("convenience", "versatility", "performance", "security", "certification","compatibility", "systemreqs", "whatsincluded", "techspecs", "datasheets", "related_products");
		for (var i=0; i<objectnamearray.length; i++){
				if (objExists(objectnamearray[i]+'_detail')) {
					hidestyle(objectnamearray[i]+"_detail");
					switchImage(objectnamearray[i] + "_image");
				}
		}
	}
	updateToggleAll();
}

function anyOpen() {
	if (!DHTML) return;

	objectnamearray = new Array("convenience", "versatility", "performance", "security", "certification","compatibility", "systemreqs", "whatsincluded", "techspecs", "datasheets", "related_products");
	for (var i=0; i<objectnamearray.length; i++){
		if (objExists(objectnamearray[i]+'_detail')) {
			imageID = objectnamearray[i] + "_image";
			imagesrc = document.images[imageID].src;
			if (imagesrc.indexOf("Open")!=-1) 
				return true;
		}
	}
	return false;
}

function closeAllImages() {
	if (!DHTML) return;

	objectnamearray = new Array("convenience", "versatility", "performance", "security", "certification","compatibility", "systemreqs", "whatsincluded", "techspecs", "datasheets", "related_products");
	for (var i=0; i<objectnamearray.length; i++){
		if (objExists(objectnamearray[i]+"_detail")) {
			imageID = objectnamearray[i] + "_image";
			imagesrc = document.images[imageID].src;
			if (imagesrc.indexOf("Open")!=-1) 
				document.images[imageID].src = imagePath + "roundButtonClosed.gif";
		}
	}
}


/*-----------------functions for Test expandable rows--------------------*/
/*
function hideAll_test() {
	objectnamearray = new Array("test_detail");
	for (var i=0; i<objectnamearray.length; i++){
		hidestyle(objectnamearray[i],1);
	}
}

function toggle_test() {
	objectnamearray = new Array("test_detail");
	for (var i=0; i<objectnamearray.length; i++){
			hidestyle(objectnamearray[i]);
	}
}
*/

/*-----------------functions for Cable Modem expandable rows--------------------*/
/*
function hideAll_cablemodem() {
	objectnamearray = new Array("docsis1", "docsis11", "docsis2", "ethernet", "usb");
	for (var i=0; i<objectnamearray.length; i++){
		hidestyle(objectnamearray[i],1);
	}
}

function toggle_cablemodem() {
	objectnamearray = new Array("docsis1", "docsis11", "docsis2", "ethernet", "usb");
	for (var i=0; i<objectnamearray.length; i++){
			hidestyle(objectnamearray[i]);
	}
}
*/

/*-----------------functions for Ethernet Router expandable rows--------------------*/
/*
function hideAll_ethernet() {
	objectnamearray = new Array("base_t", "duplex");
	for (var i=0; i<objectnamearray.length; i++){
		hidestyle(objectnamearray[i],1);
	}
}

function toggle_ethernet() {
	objectnamearray = new Array("base_t", "duplex");
	for (var i=0; i<objectnamearray.length; i++){
			hidestyle(objectnamearray[i]);
	}
}
*/

/*-----------------functions for Wireless Access Point expandable rows--------------------*/
/*
function hideAll_wap() {
	objectnamearray = new Array("wifi");
	for (var i=0; i<objectnamearray.length; i++){
		hidestyle(objectnamearray[i],1);
	}
}

function toggle_wap() {
	objectnamearray = new Array("wifi");
	for (var i=0; i<objectnamearray.length; i++){
			hidestyle(objectnamearray[i]);
	}
}
*/

/*-----------------functions for Security expandable rows--------------------*/
/*
function hideAll_security() {
	objectnamearray = new Array("standby", "firewall");
	for (var i=0; i<objectnamearray.length; i++){
		hidestyle(objectnamearray[i],1);
	}
}

function toggle_security() {
	objectnamearray = new Array("standby", "firewall");
	for (var i=0; i<objectnamearray.length; i++){
			hidestyle(objectnamearray[i]);
	}
}
*/