$(document).ready(function() {

	// generic vars
	$body = $('body');
	
	// js class
	$body.addClass("js");

	// logged in hover
	$('#account ul li').hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	
	// html to append
	$('#index #news, #index #press').append('<ul class="arrows"><li class="left"><a href="#">Previous</a></li><li class="right"><a href="#">Next</a></li></ul>');
		
	// welcome scroll on homepage
	$('.scrolltext').jScrollPane({
		scrollbarWidth:16,
		dragMinHeight:33,
		dragMaxHeight:33,
		scrollbarMargin:25
	});
	
	// news fader and clickable areas on homepage
	$('#news .news').cycle({
		fx: 'fade',
		prev: '#news .left a',
		next: '#news .right a',
		pause: true
	});
	var $newsitem = $("#news .news .item");
	$newsitem.css('cursor', 'pointer');
	$newsitem.click(function(){
    	window.location=$(this).find("a").attr("href");
		return false;
	});
	
	// new wines clickable areas
	var $newsitem = $("#newWines .wines .item");
	$newsitem.css('cursor', 'pointer');
	$newsitem.hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	$newsitem.click(function() {
    	window.location=$(this).find("a").attr("href");
		return false;
	});
	
	// entire produce of the month click area
	/*var $produceitem = $("#producer");
	$produceitem.css('cursor', 'pointer');
	$produceitem.click(function() {
    	window.location=$(this).find("a").attr("href");
		return false;
	});*/
	
	// wines in the press
	$('#press .press').cycle({
		fx: 'fade',
		prev: '#press .left a',
		next: '#press .right a',
		pause: true
	});
	
	$('#advert .innerad').cycle({
		fx: 'fade',
		pause: true
	});

	
	// shop bin ends
	$('#binend .content .scroller').jScrollPane({
		scrollbarWidth:16,
		dragMinHeight:33,
		dragMaxHeight:33,
		scrollbarMargin:10
	});
	var $shopbinends = $('#binend .content .scroller ul li');
	$shopbinends.css('cursor', 'pointer');
	$shopbinends.hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	$shopbinends.click(function() {
    	window.location=$(this).find("a").attr("href");
		return false;
	});
	
	// entire grid product clickable
	var $shopbinends = $('#shop #content.listing #grid .prod');
	$shopbinends.css('cursor', 'pointer');
	$shopbinends.hover(function() {
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	$shopbinends.click(function() {
    	window.location=$(this).find("a").attr("href");
		return false;
	});
	
	//clearInput('input');
	
});

// focus remove text
function clearInput(fieldType) {
	
	if(!fieldType) {
		var fieldType = 'input[type=text][value]';
	}
	
	var swap_text_boxes = [];
	
	$(fieldType).each(function() {
		swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
	});
	$(fieldType).bind('focus', function() {
		if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
    		$(this).val('');
		}
	});
	$(fieldType).bind('blur', function() {
    	if($(this).val() == '') {
    		$(this).val(swap_text_boxes[$(this).attr('id')]);
		}
	});
}

