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 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(); }
	
}

function showCart(url, w, h) {
	if (typeof w == "undefined") {
		w = 600;
	}
	if (typeof h == "undefined") {
		h = 300;
	}
	popupWindow(url, 'cartwindow', w, h, 'scrollbars=yes,resizable=yes');	
}

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);
}
