var flashvars = {};
var params = {};
params.play = 'true';
params.menu = 'true';
params.scale = 'noscale';
params.salign = 'tl';
params.bgcolor = '#FFFFFF';
params.allowfullscreen = 'true';
params.allowscriptaccess = 'always';
params.allownetworking = 'all';
var attributes = {id: 'jse'};
attributes.align = 'left';
swfobject.embedSWF('Main.swf', 'master', '100%', '100%', '10.0', '', flashvars, params, attributes);

//swfobject.addLoadEvent(customRedirect);

if (swfobject.hasFlashPlayerVersion('10.0')) {
	
	if (document.location.pathname != '/' && document.location.pathname != '/index.php') {			
		var newPath = 'http://' + document.location.host + '/#' + rootLine;
		document.location = newPath;
		
	} else {		
		swfobject.createCSS('html', 'height:100%; max-height:100%; overflow:hidden;');
		swfobject.createCSS('body', 'height:100%; max-height:100%; margin:0; padding:0; overflow:hidden; background-color:#FFFFFF;');
		swfobject.createCSS('#master', 'height:100%; min-height:100%;');		
	}
	/*
	$(function(){

		$(window).hashchange( function(){
			alert('hash changed: ' + location.hash);
		})
	
		//$(window).hashchange();
	
	
	});
	*/
	
} else {	
	
	var hash = window.location.hash;
	
	if (hash != '' && !hash.substring(1).match(/c[0-9]*/)) {
		document.location = 'http://' + document.location.host + '/html' + hash.substring(1);		
	}
	
	var isiPad = navigator.userAgent.match(/iPad/i) != null;
	var isiPhone = navigator.userAgent.match(/iPhone/i) != null;	
			
	document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
			
	function loaded() {
		document.addEventListener('touchmove', function(e){ e.preventDefault(); });
		masterBodyScroll = new iScroll('body');
	}
	document.addEventListener('DOMContentLoaded', loaded);	
	
	$(document).ready(function() {	
		
		var originalViewHeight = $(window).height();
		var viewHeight;
		var viewWidth;
			
		var delayResize = (function () {
			var timers = {};
			return function (callback, ms, uniqueId) {
				if (!uniqueId) {
					uniqueId = '';
				}
				if (timers[uniqueId]) {
					clearTimeout (timers[uniqueId]);
				}
				timers[uniqueId] = setTimeout(callback, ms);
			};
		})();
	
		var adjustBoxes = (function () {		
			
			viewHeight = $(window).height();
			viewWidth = $(window).width();
					
			$('#master').height(viewHeight - 20 - 20);			
								
		})		
				
		adjustBoxes();
		
		$(window).resize(function() {
			
			delayResize(function(){
	      		adjustBoxes();
	    	}, 200, 'resize');		
			
		});	
				
		$('#logo').show('slow');
		$('#navigation-level-1').show();
		
		if (isiPad || isiPhone) {
			
		}
		
    });

}

