var bambiSWFReference; var interfaceMethod; var hashListener; var hash;

window.onload = function(){
	
	window.location.hash = window.location.hash.replace(/\//g,',');
	
	var bambi = new SWFObject('/lib/public/swf/bambi.swf','bambiSWF','990','2880','8');
	
	bambi.addParam('allowFullScreen','true');
	bambi.addParam('allowScriptAccess','always');
	bambi.addParam('wmode','transparent');
	
	bambi.addVariable('urlHandler','getURL');			
	bambi.addVariable('pagesizeHandler','resizePageSize');
	bambi.addVariable('interfaceInitMethod','initInterface');
	bambi.addVariable('configXML','/lib/public/config/default.xml');
	bambi.addVariable('initPage',window.location.hash.replace(/#/,''));
	
	bambi.write('main');			
	
	if(document.getElementById){
		bambiSWFReference = document.getElementById('bambiSWF');
		hashListener = window.setInterval('hashHandle()',64);
	}
};
function hashHandle(){
	if(window.location.href.indexOf('#')>-1){
		if(hash != window.location.hash){
			hash = window.location.hash;
			callInterface(hash);
		}
	}				
}
function initInterface(method){
	interfaceMethod = method;
}
function callInterface(str){
	if(bambiSWFReference){
		if(interfaceMethod){
			if(bambiSWFReference){bambiSWFReference[interfaceMethod](str.replace(/#/,''));}	
		}
	}
}
function getURL(reference){
	window.location.href = window.location.pathname+'#'+reference;
	hash = window.location.hash;
}
function resizePageSize(w,h){	
	document.getElementById('main').style.clip = 'rect(0px, 990px, '+h+'px, 0px)';
	document.getElementById('main').style.height = h+'px';
	document.getElementById('footer').style.top = Math.max(screen.availHeight,h)+'px';
}
function fallBack(){
	if(DetectFlashVer(8,0,0)){
		if(document.getElementById){
			document.getElementById('main').innerHTML = '';
		}
	}else{
		window.location.href= '/html/'+window.location.hash.replace(/#/,'');
	}
}