$(document).ready(function(){
	
	$(".list .dragger img").draggable({
	
	containment: 'document',
	revert: 'invalid',
	helper: 'clone',
	zIndex: 100
	
	});
	
	$("#gallery-of-icons img").draggable({
	
	containment: 'document',
	revert: 'invalid',
	helper: 'clone',
	zIndex: 100,
	stop: 
		function(event, ui) 
			{
			$(this).css({'z-index' : '100'});
			$(this).animate({
					marginTop: '0', 
					marginLeft: '0',
					top: '0', 
					left: '0', 
					width: '100px', 
					height: '100px', 
					padding: '0px'
				}, 0);
			}
	});
	
		

	$("#comparatorDrop").droppable({
			tolerance: 'pointer',
			drop:
				function(e, ui)
					{
					var param = $(ui.draggable).attr('name');
					addToComparator(param);
					}

	});
	
// 	$('.horizontal_scroller').SetScroller({	velocity: 	 30,
// 											direction: 	 'horizontal',
// 											startfrom: 	 'right',
// 											loop:		 'infinite',
// 											movetype: 	 'linear',
// 											onmouseover: 'pause',
// 											onmouseout:  'play',
// 											onstartup: 	 'play',
// 											cursor: 	 'pointer'
// 										});
	
// 	$("ul.thumb li").hover(function() {
// 	$(this).css({'z-index' : '120'});
// 	$(this).find('img').addClass("hover").stop()
// 		.animate({
// 			marginTop: '-100px', 
// 			marginLeft: '-100px', 
// 			top: '50%', 
// 			left: '50%', 
// 			width: '200px', 
// 			height: '200px',
// 			padding: '0px' 
// 		}, 200);
// 	
// 	} , function() {
// 	$(this).css({'z-index' : '100'});
// 	$(this).find('img').removeClass("hover").stop()
// 		.animate({
// 			marginTop: '0', 
// 			marginLeft: '0',
// 			top: '0', 
// 			left: '0', 
// 			width: '100px', 
// 			height: '100px', 
// 			padding: '0px'
// 		}, 400);
// 	});
	
	 $('#comparatorDrop').scrollFollow({
		speed: 1000,
		offset: 30,
		container: 'content'
	   });
	   
		$('li.headlink').hover(
			function() { $('ul', this).css('display', 'block'); },
			function() { $('ul', this).css('display', 'none'); });


	  $('#dialog').jqm();
	  $('#error').jqm();
	  
	  $('#package-discount').bt('since 4 and more families in the cart, your total is automatically discounted');
	  
	  $('#bulk-discount').bt('since 4 and more fonts in the cart, your total is automatically discounted');
	  
	  $('#discount-voucher').bt('educational or distributor discount. To apply for a discount voucher, send us either student/teacher ID or your wholesale  request.');
	  
});


function addToComparator(param) {
	$.ajax({
	type: "GET",
	url: "/ajax/addToComparator.php",
	data: 'id='+encodeURIComponent(param),
	dataType: 'json',
	success: function(msg){
		$('#comparatorContent').append(msg.html);
		}
	});
}



function removeFromComparator(param) {
	$.ajax({
	type: "GET",
	url: "/ajax/remFromComparator.php",
	data: 'id='+encodeURIComponent(param),
	dataType: 'json',
	success: function(msg){
		$('#'+msg.id).remove();
		}
	});
}



function toggleOrderDetails(element_id) {
	
	var elements = document.getElementsByClassName('o'+element_id);
	var element = document.getElementById('o'+element_id);
	
	if (element.className == 'head')
		{
		element.className = '';
		}
	else
		{
		element.className = 'head';
		};
		
	for(i=0;i<elements.length;i++) {
		if (element.className == 'head')
			{
			elements[i].style.display = 'table-row';
			}
		else
			{
			elements[i].style.display = 'none';
			}
		};
	return true; 
	}
	
function toggleInvoicingAddress(checkbox) {
	if (checkbox.checked)
		document.getElementById('invoicing').style.display = 'block';
	else
		document.getElementById('invoicing').style.display = 'none';
	return true;
	}
	
function showOverview() {
	document.getElementById('overview').style.display='block'; document.getElementById('gallery').style.display='none'; document.getElementById('stripTransmitter0').style.display='none'; document.getElementById('description').style.display='none'; document.getElementById('liOverview').className='active'; document.getElementById('liGallery').className=''; document.getElementById('family-description').style.display='block'; document.getElementById('family-icon').style.display='inline-block'; 
	}
	
function showGallery() {
	document.getElementById('overview').style.display='none';
	document.getElementById('gallery').style.display='block'; 
	document.getElementById('stripTransmitter0').style.display='block'; 
	document.getElementById('description').style.display='block'; 
	document.getElementById('liOverview').className=''; document.getElementById('liGallery').className='active'; document.getElementById('family-description').style.display='none'; document.getElementById('family-icon').style.display='none'; 
	}

