
	
function fnActivateMenuitem(menu) {
	$('.floating_menu li').removeClass('active');
   	$(menu).addClass('active');
};

function fnShowProfile(name, position, description, xpos) {
  $('.profile').show();
  $('.default').hide();
	$('div.person_description_inner .name').html(name);
	if (position.length > 0) { $('div.person_description_inner .position').html("| " + position) } else { $('div.person_description_inner .position').html('') };
	$('div.person_description_inner .description').html(description);
	$('div.person_description').animate({"left":xpos}, 50);
};

function fnReturnProfile() {
  // $('div.person_description').css({"left":0});
  $('.profile').hide();
  $('.default').show();
};

// Load people info into array
var people = new Object();
people["jase"] = new Array("Jason Leong", "Co-founder", "Entrepeneur, designer, developer.", 0);
people["wigs"] = new Array("James Wigglesworth", "Co-founder", "A person with passion and integrity. A conscious marketer, a developer and web entrepreneur. Oh, and I'll rant about music for hours.", 30);
people["francois"] = new Array("Francois Bondiguel", "Co-founder", "Guy #3 - make things happen. I am a citizen of the world, passionate about web and business development and enjoying learning new skills everyday.", 100);
people["ben"] = new Array("Benjamin Humphrey", "Design & Copy", "Web and graphic designer, runs a small online media startup called Ohso, focusing on open source.", 210);
people["alex"] = new Array("Alex McMillan", "Forecasting Engine", "Programmer extraordinaire, thinks up new ways of calculating balances and handling events.", 320);
people["james"] = new Array("James Stradling", "Bank Integration", "Cocoa and Ruby programmer, student of science, co-founder of web and mobile dev studio, Holotype.", 420);
people["dave"] = new Array("Dave Strydom", "Branding", "Collaborated with the team to bring a greater sense of value to our brand.", 530);
people["tom"] = new Array("Tom Tremewan", "Social Media", "Community manager and blog editor for Good Cents, PocketSmith's personal finance publication.", 620);
people["andy"] = new Array("Andy Weston", "Illustrations", "Created the new illustrative look for PocketSmith's video and webpages.", 640);	

$(document).ready(function() {
	
	$('div.people li').hover(
	  function() { var person = $(this).attr('id'); fnShowProfile(people[person][0], people[person][1], people[person][2], people[person][3]) },
	  function() { fnReturnProfile() }		
	);
	
	
	if ($('body.home').length > 0) { 
    // var m1 = 0.01;
    // var m2 = 0.01;
    // var m3 = 0.025;
		var m1 = 0.01;
		var m2 = 0.0125;
		var m3 = 0.015;
	} else {
		var m1 = 0.01;
		var m2 = 0.0125;
		var m3 = 0.015;
	};
	
	$('body').parallax({
	  'elements': [
	    {
	      'selector': 'div.back',
	      'properties': {
	        'x': {
	          'background-position-x': {
	            'initial': -10,
	            'multiplier': m1,
	            'invert': true
	          }
	        }
	      }
	    },
	    {
	      'selector': 'div.middle',
	      'properties': {
	        'x': {
	          'background-position-x': {
	            'initial': 50,
	            'multiplier': m2,
	            'unit': '%'
	          }
	        }
	      }
	    },
	    {
	      'selector': 'div.front',
	      'properties': {
	        'x': {
	          'background-position-x': {
	            'initial': 0,
	            'multiplier': m3
	          }
	        }
	      }
	    }
	  ]
	});
	
	$(".tell_me_how").toggle(
		function() { $(this).parent().find(".additional_content").show('blind')},
		function() { $(this).parent().find(".additional_content").hide('blind')}
	);
	
	$(".front").delay(600).animate({ top: '0'}, 130 )	
	$(".middle").delay(900).animate({ top: '0'}, 170 )
	
	$(window).scroll(function() {
		if ($(window).scrollTop() > 345) { 
			$(".floating_menu_outer").css('position', 'fixed');
			$(".floating_menu_outer").css('top', '50px');
		} else {
			$(".floating_menu_outer").css('position', 'absolute');
			$(".floating_menu_outer").css('top', '-9px');
		};
	});
	

	var scrollElement = 'html, body';
	$('html, body').each(function () {
		var initScrollTop = $(this).attr('scrollTop');
		$(this).attr('scrollTop', initScrollTop + 1);
		if ($(this).attr('scrollTop') == initScrollTop + 1) {
			scrollElement = this.nodeName.toLowerCase();
			$(this).attr('scrollTop', initScrollTop);
			return false;
		}    
	});
	
	// Smooth scrolling for internal links
	$("a[href^='#']").click(function(event) {
		event.preventDefault();
		
		var $this = $(this),
		target = this.hash,
		$target = $(target);
		
		$(scrollElement).stop().animate({
			'scrollTop': $target.offset().top 
		}, 500, 'swing', function() {
			window.location.hash = target;
		});
		
	});
});

//  Mailform
function setupAjaxForm(form_id, form_validations){
    
    var form = '#' + form_id;
    var form_message = form + '-message';
 
    // en/disable submit button
    var disableSubmit = function(val){
        $(form + ' input[type=submit]').attr('disabled', val);
    };
 
    // setup loading message
    $(form).ajaxSend(function(){
        // $(form_message).removeClass().addClass('loading').html('Loading...').fadeIn();
    });
 
    // setup jQuery Plugin 'ajaxForm'
    var options = {
        dataType:  'json',
        beforeSubmit: function(){
            // run form validations if they exist
            if(typeof form_validations == "function" && !form_validations()) {
                // this will prevent the form from being subitted
                return false;
            }
            disableSubmit(true);
        },
        success: function(json){
            /**
               * The response from AJAX request will look something like this:
               * {"type" : "success", "message" : "Thank-You for submitting the form!"}
               * Once the jQuery Form Plugin receives the response, it evaluates the string into a JavaScript object, allowing you to access 
               * object members as demonstrated below.
               */
            $(form_message).hide();
            $(form_message).removeClass().addClass(json.type).html(json.message).fadeIn('slow');
            disableSubmit(false);
            if(json.type == 'success') { $(form).clearForm(); $('#form_fields').slideUp();};
        }
    };
    $(form).ajaxForm(options);
};








