

window.addEvent('domready', function() {
	$$('div.menuitem').each(function(el) {
		el.addEvent('click', function() {
			document.location = $(this).getElement('a').href;
		});
	});
});

/********** tell a friend *************/
window.form_friend_options = {
	duration:		700,
	transition:		Fx.Transitions.Cubic.easeOut,
	transition_types:	['morph', 'fade'], // morph, fade
	overlay:		{ color: '#000000', opacity: 0.5, close_on_click: false }
};


/********** optin *************/
window.form_subscribe_options = {
	duration:		700,
	transition:		Fx.Transitions.Cubic.easeOut,
	transition_types:	['morph', 'fade'], // morph, fade
	overlay:		{ color: '#000000', opacity: 0.5, close_on_click: true }
};

/******** gallery **********/
window.gallery_options = {
	overlay: 	{ color: '#000', opacity: 0.6, close_on_click: false },
	background: 	'#F9CD0D',
	fontcolor:	'#231F20',
	border:		'solid #231F20 1px',
	padding:	'10px',
	image_dir:	'gallery-n2wines',
	fade_duration:	500,
	morph_duration:	400,
	enable_slideshow: true,
	slideshow_delay: 7000
};



//window.addEvent('domready', function() {
//	// handle navlinkhover boxes
//	$$('div.navlinkbox').each(function(el) {
//		el.addEvent('mouseover', function() {
//			this.addClass('navlinkboxhover');
//		});
//		el.addEvent('mouseout', function() {
//			this.removeClass('navlinkboxhover');
//		});
//	});
//});


// handle rollover images
window.addEvent('load', function() {
	$$('img[rollover=true],input[rollover=true]').each(function(el) {
		var pimg = new Element('img');
		pimg.addEvent('load', function() {
			this.addEvent('mouseover', function() {
				imageRollover(this);
			});
			this.addEvent('mouseout', function() {
				imageRollout(this);
			});
		}.bind(el));
		pimg.src = el.src.replace(/\.([^\.]+)$/, '-over.$1');
	});
});

function imageRollover(that) {
	that = $(that);
	if(!that) return;

	var href = that.src.replace(/\.([^\.]+)$/, '-over.$1');
	var tmp = new Element('img');
	tmp.addEvent('load', function() {
		this.src = href;
	}.bind(that));
	tmp.src = href;
}

function imageRollout(that) {
	that = $(that);
	if(!that) return;

	that.src = that.src.replace(/-over\.([^\.]+)$/, '.$1');
}


window.addEvent('domready', function() {
	// this just fixes navlinkbox elements to allow clicking on the entire box
	$$('div.navlinkbox').each(function(el) {
		if(el.getElement('a')) {
			el.addEvent('click', function() {
				document.location = this.getElement('a').href;
			});
		}
	});

});
// slider-bar-vert


function initContentScroller() {
	var divPagecontent = $('pagecontent');
	var divSlider = $('divContentSlider');
	var divKnob = $('divContentSliderKnob');


	if(!divPagecontent || !divSlider || !divKnob) return;


	if(divPagecontent.getHeight() >= divPagecontent.getScrollHeight()) {
		divSlider.setStyle('display', 'none');
		divKnob.setStyle('display', 'none');
		return;
	}



	new Slider(divSlider, divKnob, {
		snap: false,
		offset: 0,
		wheel: true,
		steps: 100,
		mode:  'vertical',
		initialStep: 0,
		onChange: function(val){
			divPagecontent.scrollTo(0, (val * ( (divPagecontent.getScrollHeight() - divPagecontent.getHeight()) / 100)).toInt() );
		}
	});




}



function t(v) {
	try {
		console.log(v);
	} catch(e) {};
}






