// alert("htmlarea.js here");

		// html to swf
		
			// external interface functions (won't work unless publish SWF as Flash 8 or higher)
			
				function thisMovie(movieName) {
					// alert(movieName);
					var isIE = navigator.appName.indexOf("Microsoft") != -1;
					return (isIE) ? window[movieName] : document[movieName];
				}
				
				// test
				
					function fn_html2swf_test() {
						thisMovie("site").fn_html2swf_test("test");
					}
			
				// snapshot
				
					function fn_upload_completed() {
						var filename = document.getElementById("memory_filename").innerHTML;
						// alert("fn_upload_completed : filename=" + filename);
						thisMovie("site").fn_upload_completed(filename);
					}
					
					function fn_upload_started(filename) {
						// alert("fn_upload_started : filename=" + filename);
						thisMovie("site").fn_upload_started(filename);
					}
					
				// strings
				
					function fn_extint_html2swf_str(str) {
						// alert("fn_extint_html2swf_str : str=" + str);
						thisMovie("site").fn_extint_html2swf_str(str);
					}
				
			
		// swf to html
		
			// getURL
			
				fn_feedback = function(room_uuid) {
					document.getElementById("F_RoomID").value = room_uuid;
					document.form_feedback.submit();
				}
				fn_title = function(title) {
					document.title = title;
					window.status = title;
					// alert("title=-" + title + " document.title=" + document.title);
				}
				fn_exit = function() {
					// alert("fn_exit : about to exit");
					self.close();
				}
				fn_browser = function(showhide,page_url,content_url) {
					// alert("fn_browser : showhide=" + showhide + " page_url=" + page_url + " content_url=" + content_url);
					if(page_url == undefined) {
						page_url = "browser.php";
					}
					if(content_url != "") {
						page_url += "&content=" + content_url;
					}
					switch(showhide) {
						case "show" :
							wh_obj = fn_wh();
							winW = wh_obj.w;
							winH = wh_obj.h;
							// alert("w=" + winW + " h=" + winH);
							var wb_w = winW - 240 + 20;
							var wb_h = winH - 33;
							if(document.getElementById('adiframe').src != page_url) {
								document.getElementById('adiframe').src = page_url;
							}
							document.getElementById('b').style.width = wb_w + "px";
							document.getElementById('b').style.height = wb_h + "px";
							s('b');
						break;
						case "hide" :
							document.getElementById('b').style.width = 1 + "px";
							document.getElementById('b').style.height = 1 + "px";
							h('b');
						break;
						case "url" :
							// alert("fn_browser : url=" + url);
							document.getElementById('adiframe').contentWindow.fn_navigate(page_url);
						break;
					}
				}
				
				
			// external interface
			
				function fn_extint_swf2html_wh() {
					// alert("fn_extint_swf2html_wh : start");
					// resize in then out to ensure swf stretches properly
					wh_obj = fn_wh();
					winW = wh_obj.w;
					winH = wh_obj.h;
					thisMovie("site").fn_extint_html2swf_resize(winW - 1,winH - 1);
					thisMovie("site").fn_extint_html2swf_resize(winW,winH);
				}
				
				function fn_extint_swf2html_str(str) {
					// alert("fn_extint_swf2html_str : str=" + str);
					switch(str) {
						case "maximise" :
							window.moveTo(0,0);
							window.resizeTo(1024,768);
							// do twice to ensure resize works
							window.moveTo(0,0);
							window.resizeTo(1024,768);
						break;
					}
				}
				
				function fn_extint_swf2html_nudge() {
					setTimeout("window.focus()",100);
					window.focus();
					window.moveTo(0,0);
					window.moveTo(20,10);
					window.moveTo(20,20);
					window.moveTo(10,20);
					window.moveTo(10,10);
					window.moveTo(0,0);
					window.moveTo(20,10);
					window.moveTo(20,20);
					window.moveTo(10,20);
					window.moveTo(10,10);
					window.moveTo(0,0);
					window.moveTo(20,10);
					window.moveTo(20,20);
					window.moveTo(10,20);
					window.moveTo(10,10);
					window.moveTo(0,0);
					window.resizeTo(1024,768);
				}

				function fn_htmlarea_show(url,t,l,w,h) {
					// url = "http://www.beautymagonline.com/Home.asp";
					window.open('http://www.netdesign.co.nz');
					return;
					var id="abc";
					fn_create_htmlarea(id,url,t,l,w,h);
				}
				



// create

	fn_create_htmlarea = function(id,url,t,l,w,h) {
		// alert("fn_create_div : t=" + t + " l=" + l + " w=" + w + " h=" + h);
		// alert("fn_create_div : start");
		
		// create div
		var div = document.createElement("div");
		div.id = id;
		div.style.border = "none";
		div.style.width = w; // "200px";
		div.style.height = h; // "50px";
		div.style.top = t; // fn_rand(300); // t; // "350px";
		div.style.left = l; // "400px";
		div.innerHTML = "<b>Gidday</b><a href='javascript:fn_remove_element(\"abc\")' >remove</a><a href='javascript:fn_move(\"abc\",20,20)' >move</a><a href='javascript:fn_resize(\"abc\",450,300)' >resize</a><a href='javascript:fn_html2swf_test()' >callback</a>";
		div.style.position = "absolute";
		div.style["z-index"] = "10"; 
		div.style["background-color"] = "#ffffff"; 
		div.style.visibility = "visible";
		div.style.padding = "0px";
		// var result = document.body.appendChild(div);
		
		// create iframe
		var iframe = document.createElement("iframe");
		iframe.id = "def";
		iframe.style.width = w; // "200px";
		iframe.style.height = h; // "50px";
		iframe.src = url;
		iframe.scrolling = "auto"; // auto, yes, no
		iframe.frameBorder = "0"; // frameBorder not frameborder
		
		// add iframe to div
		div.appendChild(iframe);

		// add div to body
		document.body.appendChild(div);
	}
	
// move

	fn_move = function(id,x,y) {
		var el = document.getElementById(id);
		el.style.top = y;
		el.style.left = x;
	}

// resize

	fn_resize = function(id,w,h) {
		var el = document.getElementById(id);
		var elchild = el.childNodes.item(el.childNodes.length - 1); // is the last child (after the links, etc.)
		elchild.style.width = w;
		elchild.style.height = h;
		el.style.width = w;
		el.style.height = h;
	}

// random number

	fn_rand = function(n) {
		var rnd = Math.floor(Math.random( ) * n + 1 );
		return rnd;
	}

// create random div

	fn_create_div_random = function() {
		var top = fn_rand(300);
		var left = fn_rand(300);
		var width = fn_rand(300);
		var height = fn_rand(300);
		fn_create_div(top,left,width,height);
	}

// remove element

	// note that elements with same id will be removed in order that they were appended (order they appear in DOM xml I think)
	fn_remove_element = function(id) {
		var el = document.getElementById(id);
		el.parentNode.removeChild(el);
	}
	
// create paragraph
	
	// cannot run functions to add content to body until it is loaded
	function fn_create_paragraph(str) {
		// create a new paragraph
		newpara = document.createElement("p");
		
		// now some text
		newtext = document.createTextNode(str);
		
		// add the text to the paragraph
		newpara.appendChild(newtext);
		
		// add paragraph to body
		document.body.appendChild(newpara);
		
	}
