$(document).ready(function() {
		$('.slideshow').cycle({ 
		    fx: 'wipe',
		    cssBefore: { 
		       clip: 'rect(0px 380px 0px 250px)' 
		    }  
		});
		
		/**
		 * Use slideshow module to display testimonials in divs
		 */
		$('.testimonials').cycle({
			fx: 'fade',
			timeout: 10000,
			random: 1
		});	
		
		/**
		 * If the main window is not the height of the viewable area then we force it
		 * to fill available vertical space. This is because CSS does not support
		 * automatic vertical margins.
		 */
		if( ( $('.main').height() + $('.header').height() ) < $(window).height() )
		{
			$('.main').height( $(window).height() - $('.header').height() );
		}
		
		/**
		 * Hide details on checkout form
		 */
		$('#whereheard_details').hide();
		$('.whereheard_details_label').hide();
		$('#whereheard').change(function() { onWhereHeardChange(); });

		product = getURLParameter('product');
    		if(product.length > 1) {
			$('fieldset .product-' + product).show();
		} else {
			$('fieldset .product-lifetime').show();
		}
		$('#price').val($('fieldset .product:visible').attr('data-price'));
	});

function getURLParameter(name) {
    return decodeURI(
        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
    );
}


	
	function onWhereHeardChange()
	{
		if($('#whereheard').val() != '---')
		{
			if($('#whereheard').val() == 'Telephone Call')
			{
				$('.whereheard_details_label').text("Which advisor did you speak to?");
			}
			else if($('#whereheard').val() == 'Print Advert')
			{
				$('.whereheard_details_label').text("Which publication did you see the advert in?");
			}
			else if($('#whereheard').val() == 'Search Engine')
			{
				$('.whereheard_details_label').text("Which search engine did you find us through?");
			}
			else if($('#whereheard').val() == 'Word of Mouth')
			{
				$('.whereheard_details_label').text("Who recommended you to us?");
			}
			
			$('#whereheard_details').show('slow');
			$('.whereheard_details_label').show('slow');			
		}
		else
		{
			$('#whereheard_details').hide('slow');
			$('.whereheard_details_label').hide('slow');		
		}
	}

