function getLanguageFolder() {
	var path_array = window.location.pathname.split("/");
	var path = "/"+path_array[1]+"/";
	//alert("getLanguageFolder: "+path);
	return path;
}

var testversion = false;
if(window.location.host.indexOf("apollinaris.local") >= 0 )
{
	var testversion = true;
}

if(testversion == true)
{
	/**
	* Online or offline mode
	*/
	var use_offline = false;
	
	/**
	* Location from document root with trailing slash.
	*/
	//var directory = "/de_de/";
	var directory = getLanguageFolder();
	
	
	/**
	* The target file for the redirects and the flash holder.
	*/
	var targetfile = "index.php";
	
	/**
	* If targetfile is your directory index (usually index.html or index.php), you can turn it on. For local use, turn it off.
	*/
	var hide_targetfile = true;
	
	/**
	* The index file of a directory. Usually it's something like index.html or index.php.
	*/
	var indexfile = "index.php";
	
	/**
	* Id of the html container, that is replaced by the flash file.
	*/
	var idcontent = "flashcontent";
	
	/**
	* If file extension is defined, erase it in SWFAddress value. This value should corresponding with extension of the indexfile. Leave it empty to include the file extension into the SWFAddress value.
	*/
	var file_extension = ".php";
}
else
{
	/**
	* Online or offline mode
	*/
	var use_offline = false;
	
	/**
	* Location from document root with trailing slash.
	*/
	//var directory = "/de_de/";
	var directory = getLanguageFolder();
	
	/**
	* The target file for the redirects and the flash holder.
	*/
	var targetfile = "index.html";
	
	/**
	* If targetfile is your directory index (usually index.html or index.php), you can turn it on. For local use, turn it off.
	*/
	var hide_targetfile = true;
	
	/**
	* The index file of a directory. Usually it's something like index.html or index.php.
	*/
	var indexfile = "index.html";
	
	/**
	* Id of the html container, that is replaced by the flash file.
	*/
	var idcontent = "flashcontent";
	
	/**
	* If file extension is defined, erase it in SWFAddress value. This value should corresponding with extension of the indexfile. Leave it empty to include the file extension into the SWFAddress value.
	*/
	var file_extension = ".html";
}

/**
* Configure the SWFObject embed
*/
function runSWFObject(flashvars, params, attributes) {
	params.base = "/bin/swf/";
	params.scale = "noscale";
	params.allowFullScreen  = "true";
	attributes.id = "apollinaris";
	
	swfobject.embedSWF("/bin/swf/Apollinaris.swf", "flashcontent", "100%", "100%", "9.0.47", "/bin/swf/expressInstall.swf", flashvars, params, attributes);
}


//////////////////////////////////////////////////////////
//														//
//   It is not necessary to edit the following lines!   //
//													    //
//////////////////////////////////////////////////////////
//test, if flash can be used
if (swfobject.hasFlashPlayerVersion("9.0.47")) {

	//get the document root
	if(use_offline == true) {
		var document_root = location.href.substring(0, location.href.lastIndexOf(directory) + directory.length);
	} else {
		var document_root = location.protocol + "//"+ location.host + directory;
	}

	//get relative path from entrypoint (document root)
	var relative_url = location.href.replace(document_root, "");

	//remove any fragment
	relative_url = relative_url.replace("#"+SWFAddress.getValue(), "");
	relative_url = (relative_url.lastIndexOf("#") == relative_url.length-1) ? relative_url.substring(0, relative_url.indexOf("#")) : relative_url;

	//if is root directory, then set relative url to index file
	if(relative_url == "" && SWFAddress.getValue() == "/") {
		relative_url = indexfile;
		
	//else if is any other directory without index file, add it
	} else if(relative_url.lastIndexOf("/") == relative_url.length-1) {
		relative_url += indexfile;
	}

	//if show targetfile in url, always redirect it. also by index it self
	if(hide_targetfile == false  && (relative_url != targetfile || SWFAddress.getValue() == "/")) {
		//console.log("REDIRECT: "+ document_root + targetfile + "#/"+relative_url.replace(file_extension, "")+"/");
		SWFAddress.href(document_root + targetfile + "#/"+relative_url.replace(file_extension, "")+"/");
		
	//hide the targetfile in url
	} else if(hide_targetfile == true && relative_url != indexfile) {
		//console.log("REDIRECT: "+ document_root + "#/"+relative_url.replace(file_extension, "")+"/");
		SWFAddress.href(document_root + "#/"+relative_url.replace(file_extension, "")+"/");
	}
	
	
	//the following lines where used by the index file, after redirect

	/**
	* Generates an URL from the SWFAddress value
	* @see ExternalInterface call from flash
	*/
	function getURLBySWFAddress(swfaddress) {
		//parse SWFAddress value for query string. Remove first slash and replace & for flash vars
		var raw_url = swfaddress.substring(1,SWFAddress.getValue().length);
		var querystring = (raw_url.lastIndexOf("?") > -1) ? raw_url.substring(raw_url.indexOf("?"), raw_url.length) : "";
		//cut traling slash an remove query from url
		if(querystring.lastIndexOf("/") == querystring.length-1) querystring = querystring.substring(0, querystring.length-1);
		raw_url = raw_url.replace(querystring, "");
		//cut trailing slash in url
		if(raw_url.lastIndexOf("/") == raw_url.length-1) raw_url = raw_url.substring(0, raw_url.length-1);
		//returns the file extension or undefined
		function getFileExtension(filename) { return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined; }
		//if no file extension given, add the defined fileextension
		raw_url += (getFileExtension(raw_url) == undefined && raw_url != "") ? file_extension + querystring : querystring;
		raw_url = document_root + raw_url;
		
		//alert(raw_url);
		return raw_url;
	}
	
	function getRelativeURLBySWFAddress(swfaddress) {
		//parse SWFAddress value for query string. Remove first slash and replace & for flash vars
		var raw_url = swfaddress.substring(1,SWFAddress.getValue().length);
		var querystring = (raw_url.lastIndexOf("?") > -1) ? raw_url.substring(raw_url.indexOf("?"), raw_url.length) : "";
		//cut traling slash an remove query from url
		if(querystring.lastIndexOf("/") == querystring.length-1) querystring = querystring.substring(0, querystring.length-1);
		raw_url = raw_url.replace(querystring, "");
		//cut trailing slash in url
		if(raw_url.lastIndexOf("/") == raw_url.length-1) raw_url = raw_url.substring(0, raw_url.length-1);
		//returns the file extension or undefined
		function getFileExtension(filename) { return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined; }
		//if no file extension given, add the defined fileextension
		raw_url += (getFileExtension(raw_url) == undefined && raw_url != "") ? file_extension + querystring : querystring;
		raw_url = directory + raw_url;
		//alert(raw_url);
		return raw_url;
	}
	
	


	//setup the flash vars
	var flashvars = {};
	flashvars.idcontent = idcontent;
	flashvars.document_root = document_root;
	flashvars.file_extension = file_extension;	
	flashvars.pageurl = (SWFAddress.getValue() != directory) ? getURLBySWFAddress(SWFAddress.getValue()).replace("&", "%26") : location.pathname;
	flashvars.pagehash = location.hash;

	var params = {};
	var attributes = {};
	attributes.id = idcontent;

	//embed the swf file via SWFObject
	runSWFObject(flashvars, params, attributes);
	
}



