//
// serious-cc.js
//
// Copyright (c) 2009. IamSerious.
// All rights reserved.
//

var Serious;
if (!Serious) Serious = {};
////////////////////////////////////////////////////////////////////////////////
//
// Serious.CC.ServiceProject
//
////////////////////////////////////////////////////////////////////////////////
Serious.CC = {};

Serious.CC.onPageLoad = function() {
	Serious.CC.Content		= jQuery("#content");
	Serious.CC.Home			= jQuery("#homeContent");
	Serious.CC.Journey		= jQuery("#journeyContent");
	Serious.CC.Who			= jQuery("#whoContent");
	Serious.CC.Who.Shane	= jQuery("#shane");
	Serious.CC.Who.Scanlan	= jQuery("#scanlan");
	Serious.CC.Who.Geffri	= jQuery("#geffri")
	Serious.CC.Who.Rasip	= jQuery("#rasip");
	Serious.CC.Contact		= jQuery("#contactContent");
	Serious.CC.Resources	= jQuery("#resourcesContent");
	Serious.CC.AllChildren	= jQuery("#homeContent,#journeyContent,#whoContent,#contactContent,#resourcesContent");
	Serious.CC.JourneyTexts	= jQuery("#journeyText .journey");

	jQuery("input:text,textarea").hint();

	shaneAddress =	'shane'+
					'@'+
					'completecampaigns.'+
					'com'+
					'.au';

	jQuery(".shaneAddress")
		.append(shaneAddress)
		.attr("href","mailto:" + shaneAddress);

	geffriAddress =	'geffri'+
					'@'+
					'completecampaigns.'+
					'com'+
					'.au';

	jQuery(".geffriAddress")
		.append(geffriAddress)
		.attr("href","mailto:" + geffriAddress);

	jQuery("#navigation").mouseout(function() {
		//jQuery('#navigation').removeClass().addClass("ui-state-default");
	});

	jQuery("#journey")
		.click(function() {
			jQuery('#navigation,body').removeClass().addClass("ui-state-journey");
			Serious.CC.AllChildren.hide();
			Serious.CC.Journey.show();
			Serious.CC.JourneyTexts.hide();
			jQuery('#j1Text').show();
			jQuery('#journeyContent').removeClass().addClass("ui-state-j1");
			return false;
		})
		.hover(
			function() {
				jQuery('#navigation').removeClass().addClass("ui-state-journey");
			},
			function() {
				jQuery('#navigation').removeClass();
			}
		);

		// Journey Options
		Serious.CC.Journey.find("li")
			.mouseover(
				function() {
					var id = jQuery(this).attr('id');
					Serious.CC.JourneyTexts.hide();
					jQuery('#'+id+'Text').show();
					jQuery('#journeyContent').removeClass().addClass("ui-state-"+id);
				}
			);

	jQuery("#who")
		.click(function() {
			jQuery('#navigation,body').removeClass().addClass("ui-state-who");
			Serious.CC.Who.removeClass();
			Serious.CC.AllChildren.hide();
			Serious.CC.Who.show();
			Serious.CC.Who.Shane.show();
			Serious.CC.Who.Scanlan.hide();
			Serious.CC.Who.Geffri.show();
			Serious.CC.Who.Rasip.hide();
			jQuery("#footer-image").removeClass();
			return false;
		})
		.hover(
			function() {
				jQuery('#navigation').removeClass().addClass("ui-state-who");
			},
			function() {
				jQuery('#navigation').removeClass();
			}
		);

		// Who Options
		Serious.CC.Who.Geffri
			.click(function() {
				Serious.CC.Who.removeClass().addClass("ui-state-geffri");
				jQuery("#footer-image").removeClass().addClass("ui-state-geffri");
				Serious.CC.Who.Shane.show();
				Serious.CC.Who.Scanlan.hide();
				Serious.CC.Who.Geffri.hide();
				Serious.CC.Who.Rasip.show();
				return false;
			})
			.hover(
				function() {
					jQuery('#whoNavigation').removeClass().addClass("ui-state-geffri");
				},
				function() {
					jQuery('#whoNavigation').removeClass();
				}
			);
		Serious.CC.Who.Shane
			.click(function() {
				Serious.CC.Who.removeClass().addClass("ui-state-shane");
				jQuery("#footer-image").removeClass().addClass("ui-state-shane");
				Serious.CC.Who.Shane.hide();
				Serious.CC.Who.Scanlan.show();
				Serious.CC.Who.Geffri.show();
				Serious.CC.Who.Rasip.hide();
				return false;
			})
			.hover(
				function() {
					jQuery('#whoNavigation').removeClass().addClass("ui-state-shane");
				},
				function() {
					jQuery('#whoNavigation').removeClass();
				}
			);

	jQuery("#contact")
		.click(function() {
			jQuery('#navigation,body').removeClass().addClass("ui-state-contact");
			Serious.CC.AllChildren.hide();
			Serious.CC.Contact.show();
			return false;
		})
		.hover(
			function() {
				jQuery('#navigation').removeClass().addClass("ui-state-contact");
			},
			function() {
				jQuery('#navigation').removeClass();
			}
		);

		jQuery("#submitting,#submitted,#submiterror").hide();

		jQuery("#submit")
			.click(function() {
				var	data = jQuery.makeArray(jQuery("#name,#email,#phone,#comments"));
				jQuery.ajax({
					// Set the address of the mailer file here
					url: "wherever.php",
					type: "POST",
					data: data,
					dataType: "html",
					success: function(msg){
						jQuery("#submit").hide();
						jQuery("#submitting").hide();
						jQuery("#submiterror").hide();
						jQuery("#submitted").show();
					},
					error: function(msg){
						jQuery("#submit").show();
						jQuery("#submitting").hide();
						jQuery("#submitted").hide();
						jQuery("#submiterror").show();
					}
				});
				jQuery("#submit").hide();
				jQuery("#submitting").show();
				jQuery("#submitted").hide();
				jQuery('#navigation,body').removeClass().addClass("ui-state-contact");
				Serious.CC.AllChildren.hide();
				Serious.CC.Contact.show();
				return false;
			});


	jQuery("#resources")
		.click(function() {
			jQuery('#navigation,body').removeClass().addClass("ui-state-resources");
			Serious.CC.AllChildren.hide();
			Serious.CC.Resources.show();
			return false;
		})
		.hover(
			function() {
				jQuery('#navigation').removeClass().addClass("ui-state-resources");
			},
			function() {
				jQuery('#navigation').removeClass();
			}
		);
};

Serious.Utils.addLoadListener(Serious.CC.onPageLoad);


