Cufon.replace('h1', { fontFamily: 'American Typewriter Light' });
Cufon.set('fontFamily', 'American Typewriter Medium');
Cufon.replace('h2.full');
Cufon.replace('h2');
Cufon.replace('#side_col h2');
Cufon.replace('#topnav li a', {
	hover: true
});
Cufon.replace('#basket_title');
Cufon.replace('#other_actions ol li a', {
	hover: true
});
Cufon.replace('.submit');
Cufon.replace('.incentive');
Cufon.replace('.promo_price', { fontFamily: 'American Typewriter Bold' });
Cufon.replace('h3.how', { fontFamily: 'American Typewriter Bold' });
Cufon.replace('h2.bold', { fontFamily: 'American Typewriter Medium' });


$(document).ready(function() {
	
	function getLines(id)
    {
      return $('#' + id).val().split("\n").length
    }

  $('#message').keyup(function() 
  {
    var allowedNumberOfLines = 3;
    
    if(getLines('message') > allowedNumberOfLines)
    {
      modifiedText = $(this).val().split("\n").slice(0, allowedNumberOfLines);
      $(this).val(modifiedText.join("\n"));
    }
  });
  
	$("#footer ul li:last-child").css("background-image", "none");
	
	function refreshBasket()
	{
		$.get('/checkout/order/basket/basket_readonly/0/display_delivery_details/1/disable_remove/1/disable_preview/1/ajaxProcess/1', function(data) {
			if(data != null)
			{
				$('#basket').html(data);
				Cufon.replace('h2', { fontFamily: 'American Typewriter Light' });
			}
			});

	}
	
		//fancy box
		$('.view_demo, .view_card').live('click', function(){
			$(this).fancybox({
			'width'				: 650,
			'height'			: 700,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
			//,'onClosed'			: function() { window.location.href= window.location.href;   }	
		}).trigger("click");
		return false;
		});
		
		$('.view').live('click', function(){
			$(this).fancybox({
			'width'				: 650,
			'height'			: 700,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
			,'onClosed'			: refreshBasket
		}).trigger("click");
		return false;
		});

		$('.personalise').live('click', function(){
			$(this).fancybox({
			'width'				: 650,
			'height'			: 700,
			'autoScale'			: false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'type'				: 'iframe'
			,'onClosed'			: refreshBasket

		}).trigger("click");
		return false;
		});		
		
		$('.personalise_close').live('click',function(){
			parent.$.fancybox.close();
		    return false;
		});
		

		// Pop up calendar
		$("#delivery_date").datepicker({ dateFormat: 'dd/mm/yy' ,minDate: +1});
		
		// Gift category show hide list
		
		$("#view_gifts ul > li").slice(1,5).css("display","block");
		$("#view_gifts ul li a.view_all, #view_gifts ul li a#menu-all").parent().css("display","block");
		
		$("#view_gifts ul li a.view_all").click(function(){
			$("#view_gifts ul li").toggleClass("reveal");
			  $(this).text($(this).text() == 'Minimise categories' ? 'View all categories' : 'Minimise categories');
		});	
		
		//carousel
		

		
		
		// email function
		
		        $(".email").click(function() {
           window.location = "mailto:"+"?subject=Daily Mail and General Trust" + "&body=" + "I thought this link might interest you: " + document.title + ", which is available at the following address, " + document.location;
        	return false;
        });  
		
			
});


