var contentWidth = 884;
var contentHeight = 854 + 63;

function updateHashVariable(key, value) {
	window.location.hash = "#" + key + "=" + value;
}

function eventWindowResized(ObjectID)
{
	resizeWidth(ObjectID);
	resizeHeight(ObjectID);
}

function resizeWidth(ObjectID)
{
	// Check ob replace objekt existiert
	if(!(oResize= document.getElementById(ObjectID)))
	{
		return false;	
	}
	
	windowWidth = contentWidth;
	
	if (window.innerWidth)
	{
		windowWidth = window.innerWidth;
	}
	else if (document.body && document.body.offsetWidth)
	{
		windowWidth = document.body.offsetWidth;
	}
		
	if(windowWidth > contentWidth)
	{
		oResize.style.width = "100%";
	}
	else
	{
		oResize.style.width = contentWidth + "px";
	}

}

function resizeHeight(ObjectID)
{
	// Check ob replace objekt existiert
	if(!(oResize= document.getElementById(ObjectID)))
	{
		return false;	
	}
	windowHeight = contentHeight;
	
	if (window.innerHeight)
	{
		windowHeight = window.innerHeight;
	}
	else if (document.body && document.body.offsetHeight)
	{
		windowHeight = document.body.offsetHeight;
	}
		
	if(windowHeight > contentHeight)
	{
		oResize.style.height = "100%";
	}
	else
	{
		oResize.style.height = contentHeight + "px";
	}

}

function recalcHeight(contentH,ObjectID) {
	contentHeight = contentH;
	resizeHeight(ObjectID);
}

function resizeFlash(ObjectID, width, height)
{
	//alert("resizeFlash: " + width + " / " + height);
	
	// Check ob Objekt existiert
	if(!(oResize= document.getElementById(ObjectID)))
	{
		return false;	
	}
	if (width != null)
	{
		oResize.style.width = width;
	}
	if (height != null)
	{
		oResize.style.height = height;
	}
	
	try
	{
		document.getElementById('shadowContentLeft').style.bottom=-1;
		document.getElementById('shadowContentLeft').style.bottom=0;
		document.getElementById('shadowContentRight').style.bottom=-1;
		document.getElementById('shadowContentRight').style.bottom=0;
	}
	catch(E){}
}

function createFlashControl(DivID, replaceDivID, ObjectID, ObjectURL)
{
	
	// Check ob objekt existiert
	/*if(!(oTargetDiv = document.getElementById(DivID)))
	{
		return;	
	}*/
	// Check ob replace objekt existiert
	if(!(oReplaceDiv = document.getElementById(replaceDivID)))
	{
		return;	
	}
	if(!(oTargetDiv = oReplaceDiv.parentNode))
	{
		return;	
	}
	
	oFlashObject = document.createElement('object');
	oTargetDiv.appendChild(oFlashObject,oReplaceDiv);
	
	//params
	oParam = document.createElement('param');
	oParam.setAttribute("name","movie");
	oParam.setAttribute("value",ObjectURL);
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","quality");
	oParam.setAttribute("value","high");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","play");
	oParam.setAttribute("value","true");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","bgcolor");
	oParam.setAttribute("value","#ffffff");
	oFlashObject.appendChild(oParam);
	
	/*oParam = document.createElement('param');
	oParam.setAttribute("name","wmode");
	oParam.setAttribute("value","transparent");
	oFlashObject.appendChild(oParam);*/
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","scale");
	oParam.setAttribute("value","showall");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","salign");
	oParam.setAttribute("value","lt");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","allowScriptAccess");
	oParam.setAttribute("value","sameDomain");
	oFlashObject.appendChild(oParam);
	
	//object
	oFlashObject.setAttribute("id",ObjectID);
	oFlashObject.className = "flashContent";
	oFlashObject.setAttribute("type","application/x-shockwave-flash");
	oFlashObject.setAttribute("data",ObjectURL);
	
}

