var sc_project=1642718;
var sc_invisible=1;
var sc_partition=15;
var sc_security="2ddcda17";

var Jonimation = {
	_contentsArea: null,
	_allContent: null,
	_contentWidth: null,
	_stalkScript: 'http://www.statcounter.com/counter/counter.js',
	
	init: function(){
		this._contentsArea = $('#contents');
		this._allContent = $('div.content');
		this._allContent.css({position:'absolute'});
		this._contentWidth = parseInt(this._contentsArea.css('width')) + parseInt(2) + 'px';
		$.getScript(Jonimation._stalkScript);
		this.show(this.getHashValue());
	},
	
	show: function(elementName) {
		newElement = $('#' + elementName);
		if(newElement != null) {
		    this._allContent.css({display:'none',left:'0px'}); //reset all content
		    newElement.show(); //show selected element
	        window.location.href = this.getBaseUrl() + '#' + elementName;
	        $.getScript(this._stalkScript);
	    }
	},
	
	slideLeft: function(elementName) {
		newElement = $('#' + elementName);
		current = $('div.content:visible');
		newElement.css({left:this._contentWidth}); //move the new element to the right
		newElement.show(); //make sure new element is visible
		current.animate({left:'-' + this._contentWidth}); //animate old active element
		newElement.animate({left:'0px'},500,'swing',function(){
		    current.hide();
		    window.location.href=Jonimation.getBaseUrl() + '#' + elementName;
		    $.getScript(Jonimation._stalkScript);
		}); 
	},
	
	slideRight: function(elementName) {
		newElement = $('#' + elementName);
		current = $('div.content:visible');
		newElement.css({left:'-' + this._contentWidth}); //move the new element to the left
		newElement.show(); //make sure new element is visible
		current.animate({left:this._contentWidth}); //animate old active element
		newElement.animate({left:'0px'},500,'swing',function(){
		    current.hide();
		    window.location.href=Jonimation.getBaseUrl() + '#' + elementName;
		    $.getScript(Jonimation._stalkScript);
		});
	},
	
	getBaseUrl: function() {
        fullUrl = window.location.href;
        loc = window.location.href.lastIndexOf('#');
        return (loc > -1) ? window.location.href.substring(0,loc) : window.location.href;
     },
     
     getHashValue: function() {
        fullUrl = window.location.href;
        loc = window.location.href.lastIndexOf('#');
        return (loc > -1) ? window.location.href.substring(loc+1) : 'home';
     }
}

$(function(){
	Jonimation.init();
});