<!--
//<![CDATA[		   
window.addEvent('domready', function() {

	// Print page
	$('printFunction').addEvent('click', function(evt) { 
		var evt = new Event(evt); 
		window.print();	
		evt.preventDefault();
	});
	
	/* ---------------------------------------------------------------------------------------- */
	/* DOC CART  */
	
	var docCart = {
		
		activeCart: false,	
		
		setupCart: function() {
			$('documentsDialogue').setOpacity(0);
			$('activateDocCart').addEvent('click',function(e){			
				e = new Event(e);
				e.preventDefault();			
				var anim = (docCart.activeCart) ? docCart.hideCart() : docCart.showCart();				
			});
		},
		
		bindLinks: function() {
			$$('a.DocCartLink').addEvent('click', function(evt) { 
					
					evt = new Event(evt);			
					evt.preventDefault();
								
					var obj = this;
					var docid = obj.getProperty("rel");
					
					var addToCart = new Ajax('/ajax/inc_download.asp?action=ADDTOCART&id=' + docid, {
						method: 'get', 
						async: true, 
						autoCancel: true,
						onSuccess: function(msg) {
							$('documentsCartContent').setHTML(msg);
							var td = obj.getParent();
							td.setHTML("Added...");
						},
						onFaliure: function() {
							alert("ERROR!");
						}
					}).request();
					
					// Show cart
					docCart.showCart();	
					
					// Fade cart out after 1 second
					setTimeout("docCart.hideCart()", 2000);
		
			});		
		},
		
		showCart: function() {
	
			// Step 1 - populate cart
			var popCart = new Ajax('/ajax/inc_download.asp?action=REFRESH', {
				method: 'get', 
				async: true, 
				autoCancel: true,
				onSuccess: function(msg) {
					$('documentsCartContent').setHTML(msg);				
					
					// Add event to clear cart button
					$$('button.ClearCart').addEvent('click', function(evt) {
						evt = new Event(evt);			
						evt.preventDefault();													  
						docCart.clearCart();						
					});
					
					// Add event to download zip'd docs button
					$$('button.DownloadDocuments').addEvent('click', function(evt) {
						evt = new Event(evt);			
						evt.preventDefault();				
						location.replace('/ajax/inc_download.asp?action=DOWNLOAD');	
						docCart.clearCart();
						docCart.hideCart();						
					});
					
					// Bind event to the remove button for each document
					$$('a.DocRemove').addEvent('click', function(evt) { 
						evt = new Event(evt);			
						evt.preventDefault();
						var docid = this.getProperty("rel");
						docCart.removeDoc(docid);
						docCart.showCart();
					});
					
					// Bind the event to the close button on the document cart
					$$('img.documentCartCloseButton').addEvent('click', function(evt) {
						evt = new Event(evt);			
						evt.preventDefault();		
						docCart.hideCart();
					});
					
				},
				onFaliure: function() {
					alert("ERROR!");
				}
			}).request();	
			
			
			// Step 2 - open cart
			docCart.activeCart = true;
			var fxFade = new Fx.Style('documentsDialogue', 'opacity', {duration: 150});
			$$("#documentsDialogue").setStyle("display", "block");
			fxFade.start(1);
		},
		
		hideCart: function() {
			docCart.activeCart = false;
			var fxFade = new Fx.Style('documentsDialogue', 'opacity', {duration: 150});	
			
			fxFade.start(0);
			$$("#documentsDialogue").setStyle("display", "none");
		},
		
		clearCart: function() {
			var clearCart = new Ajax('/ajax/inc_download.asp?action=CLEAR', {
				method: 'get', 
				async: true, 
				autoCancel: true,
				onSuccess: function(msg) {
					$('documentsCartContent').setHTML(msg);
				},
				onFaliure: function() {
					alert("ERROR!");
				}
			}).request();		
		},
		
		removeDoc: function(docid) {
			var removeFromCart = new Ajax('/ajax/inc_download.asp?action=REMOVE&id=' + docid, {
				method: 'get', 
				async: true, 
				autoCancel: true,
				onSuccess: function(msg) {
					$('documentsCartContent').setHTML(msg);
				},
				onFaliure: function() {
					alert("ERROR!");
				}
			}).request();		
		},
		
		init: function() {
			this.setupCart();
			this.bindLinks();
		}
		
	};

	docCart.init();
	
	
});

Cufon.replace('h1', { fontFamily: 'myriad-pro' });
Cufon.replace('h2', { fontFamily: 'myriad-pro' });

//]]>