if(typeof($) != 'undefined')
{
    //setup vars go here
    
    $(document).ready(function(){
        
        //don't put code in here, call functions!
        setupExternals();
        iPadGallery();
        termsTicked();
    }); 
    
    //put jquery functions here, in order they are called in ready function
    function setupExternals()
    {
        $('a.external').attr('target','_blank');
    }
    
    function iPadGallery()
    {
		$('.iPadGalleryThumb').click(function(e){
			
			e.preventDefault();
			var swap = $(this).attr('href');
			$('#iPadMainImage').attr('src', swap);
		});    
	}
	
	function termsTicked()
	{
		$('.productOption input').click(function(e){
			
			var termsCheck = document.getElementById('termsCheck');
			if(!termsCheck.checked)
			{
				alert('Please read our terms and conditions and tick the box to confirm');
				return false;
			}	
		});
		
		$('.buyiPadItem input').click(function(e){
			
			var termsCheck = document.getElementById('termsCheck');
			if(!termsCheck.checked)
			{
				alert('Please read our terms and conditions and tick the box to confirm');
				return false;
			}	
		});
	}
}
