$(document).ready(function() {

	// next and back buttons
	$('#showCase p.chev a').html('');
	$('.bigOption a').html('');
	
	// quote panels
	$('#showCase .panelRightQuote .quote').hide();
	$('#showCase .panelRightQuote .quote:eq(0)').show().addClass('quoteShown');
	setNext(1);
	function setNext(no) {
		$('#showCase .panelRightQuote .next').unbind().click(function() {
			if(no == 0) {
				$('#showCase .panelRightQuote .quote:last').fadeOut(function(){
					quoteShow(no);
				});
			} else {
				$('#showCase .panelRightQuote .quote:eq('+(no-1)+')').fadeOut(function(){
					quoteShow(no);
				});
			}
			return false;
		});
	}
	function quoteShow(no) {
		$('#showCase .panelRightQuote .quote:eq('+no+')').fadeIn(function() {
			var next = no+1;
			if($('#showCase .panelRightQuote .quote:eq('+next+')').length > 0) {
				setNext(next);
			} else {
				setNext(0);
			}
		});
	}
	
	// menu panel
	$('#subMenu').hide();
	$('#subMenuWrap').prepend('<a href="#" class="openMenu">menu</a>');
	$('.openMenu').hover(function() {
		$('#subMenu').show();
	},function() {
	});
	$('#subMenuWrap').hover(function() {
	},function() {
		$('#subMenu').hide();
	});

	
	// reveal from left to right
	$('div.reveal:not(.keep)').hide();
	if($('ul.reveal li span').length > 0) {
		$('ul.reveal li span').wrap('<a></a>');
	} else if($('ul.reveal li').length > 0) {
		$('ul.reveal li').wrapInner('<a></a>');
	}
	$('ul.reveal li a').each(function() {
		var cName = $(this).parent().attr('class');
		$(this).click(function() {
			if($('.leaveBg').length == 0) {
				$('div#showCaseWrap').css({'background-image':'none'});
				$('div#showCase').css({'background-image':'none'});
			}
			$('div.reveal').hide();
			$('div.reveal.'+cName).fadeIn();
		}).css({cursor:'pointer'});
	});
	
	$('.claimseat #contact').hide();
	$('.nominate #contact').hide();


});


//ECL'S SHOP FUNCTION
function productAdd (token,id,q,a1,v1,a2,v2) {
	$.post(
		"/php_pay/api.php",
		{
			"action":		"basketAdd",
			"productId":	id,
			"quantity":		q,
			"attribute_1":	a1,
			"value_1":		v1,
			"attribute_2":	a2,
			"value_2":		v2
		},
		function (xml) {
			//alert(var_dump(xml));
			if(token) {
				window.location = '/'+token+'/basket';
			} else {
				window.location = '/basket';
			}

		}
	);
}

