<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	
	var quotePos = 1;

	var quote_firstname, quote_lastname, quote_email, quote_company, quote_address, quote_suburb, quote_state, quote_postcode;
	var quote_ft, quote_foc, quote_uof, quote_aof, quote_renovated, quote_startdate, quote_area, quote_details, quote_sn;
	var quote_cr;

	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function sendEnquiry(firstname, lastname, email, postal, suburb, state, postcode, comment)
	{
		var url = "process.php";

		var data = "process=enquiry";
		data = data + "&firstname=" + firstname;
		data = data + "&lastname=" + lastname;
		data = data + "&email=" + email;
		data = data + "&postal=" + postal;
		data = data + "&suburb=" + suburb;
		data = data + "&state=" + state;
		data = data + "&postcode=" + postcode;
		data = data + "&comment=" + escape(comment);
		data = data + "&sid=" + Math.random();

		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				showMessageBox(txt);
				cleanUpEnquiryForm();
			},

			onFailure: function() {
				showMessageBox("Error connecting to server. Please refresh this page...");
			}

		}).send(data);
	}

	function sendQuote()
	{
		var url = "process.php";

		var data = "process=quote";
		data = data + "&firstname=" + quote_firstname;
		data = data + "&lastname=" + quote_lastname;
		data = data + "&email=" + quote_email;
		data = data + "&company=" + quote_company;
		data = data + "&address=" + quote_address;
		data = data + "&suburb=" + quote_suburb;
		data = data + "&state=" + quote_state;
		data = data + "&postcode=" + quote_postcode;
		data = data + "&ft=" + quote_ft;
		data = data + "&foc=" + quote_foc;
		data = data + "&uof=" + quote_uof;
		data = data + "&aof=" + quote_aof;
		data = data + "&renovated=" + quote_renovated;
		data = data + "&startdate=" + quote_startdate;
		data = data + "&area=" + quote_area;
		data = data + "&details=" + escape(quote_details);
		data = data + "&sn=" + quote_sn;
		data = data + "&cr=" + quote_cr;
		data = data + "&sid=" + Math.random();

		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				cleanUpQuoteForm();
			},

			onFailure: function() {
				showMessageBox("Error connecting to server. Please refresh this page...");
			}

		}).send(data);
	}

	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================
	function submitEnquiry()
	{
		var message = "";
		var form = document.enquiryform;

		var firstname = form.firstname.value.replace("First Name", "");
		var lastname = form.lastname.value.replace("Last Name", "");
		var email = form.email.value.replace("Email Address", "");
		var postal = form.postal.value.replace("Postal Address", "");
		var suburb = form.suburb.value.replace("Suburb", "");
		var state = form.state.value.replace("State", "");
		var postcode = form.postcode.value.replace("Postcode", "");
		var comment = form.comment.value.replace("Message or Enquiry", "");

		var valid = true;

		if (firstname == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your first name.\n";
		}

		if (lastname == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your last name.\n";
		}

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)))
		{
			valid = false;
			message = message + "Please make sure you have entered a valid e-mail address.\n";
		}

		if (valid == true) 
		{
			sendEnquiry(firstname, lastname, email, postal, suburb, state, postcode, comment);
		}
		else
		{
			alert(message);
		}
	}

	function cleanUpEnquiryForm()
	{
		var form = document.enquiryform;

		form.firstname.value = "First Name";
		form.lastname.value = "Last Name";
		form.email.value = "Email Address";
		form.postal.value = "Postal Address";
		form.suburb.value = "Suburb";
		form.state.value = "State";
		form.postcode.value = "Postcode";
		form.comment.value = "Message or Enquiry";
	}

	function cleanUpQuoteForm()
	{
		var form = document.quoteform;

		form.firstname.value = "First Name";
		form.lastname.value = "Last Name";
		form.email.value = "Email Address";
		form.company.value = "Company";
		form.address.value = "Address";
		form.suburb.value = "Suburb";
		form.state.value = "State";
		form.postcode.value = "Postcode";
		form.ft.selectedIndex = 0;
		form.foc.selectedIndex = 0;
		form.uof.selectedIndex = 0;
		form.aof.selectedIndex = 0;
		form.renovated.checked = false;
		form.startdate.value = "Approximate Start Date of Service";
		form.area.value = "Approximate Square Metres of Area";
		form.details.value = "Details of area and cleaning or any specific requirements";
		resetCheckedCheckboxes(form.sn);
		resetCheckedCheckboxes(form.cr);
	}

	function checkQuoteStep1()
	{
		var message = "";
		var form = document.quoteform;

		quote_firstname = form.firstname.value.replace("First Name", "");
		quote_lastname = form.lastname.value.replace("Last Name", "");
		quote_email = form.email.value.replace("Email Address", "");
		quote_company = form.company.value.replace("Company", "");
		quote_address = form.address.value.replace("Address", "");
		quote_suburb = form.suburb.value.replace("Suburb", "");
		quote_state = form.state.value.replace("State", "");
		quote_postcode = form.postcode.value.replace("Postcode", "");

		var valid = true;

		if (quote_firstname == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your first name.\n";
		}

		if (quote_lastname == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your last name.\n";
		}

		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(quote_email)))
		{
			valid = false;
			message = message + "Please make sure you have entered a valid e-mail address.\n";
		}

		if (quote_address == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your address.\n";
		}

		if (quote_suburb == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your suburb.\n";
		}

		if (quote_state == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your state.\n";
		}

		if (quote_postcode == "")
		{
			valid = false;
			message = message + "Please make sure you have entered your postcode.\n";
		}

		if (!valid)
		{
			alert(message);	
		}

		return valid;	
	}

	function checkQuoteStep2()
	{
		var message = "";
		var form = document.quoteform;

		quote_ft = form.ft.value.replace("Please Select", "");
		quote_foc = form.foc.value.replace("Please Select", "");
		quote_uof = form.uof.value.replace("Please Select", "");
		quote_aof = form.aof.value.replace("Please Select", "");
		quote_renovated = form.renovated.checked;
		quote_startdate = form.startdate.value.replace("Approximate Start Date of Service", "");
		quote_area = form.area.value.replace("Approximate Square Metres of Area", "");
		quote_details = form.details.value.replace("Details of area and cleaning or any specific requirements", "");
		quote_sn = getCheckedCheckboxes(form.sn);
		quote_sn = quote_sn.substr(0, quote_sn.length - 1);

		var valid = true;

		if (quote_startdate == "")
		{
			valid = false;
			message = message + "Please make sure you have entered the approximate start date of service.\n";
		}

		if (quote_area == "")
		{
			valid = false;
			message = message + "Please make sure you have entered the approximate square metres of area.\n";
		}

		if (quote_ft == "")
		{
			valid = false;
			message = message + "Please make sure you have selected the facility type.\n";
		}

		if (quote_foc == "")
		{
			valid = false;
			message = message + "Please make sure you have selected the frequency of cleaning.\n";
		}

		if (quote_uof == "")
		{
			valid = false;
			message = message + "Please make sure you have selected the usage of facility.\n";
		}

		if (quote_aof == "")
		{
			valid = false;
			message = message + "Please make sure you have selected the age of facility.\n";
		}

		if (!valid)
		{
			alert(message);	
		}

		return valid;
	}

	function checkQuoteStep3()
	{
		var message = "";
		var form = document.quoteform;

		quote_cr = getCheckedCheckboxes(form.cr);
		quote_cr = quote_cr.substr(0, quote_cr.length - 1);

		var valid = true;

		return valid;
	}

	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================
	function showMessageBox(txt)
	{
		//setup the div
		// var div_wrapper = $('wrapper_message_box');
		// var div_box = $('message_box');
		// var div_text = $('message_text');

		// div_text.set('html', txt);
		// div_wrapper.setStyle('display', 'block');
		// div_box.setStyle('display', 'block');
		alert(txt);
	}

	function initBackgrounds()
	{
		var container = 'background';
		var path = 'images/site/';
		var images;
		
		if ($chk($(container)))
		{
			var bg = $(container).getChildren('div')[0];
			//var bg_id = bg[0].get('id');
			
			/* preloading */  			
			images = [ path + 'bg.jpg' ];
								
			//create the asset.images
			assetBackgrounds = new Asset.images(images, {  
			
				onComplete: function() { 
					images.each(function(imgsrc) {  
						new Element('img',{ src: imgsrc, width: $('background').getWidth(), style: 'width:auto; height:auto;' }).inject($(bg));  				
					});					
					
					$(container).setStyle('opacity', 0);
					bgFull(container, 100);
					
					$(container).removeClass('bg_hide');
					new Fx.Tween($(container)).start('opacity', 0, 1);
				}  
				
			});					
		}
	}

	function randomFeaturedBox(max)
	{
		if ($chk($('featured_normal')))
		{
			$$('.slide_featured').each(function(element){
				element.setStyle('display', 'none');
			});

			var randomNumber = $random(1, max);

			$('featuredBox' + randomNumber).setStyle('display', 'block');
		}
	}

	function showQuoteStep(stepID)
	{
		var valid = true;
		stepID = parseInt(stepID);

		if (quotePos < stepID)
		{
			switch (stepID)
			{
				case 2:
					valid = checkQuoteStep1();
					break;
				case 3:
					valid = checkQuoteStep2();
					break;
				case 4:
					valid = checkQuoteStep3();
					break;
			}
		}

		if (valid)
		{
			updateQuoteMenu(stepID);
			quotePos = stepID;

			if (stepID == 4)
			{
				sendQuote();
			}

			new Fx.Scroll($('quote_steps')).toElement('quote_step' + stepID);
		}
	}

	function updateQuoteMenu(stepID)
	{
		$('menu_quote_step' + quotePos).removeClass('menu_quote_title_landed');
		$('menu_quote_step' + stepID).addClass('menu_quote_title_landed');
	}

	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		if ($chk($$('.nav_link')))
		{
			$$('.nav_link').addEvents({
				'mouseout' : function() {
					$(this.get('id') + '_off').setStyle('display', 'block');
					$(this.get('id') + '_on').setStyle('display', 'none');
				},
				'mouseover' : function() {
					$(this.get('id') + '_off').setStyle('display', 'none');
					$(this.get('id') + '_on').setStyle('display', 'block');
				}
			});
		}

		if ($chk($$('.button')))
		{
			$$('.button').addEvents({
				'mouseout' : function() {
					$(this).setStyle('text-decoration', 'none');
				},
				'mouseover' : function() {
					$(this).setStyle('text-decoration', 'underline');
				}
			});
		}
	}

	function setupSlideshows()
	{
		if($chk($('banner_image_home')))
		{
			//(function() { tweenFadeOut('removable_banner'); }).delay(6000);
			var bannerHomeShow = new Slideshow('banner_image_home', false, { delay: 8000, width: 980, height: 300 });
		}

		if($chk($('banner_image_other')))
		{
			var bannerHomeShow = new Slideshow('banner_image_other', false, { delay: 8000, width: 980, height: 200 });
		}

		if($chk($('side_image_slideshow')))
		{
			var sideShow = new Slideshow('side_image_slideshow', false, { delay: 8000, width: 300, height: 140 });
		}

		if($chk($('sidework_image_slideshow')))
		{
			var sideworkShow = new Slideshow('sidework_image_slideshow', false, { delay: 8000, width: 300, height: 135 });
		}

		if($chk($('featured_slideshow')))
			fadeTicker('featured_slideshow','slide_featured', 8000, 2000);
	}

	/*
	function tweenFadeOut(element){
		var myFadeOut = new Fx.Tween($(element), {
			property: 'opacity',
			duration: 1000
		});
		myFadeOut.start(1, 0).chain(function(){$(element).setStyle('display', 'none');});
	}
	*/

	//================================================================================================
	// SCALLING BACKGROUND
	//================================================================================================		
	function $E(tag,el){return $(el||document).getElement(tag)}
	
	kina={
		doc:{x:0,y:0},
		fix:
			function()
			{				
				if(kina.bg.complete&&(db.offsetWidth!=kina.doc.x||db.offsetHeight!=kina.doc.y||kina.fix.src!=kina.bg.src))
				{
					var bg=kina.bg.getSize();
					kina.doc={x:db.offsetWidth,y:db.offsetHeight};
					kina.fix.src==kina.bg.src||$extend(kina.fix,{p:bg.x/bg.y,src:kina.bg.src});
					kina.bg.setStyles({width:(bg.y=kina.doc.x>(bg.x=Math.round(kina.doc.y*kina.fix.p)))?kina.doc.x:bg.x,height:bg.y?Math.round(kina.doc.x/kina.fix.p):kina.doc.y})			
				}								
			}
	}	
	
	function bgFull(container, interval)
	{
		if ($chk($(container)))
		{
			$extend
			(
				kina,{bg:$E('img',$E('#' + container,db=$(document.body))),timer:setInterval(kina.fix,interval)}
			);			
		}
	}	
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			setupActions();
			setupSlideshows();
			initBackgrounds();
		},
		
		'resize' : function() {

		}
		
	});
	

//-->
