/*
 * Various JavaScript functions used in the Deep Cells website.
 *
 * Author: Daniel J. R. May (daniel.may@londongt.org)
 * Version: 1.0, 19 November 2007
 */

function resizeWindow(theurl, windowname, features) {

	window.open(theurl, windowname, features);
}

function createParamElement(name, value) {

	paramElement = document.createElement("param");
	paramElement.setAttribute("name", name);
	paramElement.setAttribute("value", value);
	
	return paramElement;
}

function createStandardsCompliantFlashObjectElement(url, width, height, flashVars) {
		
	flashObject = document.createElement("object");
	flashObject.setAttribute("data", url);
	flashObject.setAttribute("type", "application/x-shockwave-flash");
	flashObject.setAttribute("width", width);
	flashObject.setAttribute("height", height);
	flashObject.setAttribute("style", "position: absolute; top: 0; left: 0; width: 100%; height: 100%;");

	flashObject.appendChild(createParamElement("quality", "high"));
	flashObject.appendChild(createParamElement("flashvars", flashVars));
	flashObject.appendChild(createParamElement("allowscriptaccess", "always"));
				
	return flashObject;			
}

function isIE() {
	
	if (navigator.appName == "Microsoft Internet Explorer" ) {
		return true;
	} else {
		return false;
	}
}

function replaceIEFlashObjectElement(url, flashVars) {

	bodyElementsArray = document.getElementsByTagName("body");
	bodyElement = bodyElementsArray[0];

	objectElementsArray = document.getElementsByTagName("object");
	ieFlashObjectElement = objectElementsArray[0];
	 
	nonIEFlashObjectElement = createStandardsCompliantFlashObjectElement(url, 800, 600, flashVars);
	
	bodyElement.replaceChild(nonIEFlashObjectElement, ieFlashObjectElement);	
}
