
function changeColour(elementId) {
    var interval = 1000;
    var colour1 = "#ff0000"
    var colour2 = "#000000";
    if (document.getElementById) {
        var element = document.getElementById(elementId);
        element.style.color = (element.style.color == colour1) ? colour2 : colour1;
        setTimeout("changeColour('" + elementId + "')", interval);
    }
}


function expandGroupById(productGroupId) {
	expandGroup(productGroupId, true);
}

function expandGroup(productGroupId, noCollapse) {
	var divCn = null;
	var catDivCn = null;
	var link = null;
	var linkSrc;
	var expanded;
	var dh;
	
	// get the divs
	var div = document.getElementById("pc" + productGroupId);
	catDiv = document.getElementById("_" + div.id);
	
	if (div.className.lastIndexOf("-e") > 0) {
		if (noCollapse) return;
		divCn = "productgroup-c";
		catDivCn = "productcategory-h";
		expanded = false;
		dh = -catDiv.height;
	} else {
		divCn = "productgroup-e";
		catDivCn = "productcategory-v";
		expanded = true;
		dh = catDiv.height;
	}
	
	var th = div.parentNode;
	th.height = th.height + dh;
	// linkSrc = groupSwitchUrl + "&expanded=" + expanded;
	linkSrc = "/client/product/groupswitch.tile?productGroupId=" + productGroupId + "&expanded=" + expanded;

	if (document.getElementById) {
		var objXml = null;
		try {
			objXml = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (Exception) {
			// noop
		}

		if (objXml == null) {
			try {
				objXml = new XMLHttpRequest();
			} catch (Exception) {
				// noop
			}
		}
		
		var changeLinkSrc = true;
		try {
			objXml.open("GET", linkSrc, false);
			objXml.send(null);
			changeLinkSrc = objXml.responseText.length == 0;
		} catch (e) {
			
		} 
		
		if (changeLinkSrc) {
			link = document.getElementById("__" + div.id);
			link.src = linkSrc + "&img=true";
		}
    }
    
	div.className = divCn;
	catDiv.className = catDivCn;
}

function setClassName(element, className) {
	element.className = className;
}