function updateAlternative(paragraphId, filenameFullImage, title, description)
{
	var node;
	
	//alert("updateAlternative: \n" + paragraphId + "\n" + filenameFullImage + "\n" + title + "\n" + description);
	
	node = document.getElementById('altFlashImg_' + paragraphId);
	if (node)
	{
		document.getElementById('altFlashImg_' + paragraphId).src = filenameFullImage;
	}
	
	node = document.getElementById('altFlashTitle_' + paragraphId);
	if (node)
	{
		if (node.firstChild)
		{
			node.firstChild.replaceData(0, document.getElementById('altFlashTitle_' + paragraphId).firstChild.nodeValue.length, title);
		}
		else
		{
			node.appendChild(document.createTextNode(title));
		}
	}
	
	node = document.getElementById('altFlashDescription_' + paragraphId);
	if (node)
	{
		if (node.firstChild)
		{
			node.firstChild.replaceData(0, document.getElementById('altFlashDescription_' + paragraphId).firstChild.nodeValue.length, description);
		}
		else
		{
			node.appendChild(document.createTextNode(description));
		}
	}		
}


function createFlash(DivID, ObjectID, ObjectURL,widthEm,heightEm)
{
	
	//alert("DEV: createFlash: " + widthEm + " x " + heightEm);
	
	var oFlashObject = null;
	// Check ob objekt existiert
	if(!(oTargetDiv = document.getElementById(DivID)))
	{
		return;	
	}
	
	try
	{
		//var createElementString = '<object style="width: 100%; height: 100%;" />';
		var createElementString = '<object style="width: ' + widthEm + 'em; height: ' + heightEm + 'em;" />';
		// Attribute erstellen
		oFlashObject = document.createElement(createElementString);
	}
	catch(e){}

	// Normale DOM Browser
	if(!oFlashObject || oFlashObject.nodeName != "OBJECT")
	{
		// nicht IE also kommt mit /n zurecht anstelle /r
		lineBreakType = "n";
		
		// auslesen des Namens
		oFlashObject = document.createElement('object');
	
		// Attribute erstellen
		attributesLength = oFlashObject.attributes.length;
		oFlashObject.setAttribute('style','width: ' + widthEm + 'em; height: ' + heightEm + 'em;');
		//oFlashObject.setAttribute('style','width: 100%; height: 100%;');
	}
	
	// aktuellen inhalt entfernen
	var contentLength = oTargetDiv.childNodes.length;
	for(var i=0;i<contentLength;i++)
	{
		oTargetDiv.removeChild(oTargetDiv.firstChild);
	}
	
	// Neuen inhalt einhaengen
	oTargetDiv.appendChild(oFlashObject);
	
	//params
	oParam = document.createElement('param');
	oParam.setAttribute("name","movie");
	oParam.setAttribute("value",ObjectURL);
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","quality");
	oParam.setAttribute("value","best");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","play");
	oParam.setAttribute("value","true");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","bgcolor");
	oParam.setAttribute("value","#ffffff");
	oFlashObject.appendChild(oParam);
	
	// Setting wmode to 'transparent' causes several problems:
	// 1) Mis-positioning of input field focus
	// 2) Keymapping screw-up (@)
	// 3) Black background in print version, no matter what 'bgcolor' set (Firefox)
/*	
	oParam = document.createElement('param');
	oParam.setAttribute("name","wmode");
	oParam.setAttribute("value","transparent");
	oFlashObject.appendChild(oParam);
*/	

	oParam = document.createElement('param');
	oParam.setAttribute("name","scale");
	oParam.setAttribute("value","noborder");
	oFlashObject.appendChild(oParam);
	
	oParam = document.createElement('param');
	oParam.setAttribute("name","salign");
	oParam.setAttribute("value","lt");
	oFlashObject.appendChild(oParam);
	
/*
	oParam = document.createElement('param');
	oParam.setAttribute("name","allowFullScreen");
	oParam.setAttribute("value","true");
	oFlashObject.appendChild(oParam);
*/

	oParam = document.createElement('param');
	oParam.setAttribute("name","allowscriptaccess");
	oParam.setAttribute("value","always");
	oFlashObject.appendChild(oParam);

	//object
	oFlashObject.setAttribute("id",ObjectID);
	oFlashObject.className = "flashContentFlex";
	oFlashObject.setAttribute("type","application/x-shockwave-flash");
	oFlashObject.setAttribute("data",ObjectURL);

}