// fix dropdown nav in IE6 (http://alistapart.com/articles/horizdropdowns)
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}
document.observe("dom:loaded",function() {
	// make the content fit the page height
	centercolHeight = document.viewport.getHeight()-340 ;
	if (centercolHeight > 330) {
		$('centercol').setStyle({height:centercolHeight+'px'});
	}
	startList;
})
/* used in bestwineriesbyregion */
function getCurrentStyle(id,s) {
	if(document.all) {
		return document.all[id].style[s];
	} else if(document.getElementById) {
		return document.getElementById(id).style[s];
	} else {
		return "";
	}
}
/* used in bestwineriesbyregion and vintagechart */
function setStyle(id,s,v) {
	if(document.all) {
		document.all[id].style[s] = v;
	} else if(document.getElementById) {
		document.getElementById(id).style[s] = v;
	}
}
/* next 2 used in vintagechart, obviously */
function switchVintageChart () {
	if(Element.getStyle('vintage_chart_old','display') == 'none') {
		Element.setStyle('vintage_chart_recent', {display:'none'});
		new Effect.Appear('vintage_chart_old');
	} else if (Element.getStyle('vintage_chart_recent','display') == 'none') {	
		Element.setStyle('vintage_chart_old', {display:'none'});
		new Effect.Appear('vintage_chart_recent');
	}
}
function switchVintageChart () {
	if(Element.getStyle('vintage_chart_old','display') == 'none') {
		Element.setStyle('vintage_chart_recent', {display:'none'});
		new Effect.Appear('vintage_chart_old');
	} else if (Element.getStyle('vintage_chart_recent','display') == 'none') {	
		Element.setStyle('vintage_chart_old', {display:'none'});
		new Effect.Appear('vintage_chart_recent');
	}
}
/* used in bestwineriesbyregion */
function toggleRegion(rid) {
	if(getCurrentStyle('r'+rid,'display') == 'none') {
		/* I put some style just for testing ajax works
		 * and give myself some visual illusion, it's 
		 * ugly, it will be styled by charles eventually.
		 */
		$('extensible'+rid).setStyle({
			backgroundColor: '##c8939D',
			fontSize: '12px'
		});
	} else {
		$('extensible'+rid).setStyle({
			backgroundColor: '##FFFFFF',
			fontSize: '12px'
		});
	}
	new Effect.toggle('r'+rid,'appear');
	return false;
}
/* Left and Right function like CF ones (hard to find out whether these are ever used)*/
/* 
function Left(str, n){
	if (n <= 0) return "";
	else if (n > String(str).length) return str;
	else return String(str).substring(0,n);
}
function Right(str, n){
	if (n <= 0) return "";
	else if (n > String(str).length) return str;
	else {
	   var iLen = String(str).length;
	   return String(str).substring(iLen, iLen - n);
	}
}
*/