function myInit() {	
	
	$("a[href^='http:']").not("[href*='navigateevents.com']").attr('target','_blank');
	$('#navigation > ul > li:last > a').css('border','none');
	
	$('.trafficLights li').hover(function () {
		var id = this.id;	
		id = id.replace('tl_','');
		$('.trafficLights li#tl_'+id+' div.off').hide();
		$('.trafficLights li#tl_'+id+' div.overlay').hide();
		$('.trafficLights li#tl_'+id+' div.on').show();
		
		}, 
		function () {
		var id = this.id;
		id = id.replace('tl_','');
		$('.trafficLights li#tl_'+id+' div.off').show();
		$('.trafficLights li#tl_'+id+' div.overlay').show();
		$('.trafficLights li#tl_'+id+' div.on').hide();
		
		}
		);

	$('.trafficLights li div.on').click(function() {		
		href = $(this).find('a:first').attr('href');
		document.location.href = href;
		});

	
	$('#paragraphNav > li').click(function() {
		var navId = this.id;
		$('#paragraphNav > li').removeClass('selected');	
		$('#'+navId).addClass('selected');		
		var paragraphId = navId.replace('m','p');
		$('#paragraphs > div').hide();
		$('#'+paragraphId).show();
		return false;
		});
	
	$("#gallery li img").hover(function () {
		var gallId = this.id;							 	
		title = $('#'+gallId).attr('alt');		
		$('#galleryTitle').html(title);
		}, 
		function () {
			$('#galleryTitle').html('');
		}
		);

	
	$('#gallery li img').click(function() {
		
		var gallId = this.id;
		
		$.ajax({
			type: "POST",
			url: "/loadImage.php",
			data: "gallId="+gallId,
			success: function(returned){								
				$("#homeSubNav").css('background-image','url("'+returned+'")');
				}
			});	
		
		});
	
	$('.qty').attr('readonly','readonly');
	
	$('.qty_control a.minus').click(function() {
		
		ticketId = this.id;
		fieldId = ticketId.replace('minus_','qty_');
		currentValue = $('#'+fieldId).val();		
		if (currentValue > 0) {
			
			newValue =  Number(currentValue-1);
			$('#'+fieldId).val( newValue );
			
			// update the basket table, and get new total price
			if ($('#update_basket').val() == 'true') {
				$.ajax({
				type: "POST",
				url: "/update_basket.php",
				data: "basketId="+fieldId+"&qty="+newValue,
				success: function(returned){								
					$("#grand_total").html(returned);
					}
				});
				}
			}
		return false;
		});		
	
	$('.qty_control a.plus').click(function() {
		
		ticketId = this.id;
		fieldId = ticketId.replace('plus_','qty_');
		
		newValue = (Number($('#'+fieldId).val()) + 1);
		$('#'+fieldId).val( newValue );
		
		// update the basket table, and get new total price
		if ($('#update_basket').val() == 'true') {
			$.ajax({
				type: "POST",
				url: "/update_basket.php",
				data: "basketId="+fieldId+"&qty="+newValue,
				success: function(returned){								
					$("#grand_total").html(returned);
					}
				});
			}
		return false;
		});								 
	
	
	$('#checkout').click(function() {
		
		// dont allow zero values
		var total = 0;
		$('.qty').each(function() {
			total += $(this).val();
			});
								
		if (total == 0) {
			alert('You have not chosen any tickets to purchase');
			return false;
			}
		
		// dont allow multiple events to reside on the same basket
		eventId = $('#eventId').val();
		$('#checkout').val('Please wait...');
		$.ajax({
			type: "POST",
			url: "/checkBasket.php",
			data: "eventId="+eventId,
			success: function(returned){								
				if (returned) {
					
					msg = 'Your shopping basket contains tickets from another event. It is only possible to purchase tickets from one event at a time.\n\n';
					msg += 'Click OK to continue adding these tickets. This will remove all other tickets from your basket.\n\n';
					msg += 'Or click CANCEL to cancel adding these tickets and leave the existing tickets in the basket.';
		
					var answer = confirm(msg);
					if (answer){		
						$('#checkoutForm').submit();
						}
					
					} else {
					$('#checkoutForm').submit();
					}
					
				}
			});	

		return false;
		});
	
	$('#confirm_order').submit( function() {

		if ($('#terms').is(':checked')) {
			return true;
			} else {
			alert('Please agree to our terms and conditions');
			return false;
			}

		});
	
	$('.passwordReminder').click(function() {		
		window.open( "/password_reminder.php", "myWindow", "status = 1, height = 300, width = 300, resizable = 0" )
		return false;
		});
	$('.terms').click(function() {		
		window.open( "/terms_popup.php", "myWindow", "status = 1, height = 400, width = 400, resizable = 0, scrollbars = 1" )
		return false;
		});
	
	
	$('#archive > li > a').click( function() {		
		$(this).parent().find("ul:first").toggleClass("closed"); 
		return false;
		});
	$('#archive > li > ul > li > a').click( function() {		
		$(this).parent().find("ul:first").toggleClass("closed"); 
		return false;
		});
	
	}



