$(document).ready(function() {

	// Disable ajax cache
	$.ajaxSetup ({  
		cache: false  
	});
	
	// Get the ajax loader gif  
	var loader = "<img id='contact-loader' src='http://deasign.se/wp-content/themes/deasign/lib/img/ajax-loader.gif' alt='loading...' />";
	
	// Put the buttons in an variable to use of remove and add class later on
	var links = $('#contact-buttons button');
	
	// Ajax function
	$("#contact-buttons button").live('click', function(event) {
	
		// Prevent the default action when you click the button
		event.preventDefault();
		
		// Remove selected class on the buttons
		links.removeClass();
		
		// Add class "Selected" on the button that was pressed
		$(this).addClass('selected');
		
		// Get the permalink from the form. (If they were a tags just get the .attr("href");)
		var buttonUrl = $(this).parent('form').attr("action");
		
		// Get everything we need in a ajax variable. buttonUrl = http://www.example.com + ? + country + = + sweden
		// Country come from the buttons name and also we get the buttons value.
		// If it were a link we just use what the string is for buttonUrl
		var loadUrl = buttonUrl+'?'+$(this).attr('name')+'='+$(this).attr('value');  
 		
 		// The actual ajax, member-inner is the area we want to replace. we get the loader and then
 		// We load the url and the area we want to get = ajax
		$("#member-inner").html(loader).load(loadUrl+ ' #member-inner');  
        
	});   

});
    
    

