// JavaScript Document
var Lightbox = { init: function() {return;} };
window.addEvent('domready', function() {
	$('home-link').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('home-link').get('href');
		show_content(URL);
	});
	$('fire-pumps').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('fire-pumps').get('href');
		show_content(URL);
	});
	$('tanks').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('tanks').get('href');
		show_content(URL);
	});
	$('design-testing').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('design-testing').get('href');
		show_content(URL);
	});
	$('suppliers').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('suppliers').get('href');
		show_content(URL);
	});
	$('service').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('service').get('href');
		show_content(URL);
	});
	$('gallery').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('gallery').get('href');
		show_content(URL);
	});
	$('diesel').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('diesel').get('href');
		show_content(URL);
	});
	$('fire-protection').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('fire-protection').get('href');
		show_content(URL);
		
	});
	$('contact-us').addEvent('click', function(event) {
		//prevent the page from changing
		event.stop();
		//make the ajax call, replace text
		var URL = $('contact-us').get('href');
		var outputHTML = show_content(URL);
	});
});


function show_content(PAGE_TO_DISPLAY) {
	var req = new Request.HTML({
					url: PAGE_TO_DISPLAY+'?ajax=1',
					method: 'get',
					onRequest: function() { $('content_response').slideout; $('ajax-loader').setStyle('display',''); },
					update: $('content_response'),
					onComplete: function(response) { $('ajax-loader').setStyle('display','none'); 
						new Asset.javascript('scripts/slimbox.js', {id: 'lightscript'});
						new Asset.css('slimbox.css', {id: 'slimStyle', title: 'slimStyle', media: 'screen'}); 
						
						if (PAGE_TO_DISPLAY == '/hass/contact_us.php')
						{
							onLoad();
						}
					},
					onSuccess: function(response) {  
						if (PAGE_TO_DISPLAY.indexOf('contact_us.php') == 0)
						{
							onLoad();
						}
					}
				}).send();
}

function process_contact_us(PAGE_TO_DISPLAY) {
	var URL = PAGE_TO_DISPLAY;
	var PARAMS = $('contact_us_form').toQueryString();

	var req = new Request.HTML({
					url: PAGE_TO_DISPLAY,
					method: 'post',
					data: PARAMS,
					onRequest: function() { },
					update: $('email_sent_message'),
					onComplete: function(response) { }
				}).send();

}
