function countInstances(string, word) {
			var substrings = string.split(word);
			return substrings.length - 1;
}
	
function tabSwap(swapTab,content){
	swapTabs = document.getElementById("items").getElementsByTagName("div");
	for(i=0;i<swapTabs.length;i++){
		if(swapTabs[i].id == "infoTab"){
			if(swapTabs[i].id == "infoTab"){
				if(swapTabs[i].className == "infoTabOn"){
					swapTabs[i].className = "infoTabOff";
					for(n=0;n<swapTabs[i].getElementsByTagName("div").length;n++){
						if(swapTabs[i].getElementsByTagName("div")[n].className == "leftOn"){
							swapTabs[i].getElementsByTagName("div")[n].className = "leftOff"
						}
						if(swapTabs[i].getElementsByTagName("div")[n].className == "rightOn"){
							swapTabs[i].getElementsByTagName("div")[n].className = "rightOff"
						}
					}
				}
			}
		}
	}
	
	swapTab.className = "infoTabOn";
	swapTab.getElementsByTagName("div")[0].className = "leftOn";
	swapTab.getElementsByTagName("div")[1].className = "rightOn";
	document.getElementById("homeContent").innerHTML = document.getElementById(content).innerHTML;
}
	
var cTable
var ctRows
var toggleStatus
var toggleAllStatus

function toggleAll(row){
	cTable = document.getElementById("compTable");
	ctRows = cTable.getElementsByTagName("tr");
	ctImg = cTable.getElementsByTagName("img");
	
	if(countInstances(row.childNodes[0].childNodes[0].src,'plus')){
		row.childNodes[0].childNodes[0].src = "images/layout/icon_minus.gif";
		toggleAllStatus = true;
	}else{
		row.childNodes[0].childNodes[0].src = "images/layout/icon_plus.gif";
		toggleAllStatus = false;
	}
	
	for(i=0;i<ctRows.length;i++){
		if(countInstances(ctRows[i].id,'feature')){
			if(toggleAllStatus){
				ctRows[i].style.display = "";
			}else{
				ctRows[i].style.display = "none";
			}
		}
	}
	for(i=1;i<ctImg.length;i++){
		if(countInstances(ctImg[i].src,'icon')){
			if(toggleAllStatus){
				ctImg[i].src = "images/layout/icon_minus.gif"
			}else{
				ctImg[i].src = "images/layout/icon_plus.gif"
			}
		}
	}
}

function toggleRows(row,id,table){
	if(row == "manual"){
		cTable = document.getElementById(table);
	}else{
		cTable = row.parentNode;
	}
	
	if(row != "all"){
		ctRows = cTable.getElementsByTagName("tr");
	}
	
	if(row == "manual"){
		if(countInstances(document.getElementById(id+"_row").childNodes[0].childNodes[0].src,'plus')){
			document.getElementById(id+"_row").childNodes[0].childNodes[0].src = "images/layout/icon_minus.gif";
			toggleStatus = true;
		}else{
			document.getElementById(id+"_row").childNodes[0].childNodes[0].src = "images/layout/icon_plus.gif";
			toggleStatus = false;
		}
	}else if(row == "all"){
		tablesArray = document.getElementById("content").getElementsByTagName("table");
		for(i=0;i<tablesArray.length;i++){
			ctRows = tablesArray[i].getElementsByTagName("tr");
			for(r=0;r<ctRows.length;r++){
				if(id == "open"){
					if( countInstances(ctRows[r].id,"_feature") ){
							ctRows[r].style.display = "";					
					}
					if( countInstances(ctRows[r].id,"_row") ){
							ctRows[r].childNodes[0].childNodes[0].src = "images/layout/icon_minus.gif";					
					}
				}else{
					if( countInstances(ctRows[r].id,"_feature") ){
							ctRows[r].style.display = "none";					
					}
					if( countInstances(ctRows[r].id,"_row") ){
							ctRows[r].childNodes[0].childNodes[0].src = "images/layout/icon_plus.gif";					
					}
				}
			}
		}
	}else{
		if(countInstances(row.childNodes[0].childNodes[0].src,'plus')){
			row.childNodes[0].childNodes[0].src = "images/layout/icon_minus.gif";
			toggleStatus = true;
		}else{
			row.childNodes[0].childNodes[0].src = "images/layout/icon_plus.gif";
			toggleStatus = false;
		}
	}
	
	for(i=0;i<ctRows.length;i++){
		if( countInstances(ctRows[i].id,id) && !countInstances(ctRows[i].id,"_row") ){
			if(toggleStatus){
				ctRows[i].style.display = "";
			}else{
				ctRows[i].style.display = "none";
			}
			
		}
	}
}