	$(document).ready(function() {
		$("#infoHd").hide();
		$("#infoToggle h3").click(function() {
			$("#infoHd").slideToggle("400");
		});
		
		$('#admin_login').click(function() {
			var u = $('#username').val();
			var p = $('#password').val();
		
			$.ajax({
				type: "POST",
				url: "admin/login",
				data: "username="+u+"&password="+p,
				success: function(msg){
					if (msg == 0) {
						$('#action p').text('Unauthorised access / Incorrect password');
						$('#action').slideDown().delay(2000).fadeOut('slow');
					} else { 
						top.location="admin/home";
					}
				}
			});
			
			return false;
		});
		
		$.easing.elasout = function(x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
		};
		
		//* Intro scroller */

		$('#introScroll').live("click", function() {
			if ($('#intro').hasClass('type1')) {
				$('#intro').scrollTo( { top:0, left:710 }, 400 );
				$('#intro').removeClass('type1');
				$('#intro').addClass('type2');
				
			} else if ($('#intro').hasClass('type2')) { 
				$('#intro').scrollTo( { top:0, left:1420 }, 400 );
				$('#intro').removeClass('type2');
				$('#intro').addClass('type3');
				
			} else if ($('#intro').hasClass('type3')) { 
				$('#intro').scrollTo( { top:0, left:2130 }, 400 );
				$('#intro').removeClass('type3');
				$('#intro').addClass('type4');	
				
			} else if ($('#intro').hasClass('type4')) { 
				$('#intro').scrollTo( { top:0, left:2840 }, 400 );
				$('#intro').removeClass('type4');
				$('#intro').addClass('type5');
				
			} else if ($('#intro').hasClass('type5')) { 
				$('#intro').scrollTo( { top:0, left:-2840 }, 400 );
				$('#intro').removeClass('type5');
				$('#intro').addClass('type1');
			}			
			
			return false;
		});
		
		//* Show contact form */
		
		$('#showContact a').click(function() { 
			$('#contact').slideToggle();
			$('#showContact').fadeOut();
			return false;
		});
		
		//* Zero security box *//
		
		$('input#security').focus(function() {
			$(this).val("");
		});
		
		//* Post form */
		
		$('#submitContact').click(function() {
			var name = $("input#name").val();
			var email = $("input#email").val();
			var message = $("textarea#message").val();
			var security = $("input#security").val();
			
	        if (security != 'security' || message == '') {  
      			alert('Please make sure you have typed a message and the word \'security\' is typed in the security box.'); 
      			return false; 
      		}
		
			$.ajax({
	   			type: "POST",
	   			url: "home/contact/",
	   			dataType: 'html',
	   			data: { name: name, email: email, message: message },
	   			success: function() {
	   				$('#contactMe').slideUp();
	   				$('#contactSuccess').slideDown();
	   				$('#contactStamp').attr('src', 'http://web.me.com/disfunctional/evilfly/images/contact_stamp_sent.png');
	   			},
	   			error: function(){
        			alert("Fucked up innit!");
      			}
	 		});
	 		return false;
	 	});
	});
	
	$(function() {
  // IE6 doesn't handle the fade effect very well - so we'll stick with
  // the default non JavaScript version if that is the user's browser.
  if ($.browser.msie && $.browser.version < 7) return;
  
  $('#nav ul li')
  
    // remove the 'highlight' class from the li therefore stripping 
    // the :hover rule
    .removeClass('highlight')
    
    // within the context of the li element, find the a elements
    .find('a')
    
    // create our new span.hover and loop through anchor:
    .append('<span class="hover" />').each(function () {
      
      // cache a copy of the span, at the same time changing the opacity
      // to zero in preparation of the page being loaded
      var $span = $('> span.hover', this).css('opacity', 0);
      
      // when the user hovers in and out of the anchor
      $(this).hover(function () {
        // on hover
        
        // stop any animations currently running, and fade to opacity: 1
        $span.stop().fadeTo(500, 1);
      }, function () {
        // off hover
        
        // again, stop any animations currently running, and fade out
        $span.stop().fadeTo(500, 0);
      });
    });
    
    //$('.articleBody').hide();
    //$('.articleBody:first').show();
    //$('.article:first.article p.show a').text('Hide [-]');

	$('.article p.show a').click(function(){ 
		if($(this).text()=='Hide [-]'){
			$(this).text('Show [+]');
			$(this).parent().next().next().next().hide();
		} else {
			$(this).text('Hide [-]');
			$(this).parent().next().next().next().show();
		}
		return false;
	});
		
	$("#articleArchive").hide();
	$("#articleArchiveShow a").click(function() {
		$("#articleArchive").slideToggle();
		return false;
	});
	
	/* Toggle widescreen */
	
	$('.articleView a').click(function() { 
		$('body').toggleClass('widescreen');
		return false;
	});

});