// JavaScript Document


function onLoad(){
		initScrollPane('#productContent');
		initScrollPane('#wildContent');
		initScrollPane('#citricContent');
		initScrollPane('#privacyContent');
		$.historyInit(loadPage, "index.html");
		
		$("a.linkHistory,a.btClose").click(function(){
			var hash = this.href;
			hash = hash.replace(/^.*#/, '');
			$.historyLoad(hash);
			return false;
		});
		
		$(document).bind("keyup",function(e){
			if(e.keyCode == 27){
				var hash = document.location.hash;
				hash = hash.replace(/^.*#/, '');
				if(hash && hash != 'home'){
					$.historyLoad("home");
				}
			}
		});
	
}
function loadPage(url){
		if($('div#wrapper div.content:visible').size() > 0){
			$('div#wrapper div.content:visible').fadeOut(300, function (){
					$('div#wrapper div#'+getContent(url)).fadeIn(300);											   
			});
		}else $('div#wrapper div#'+getContent(url)).fadeIn(300);
		
}

function initScrollPane(ct,position){
			if(position){
			$(ct).jScrollPane({maintainPosition:position});
			}else {
				 $(ct).jScrollPane({maintainPosition:false});
				}
            reinitialiseScrollPane = function(){
				$(ct).jScrollPane();
            }
}

function getContent(hash){
	
	if(!hash){
		return 'homeCt';	
	}
	
	switch(hash){
		case "FrutasSelvagens": 	return 'wildCt';break;
		case "FrutasCitricas": 		return 'citricCt';break;
		case "Produto": 			return 'productCt';break;
		case "InfoNutricionais": 	return 'wildCt';break;
		case "PoliticaPrivacidade": return 'privacyCt';break;
		case "home": 				return 'homeCt';break;
		default:					return 'homeCt';break;
	}
}
		
	
	

