$(function(){

	$('ul.siteNav > li').bind('mouseover', jsddm_open);
	$('ul.siteNav > li').bind('mouseout',  jsddm_timer);
	
	$('div.date_select_container select').each(function(){
		$(this).change(function(){
			var objCont = $(this).parent();
			
			var date = $('select.date_select_year',objCont).val()+'-'+$('select.date_select_month',objCont).val()+'-'+$('select.date_select_day',objCont).val();
			$('input.date_select_hidden',objCont).val(date);
		});
	});
	
	
	
	// tick under 25 to enable age input box (was select dropdowns for dob)
	$('input.chkDoB').click(function(){
		if($(this).attr('checked') == true){
			$('input.age',$(this).parent().parent()).attr('disabled','');
		}else{
			$('input.age',$(this).parent().parent()).attr('disabled','disabled').val('00');
			$('input.date_select_hidden',$(this).parent().parent()).val('0000-00-00');
		}
	});
	/*
	$('input.chkDoB').click(function(){
		if($(this).attr('checked') == true){
			$('select',$(this).parent().parent()).attr('disabled','');
		}else{
			$('select',$(this).parent().parent()).attr('disabled','disabled').val('00');
			$('input.date_select_hidden',$(this).parent().parent()).val('0000-00-00');
		}
	});
	*/
	
	
	/*
	$('#calendar2select').livequery('change',function(){
		$('#calendar_wrap').html(calLoadHtml).load('/p/calendar2.php'+$(this).val());
	});
	*/
	
	$('#calendar_wrap3_select').livequery('change',function(){
		var divWrap = $(this).attr('id').replace('_select','');
		$('#'+divWrap).html(calLoadHtml).load('/p/calendar3.php'+$(this).val());
	});
	
	$('#lightBox a').lightBox();
	
	
		$('.imageCycle').cycle(
		{
			fx: 'fade',
			speed: 2000,
			timeout: 6000,
			pause: 1
		}).css('visibility','visible');
	
		if($('#s3slider').length > 0){
			$('#s3slider').s3Slider({
		    	timeOut: 6000
		    });
		}
		
	
	
		
	
	
	$(".JqAccordion div.title").click(function(){
		if($.browser.msie && $.browser.version <= 7){
			$(".JqAccordion div.content.current div.contentInner").hide();
		}
		$(".JqAccordion div.content.current").animate({width:0},500);
		$(".JqAccordion .title.current img").attr('src',$(".JqAccordion .title.current img").attr('src').replace('-b.','-a.'));
		$(".JqAccordion .current").removeClass('current');
		$(this).addClass('current').next().animate({width:249},500,function(){
			if($.browser.msie && $.browser.version <= 7){
				$(".JqAccordion div.content.current div.contentInner").show();
			}
		}).addClass('current');
		$(".JqAccordion .title.current img").attr('src',$(".JqAccordion .title.current img").attr('src').replace('-a.','-b.'));
	});
	
	$('.JqAccordion div.content').each(function(){
		
		if($('a',this).length > 0){
			$(this).css('cursor','pointer').click(function(){
				window.location.href = $('a',this).attr('href');
			});
		}
		
	});
	
	if($.browser.msie && $.browser.version <= 7){
		$(".JqAccordion div.set:eq(0) div.title").trigger('click');
	}
	
	$('#selPaymentMethod').change(function(){
		
		if($(this).val()=='card'){
			$('#card_wrap').show();
			$('#bacs_wrap').hide();
			$('#cheque_wrap').hide();
		}
		if($(this).val()=='bacs'){
			$('#card_wrap').hide();
			$('#bacs_wrap').show();
			$('#cheque_wrap').hide();
		}
		if($(this).val()=='cheque'){
			$('#card_wrap').hide();
			$('#bacs_wrap').hide();
			$('#cheque_wrap').show();
		}
		
	});
	
	var hIconfig = {
		over:	function(){
					var height = $('#quickview p').height() + $('#quickview ul').height();
					$('#quickview').animate({height:height+'px'},300);
				},
		timeout: 500,	
		out:	function(){
					var height = $('#quickview p').height();
					$('#quickview').animate({height:height+'px'},300);
				}
	};
	
	$('#quickview').hoverIntent(hIconfig);
	
	$('.fadedBackground').css('opacity',0.85);
	$('#lightbox-nav-btnPrev, #lightbox-nav-btnNext').css('zoom',1);
	$('#s3slider h2 span').css('opacity',1);
	
	$('.s3sliderImage div').css('opacity',0.85);
	
	resizeContent();
	$(window).resize(function() {
		resizeContent();
	});
	
});

