$(document).ready(function() {

	//Horizontal Sliding
	$('.slide').hover(function(){
		$("img", this).stop().animate({left:'300px'},{queue:false,duration:300});
	}, function() {
		$("img", this).stop().animate({left:'4px'},{queue:false,duration:300});
	});

	// Form stuff
	$(function(){
	//Do what we need to when form is submitted.
	$('#send').click(function(){
		//Setup any needed variables.
		var input_navn = $('#navn').val(),
			input_epost = $('#epost').val(),
			input_telefon = $('#telefon').val(),
			input_melding = $('#melding').val(),
			respons = $('#respons');
			//Hide any previous response text
			respons.hide();

			//Change response text to 'loading...'
			respons.html('Laster...').show();

			//Make AJAX request
			$.post('http://divint.no/wp-content/themes/divint-tmp/skjema.php', {navn: input_navn, epost: input_epost, telefon: input_telefon, melding: input_melding}, function(data){
				respons.html(data);
			});
	
			//Cancel default action
			return false;
		});

	});

	// Track links with .external class.
	$('a.external').click(function(){
		_gaq.push(['_trackEvent', 'External Links', 'Click', $(this).attr('href')]);
	});


	// Track form.
	var currentPage = jQuery.url.attr("path");
	$(':input').blur(function () {
		if($(this).val().length > 0){
			pageTracker._trackEvent("Form: " + currentPage, "input_exit", $(this).attr('name'));
		}
	});

});

