function changeMakeTab(id,count) {
	for(i=1; i<=count; i++) {
		var tabId = 'tab' + i;
		if(document.getElementById(tabId) != null) {
			document.getElementById(tabId).className = '';
		}
	}

	tabId = 'tab' + id;
	if(document.getElementById(tabId) != null) {
		document.getElementById(tabId).className = 'selected';
		changeCategoryTab(tabId+'cat1', id, count);
	}
}

function changeCategoryTab(id, num, count) {
    //loop through the categories, turn them all off, then turn on the right on
	for(i=1; i<=count; i++) {
		//turn off all the rows
		var trId = 'tr' + i;
		if(document.getElementById(trId) != null) {
			document.getElementById(trId).className = '';
		}	
	
		for(j=1; j<6; j++) {
			var tabId = 'tab' + i + 'cat' + j;
			if(id == 'tab'+i+'cat'+j) {
				if(document.getElementById(tabId) != null) {
					document.getElementById(tabId).className = 'selected';
				}
				if(document.getElementById(tabId+'text') != null) {
					document.getElementById(tabId+'text').className = 'selected';	
				}
			} else {
				if(document.getElementById(tabId) != null) {
					document.getElementById(tabId).className = '';
				}
				if(document.getElementById(tabId+'text') != null) {
					document.getElementById(tabId+'text').className = '';	
				}
			}
		}
	}

	//turn on the right row
	if(document.getElementById("tr"+num) != null) {
		document.getElementById("tr"+num).className = 'selected';
	}
}

function viewChildData(id, count) {
	for(i=1; i<=count; i++) {
		var len = id.length;
		len = len - 1;
		var c = id.substring(0,len);
		var cId = c + i;
		if(document.getElementById(cId) != null) {
			if(document.getElementById(id).className != 'selected')
				document.getElementById(cId).className = '';
		}
	}
	if(document.getElementById(id) != null) {
		//alert(id +" selected");
		if(document.getElementById(id).className == 'selected')
			document.getElementById(id).className = '';
		else 
			document.getElementById(id).className = 'selected';
	}	
}

function viewDealerMap(id,count) {
	//alert("Load Google Map");
	/*
	for(i=1; i<=count; i++) {
		var mapId = 'gmap' + i;
		if(document.getElementById(mapId) != null) {
			document.getElementById(mapId).className = '';
		}
	}

	mapId = 'gmap' + id;
	if(document.getElementById(mapId) != null) {
		alert("got here");
		document.getElementById(mapId).className = 'selected';
	}
	*/
}

function popup(name) {
	document.getElementById(name).style.display = "";
}

function hidePopup(class_name) {
	document.getElementById(class_name).style.display = "none";
}

function viewImage(url) {
 	top.consoleRef = window.open('','window',
  		'width=600,height=600'
   		+',menubar=0'
   		+',toolbar=0'
   		+',status=0'
   		+',scrollbars=0'
   		+',resizable=0');
 	top.consoleRef.document.writeln(
  		'<html><head><title>Bully Dog - View Product Image</title></head>'
   		+'<body bgcolor=white onLoad="self.focus()">'
   			+'<table align="center" width="90%"><tr><td><img src="'+url+'"></td></tr>'
   			+'<tr><td align="center"><a style="color:#ea1c24;" href="javascript:window.close();">Close</a></table>'
   		+'</body></html>');
	top.consoleRef.document.close();
}

tbHover = function() {
	if(document.getElementById("categoryTab") != null) {
	    var el = document.getElementById("categoryTab");
		var sfEls = document.getElementById("categoryTab").getElementsByTagName("td");
	 	for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
	 			this.className+=" sfhover";
	 		}
	 		sfEls[i].onmouseout=function() {
	 			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	 		}
	 	}
	    var el = document.getElementById("makeTab");
		var sfEls = document.getElementById("makeTab").getElementsByTagName("td");
	 	for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
	 			this.className+=" sfhover";
	 		}
	 		sfEls[i].onmouseout=function() {
	 			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
	 		}
	 	} 	
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
if (window.attachEvent) window.attachEvent("onload", tbHover);

function viewMap(id) {
	if(document.getElementById(id).style.display == "")
		document.getElementById(id).style.display="none";
	else 
		document.getElementById(id).style.display="";
}