

	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// FLASH AND SHOCKWAVE LIBRARY / NEGORA © 2007
	//
	// Description: Functions to handle Flash and Shockwave elements.
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// FLASH
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	function Flash () {
	}
	
	
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// IT BUILDS A FLASH OR SHOCKWAVE ELEMENT ADAPTED TO THE VERSION OF PLAYER WHICH IS BEING USED
		//
		// _src				Source URL
		// _w					Width
		// _h					Height
		// ? _id				Element ID
		// ? _title				Title
		//
		// Note 1: It returns an "object" element for Windows based systems using IE. Otherwise, an "embed" element.
		// Note 2: It automatically recognises if it's either a Flash or Shockwave file checking its extension. If no extension
		// is present, it sets it as a Flash file by default.
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		
		Flash.build = function (_url, _w, _h, _id, _title) {
			
			// It builds a HTML object with the specified attributes.
			var obj = Flash.makeElement ("object", { "id": _id, "width": _w, "height": _h, "type": "application/x-shockwave-flash" });
			if (! CliNav.IE) obj.data = _url;

			// It builds and appends the necessary parameters to the HTML object.
			var params = { "movie": _url, "quality": "best", "wMode": "transparent", "menu": "false", "allowScriptAccess": "sameDomain" };
			for (var k in params) {
				var param = Flash.makeElement ("param", { "name": k, "value": params [k] });
				obj.appendChild (param);
			}

			return obj;
			
		};

		
		Flash.makeElement = function (_type, _map) {

			_map = _map || {};

			var elem;
			if (! CliNav.IE) {
				elem = document.createElement (_type);
			} else {

				// On IE: The attribute "name" must be specified on the element creation. Otherwise it's not adopted. The attribute "value" too, in order to
				// make the form reset button work properly with it.
				var attrib = "";
				if (_map ["name"] != null) attrib += " name=\"" + _map ["name"] + "\"";
				if (_map ["value"] != null) attrib += " value=\"" + _map ["value"] + "\"";
				if (_map ["type"] != null) attrib += " type=\"" + _map ["type"] + "\"";

				elem = document.createElement (attrib == "" ? _type : "<" + _type + attrib + ">");

			}

			// It uses the "setAttribute" method instead of accesing the object attributes directly because it's setting the default values.
			var rx = /^(?:name|value|type)$/;
			for (var k in _map) if (! rx.test (k)) elem [k] = _map [k];
			return elem;

		};
		
		
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// IT WRITES THE XHTML CODE OF A FLASH OR SHOCKWAVE ELEMENT ADAPTED TO THE VERSION OF PLAYER WHICH IS
		// BEING USED
		//
		// _src				Source URL
		// _w					Width
		// _h					Height
		// ? _id				Element ID
		// ? _title				Title
		//
		// Note 1: Only writting the XHTML code through a function removes the border around the Flash or Shockwave
		// elements which appear on IE. If you use "document.write ()" in the main script of a page, it will fail.
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
		
		Flash.write = function (_src, _w, _h, _id, _title) {
			
			var fl = Flash.build (_src, _w, _h, _id, _title);
			document.write (CliElem.getHTML (fl));
			
		};
	
	

