function hideLayer(theLayer) {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById(theLayer).style.display = 'none';
	}
	else {
		if (document.layers) {  // Netscape 4
			document[theLayer].visibility = 'hidden';
		}
		else {  // IE 4
			document.all[theLayer].style.display = 'none';
		}
	}
}
function showLayer(theLayer) {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		document.getElementById(theLayer).style.display = 'block';
	}
	else {
		if (document.layers) {  // Netscape 4
			document[theLayer].visibility = 'visible';
		}
		else {  // IE 4
			document.all[theLayer].style.display = 'block';
		}
	}
}

function toggleLayer(theLayer) {
	if (document.getElementById) {  // DOM3 = IE5, NS6
		if (document.getElementById(theLayer).style.display == 'none' || document.getElementById(theLayer).style.display == '')
			showLayer(theLayer);
		else
			hideLayer(theLayer);
	}
	else {
		if (document.layers) {  // Netscape 4
			if (document[theLayer].visibility == 'hidden')
				showLayer(theLayer);
			else
				hideLayer(theLayer);
		}
		else {  // IE 4
			if (document.all[theLayer].style.display == 'none')
				showLayer(theLayer);
			else
				hideLayer(theLayer);
		}
	}	
}

function toggleClass(theItem, class1, class2) {
	if (theItem.className == class1)
		theItem.className = class2;
	else
		theItem.className = class1;
}

function popupWindow(mypage, myname, w, h, myprops) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl;
	
	var adDefaultProps = false;
	if (typeof myprops != "undefined") {
		if (myprops != '') {
			winprops = winprops + ',' + myprops;
		}
		else {
			adDefaultProps = true;
		}
	}
	else {
		adDefaultProps = true;
	}
	
	if (adDefaultProps) {
		winprops = winprops + ',scrollbars=no,resizable=no';
	}
	
	if (typeof win != 'undefined') win.close();
	
	win = window.open(mypage, myname, winprops)
	//if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	
	/*if (win)
		return true;
	else
		return false;*/
}

function onHidecheckCartChanged() {
	checkCartChanged();
}

setCartOnhide = function() {
	ColdFusion.Window.onHide('shoppingcartwindow', checkCartChanged);
}
centerWindow = function(windowName){
	//Get window object
	myWindow = ColdFusion.Window.getWindowObject(windowName);
	 
	//use the centerfunction to center the window.
	myWindow.center();
}

donothing = function() {
					
}

function getComboVal(comboId) {
	var theVal = document.getElementById(comboId).options[document.getElementById(comboId).selectedIndex].value;
	if (theVal == '') {
		theVal = 1;	
	}
	return theVal;
}

function replace(string,text,by) {
// Replaces text with by in string
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
		newstr += replace(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}

function imposeMaxLength(Object, MaxLen) {
  return (Object.value.length <= MaxLen);
}
