/*
        /00000000000                        /0   0\      000       000
        00000000000/            /00000000  /000 000\    0   0      000
            0000     /00000000  000        000000000   00   00   /000000/
            0000     000   000  000000     000 0 000  000000000    000
            0000     000   000  000        000   000  000   000    000
            000/     00000000/  \00000000  000   000  000   000    000
            
            Page & code by Thomas Renck  http://X-INfERNO.com   2011
*/

//Bind the page load event to pageInit();
$(document).ready(pageInit);

//----------------------------------------------------
//	pageInit - fires when the page is finished
//	loading, sets up jQuery elements
//----------------------------------------------------
function pageInit() {

	//Set up front page slide show
	$('#show').cycle({
		fx:     'fade',
		random:  1
	});
	
	//Create the column list for the cities.
	$('ul.cities').makeacolumnlists({cols:3,colWidth:0,equalHeight:false});
	
}

//----------------------------------------------------
//	sendContact - uses ajax to send the contact
//	request form to includes/handler_contact.php
//----------------------------------------------------
function sendContact() {
	var toPost = new Object;
	toPost.from = $('#from').val();
	toPost.subject = $('#subject').val();
	toPost.message = $('#message').val();
	toPost.type = "contact";
	
	sendForm(toPost);

	return false;
}

//----------------------------------------------------
//	sendQuoteRequest - uses ajax to send the quote
//	request form to includes/handler_contact.php
//----------------------------------------------------
function sendQuoteRequest() {
	var toPost = new Object;
	toPost.from = $('#email').val();
	toPost.name = $('#name').val();
	toPost.city = $('#city').val();
	toPost.zip = $('#zip').val();
	toPost.phone = $('#phone').val();
	toPost.message = $('#project').val();
	toPost.type = "quote";
	
	sendForm(toPost);

	return false;
}

function sendForm(toPost) {
	$.ajax({
		type: "POST",
		data: toPost,
		url: "includes/handler_contact.php",
		success: function(data, type){
			if(data=='OK') {
				alert('Thank you for your message!');
				//Clear form
				$('input, textarea').val('');
			}
			else
				alert('Something went wrong... Please try again');
		}
	});
}
