$(document).ready(function()
{ 
	$(document).pngFix();
	$('.generic-button .hitbox').click(initGenericButtons);
	
	insertMacHack();
	initGenericButtons();
	setupArrowLinksHover();
}); 

function initGenericButtons()
{
	$('.generic-button')
   		.each(
			function()
			{
				var hitbox 	= $(this).find('.hitbox');
				hitbox.height('100%');
				hitbox.width($(this).width());
			}
		);
}

$(document)
	.ready(
		function()
		{
			$('#form-update-basket')
				.find('.generic-button.update .hitbox')
					.click(
						function()
						{
							$(this).parents('form').submit();
						}
					)
				.end()
				.find('.delete')
					.click(
						function()
						{
							var $this 		= $(this);
								$this.parents('tr')
									 .find('input')
									 .val(0)
									 .end()
									 .parents('form')
									 	.submit();
						}
					).css('cursor', 'pointer')
				.end()
				.find('.generic-button.forward .hitbox')
					.click(
						function()
						{
							redirect('basket/details/');
						}
					);
		
			$('#form-details')
				.find('#billing-checkbox')
					.click(
						function()
						{
							$('#form-billing-address-elements').toggleClass('hidden');
						}
					);
					
			$('#form-approve')
				.find('.terms-condition-link')
					.click(
						function()
						{
							$('#lightbox-terms').insertBefore('#canvas');
							lightbox_show('lightbox-terms');
							initGenericButtons();
							sifrGenericButtons();
							sifrHeadlines();
						}
					);
					
			$('#lightbox-terms')
				.find('.generic-button')
					.click(
						function()
						{
							$(this).parents('.lightbox').hide();
						}
					)
					.end()
						.find('.terms-checkbox input')
							.click(
								function()
								{
									$(this).parents('.lightbox').hide();
									$('#terms-and-conditions').val(1);
									
									$('#form-approve').submit();
								}
							);
		
		
		
		}
	);