/**
 *############################################################
 *#  copyright 2009 Scholz & Volkmer GmbH
 *#  version $Revision: 1173 $
 *#  author $Author: more $
 *#  $Id: main.js 1173 2010-02-25 13:03:53Z more $
 *############################################################
 */


/**
 * Global variables
 */
var enableFlash = true;

var applicationHeight = 576;
var applicationWidth = 1000;

var deeplink = '';
var flashContainer = '';
var lang = '';
var scriptpath = '';
var basepath = '';
var flashLoaded = false;


/**
 * domready
 * get started when all dom-elements beeing loaded
 */
$(document).ready(function() {
	windowIsResized();  
	window.onresize = function() 
	{
		windowIsResized();
	}

	if(enableFlash)
	{
		initSwf();
	}
});


init();


/**
 * 
 */
function windowIsResized()
{
	var windowHeight = (window.gecko) ? document.body.clientHeight : $(window).height();
	var windowWidth = (window.gecko) ? document.body.clientWidth : $(window).width();

	if(flashLoaded)
	{
		if(windowHeight <= applicationHeight || windowWidth <= applicationWidth)
		{
			$('#outer-container-wrapper').css('height', '' + applicationHeight + 'px');
			$('#outer-container-wrapper').css('width', '' + applicationWidth + 'px');
		} else
		{
			$('#outer-container-wrapper').css('height', '100%');
			$('#outer-container-wrapper').css('width', '100%');
		}
	}
}


/**
 * 
 */
function init()
{
	windowIsResized();
}


/**
 * 
 */
function initSwf()
{
	var locationHash = location.hash;
	if(locationHash != '')
	{
		if(locationHash.charAt(0) == '#')
		{
			deeplink = locationHash.substr(1);
		} else
		{
			deeplink = locationHash.substr(0);
		}
	}

	var flashvars = {
		'deeplink' : deeplink,
		'lang' : lang,
		'scriptpath' : scriptpath,
		'basepath' : basepath
	};
	var params = {
		allowScriptAccess:'always', 
		quality:'high', 
		bgcolor:'#c8d2d6',
		menu : false
	};
	var attributes = {
		id:'ExpotechnikApp', 
		name:'ExpotechnikApp',
		style:'outline: none'
	};
	swfobject.embedSWF(
		basepath + "/ExpotechnikApp.swf", 
		flashContainer, 
		"100%", 
		"100%", 
		"10.0.0", 
		false,
		flashvars,
		params,
		attributes,
		callbackFn
	);
	if(swfmacmousewheel != undefined)
	{
		swfmacmousewheel.registerObject(attributes.id);
	}
}



/**
 * 
 */
function callbackFn(e)
{
	if(e.success == false)
	{
		$('#inner-outer-container').css('display', 'block');
		return;
	}

	$('#body').css('height', '100%');
	$('#outer-container-wrapper').css('height', '100%');
	$('#outer-container-wrapper').css('width', '100%');
	$('#outer-container-wrapper').css('margin-top', '0');
	$('#outer-container-wrapper').css('top', 'auto');
	$('#outer-container').css('height', '100%');
	$('#outer-container').css('width', '100%');
	$('#outer-container').css('margin', '0');
	$('#outer-container').css('position', 'relative');

	flashLoaded = true;
}

