$(document).ready(function(){

	//check for IE, cause it sucks.
	
	if(jQuery.support.opacity==false) {
		$('#nav').append('<li><a href="/ie/" class="strange">Look Strange? Click here.</a></li>');
		
		$('.strange').click(function(event) {
		event.preventDefault();
		
		$('#content').stop().slideUp(700, function() {
			$("#content-side").load("ie.html");
		});
	
	});
	}

	//ajax search form

	$('#search').ajaxForm({ 
			beforeSubmit: function () {
				$('#innerslide').empty();
				$('#slider').append('<div class="wait"><img src="images/wait.gif" alt="Waiting, waiting.."></div>').stop().animate({'opacity': 1}, 500, 'easeOutSine')
			},
	        target: '#innerslide', 
	        success: function() { 
				$('.wait').remove();
				$('.arrow, .arrowright').stop().animate({'opacity': 1}, 700, 'easeOutSine'); 
			}
			});  

	//nav functions

	$('#nav li a').append('<span class="hover"></span>');
	
	$('#nav li a').hover(function() {
	
		$('.hover', this).stop().animate({
			'opacity': 1
			}, 700, 'easeOutSine')
	
	},function() {
	
		$('.hover', this).stop().animate({
			'opacity': 0
			}, 500, 'easeOutSine')
	
	});
	
	$('.about').click(function(event) {
		event.preventDefault();
		
		$('#content').stop().slideUp(700, function() {
			$("#content-side").load("about.html");
		});
	
	});
	
	//sections fade and hide/show downloads
	
if(jQuery.support.opacity==true) {
	$('section').hover(function() {
			$('section').not(this).children().not('header').stop().animate({
						'opacity': 0.7
					}, 700, 'easeOutQuart');
		},function() {
			$('section').not(this).children().not('header').stop().animate({
						'opacity': 1
					}, 700, 'easeOutSine');
		});
		
}
		
	$('#bot').hover(function() {
			$('#dls').stop().animate({
						'opacity': 1
					}, 500, 'easeOutQuart');
		},function() {
			$('#dls').stop().animate({
						'opacity': 0
					}, 500, 'easeOutSine');
		});
		
	//middle magic

	$('.result').hover(function(event) {
		event.preventDefault();
		
		$(this).stop().animate({
			'opacity': 1
			}, 500, 'easeOutSine')
	
	},function() {
	
		$(this).stop().animate({
			'opacity': 0.8
			}, 500, 'easeOutSine')
	
	});
	
	$('.arrow,.arrowright').append('<span class="hover"></span>');
	
	$('.arrow,.arrowright').not('.disabled').hover(function() {
	
		$('.hover', this).stop().animate({
			'opacity': 1
			}, 700, 'easeOutSine')
	
	},function() {
	
		$('.hover', this).stop().animate({
			'opacity': 0
			}, 500, 'easeOutSine')
	
	});
	
	$('.midcontent:first').before($('.midcontent:last')); 
	
	$('.arrow').not('.disabled').click(function(event) {
		event.preventDefault();
		
		$('#innerslide:not(:animated)').animate({'left': '0'},
		1000,
		'easeOutSine',
		function() {	
			$('.midcontent:first').before($('.midcontent:last'));	
			$('#innerslide').css({'left' : '-860px'});
		});
		
	});
	
	$('.arrowright').not('.disabled').click(function(event) {
		event.preventDefault();
		
		$('#innerslide:not(:animated)').animate({'left': '-1720'},
		1000,
		'easeOutSine',
		function() {	
			$('.midcontent:last').after($('.midcontent:first'));	
			$('#innerslide').css({'left' : '-860px'});
		});
		
	});
	
});