/* This notice must be untouched at all times.

HSB.js  v. 1.02
Last modified: 01. 01. 2004
The latest version is available from:
gsb at qwest dot net

Copyright (c) 2003-2004 Greg Baker. All rights reserved.

This HTML Scroll Box adds functionality to .swf movie.

This program is free software; you can redistribute
it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License
at http://www.gnu.org/copyleft/gpl.html for more details.

*/

//-------------------------- Min Lib
function lGO(s) { return document.getElementById(s) }  // libGetObj
function libSetXY(o,x,y) { o.style.left=x+'px'; o.style.top=y+'px' }
function libSetHW(o,h,w) {  o.style.height=h; o.style.width=w }
function libSetVisibility(o,v) { o.style.visibility=v }
function libSetHTML(o,s) { o.innerHTML=s }
function getOffsetLeft(o) { var ol=o.offsetLeft; while((o=o.offsetParent)!=null) { ol+=o.offsetLeft;} return ol }
function getOffsetTop (o) { var ot=o.offsetTop; while((o=o.offsetParent)!=null) { ot+=o.offsetTop;} return ot }
function libGetLoc(o) { var c=new Object();c.x=getOffsetLeft(o);c.y=getOffsetTop(o);return c }
//---------------------------------------------------------
var IFrameObj=null,IFrameDoc=null,IFrameSetup=false,pageBox=null,Locator;
function HSBsetup() {
	if(typeof(boxHeight)=="undefined") return;
	if(awaiting!=null) { clearInterval(awaiting); awaiting=null; }
	if(!IFrameSetup) {
		if(!IFrameObj) {
			try {
			  IFrameObj=document.createElement('iframe');
			  IFrameObj.setAttribute('id','RSIFrame');
			  IFrameObj.setAttribute('name','RSIFrame');
			  IFrameObj.setAttribute('scrolling','RSIFrame');
			  IFrameObj.style.height=0;
			  IFrameObj.style.width=0;
			  IFrameObj.style.border=0;
			  IFrameObj=document.body.appendChild(IFrameObj);
			  if(document.frames)IFrameObj=document.frames['RSIFrame'];
			} catch(exception) {
			  document.body.innerHTML+='\<iframe name="RSIFrame" id="RSIFrame" scrolling="no" style="border:0px none;height:0px;width:0px;"><\/iframe>';
			  IFrameObj=new Object();
			  IFrameObj.document=new Object();
			  IFrameObj.document.location=new Object();
			  IFrameObj.document.location.iframe=document.getElementById('RSIFrame');
			  IFrameObj.document.location.replace=function(location){this.iframe.src=location;}
			}
		}
		if(navigator.userAgent.indexOf('Gecko')!=-1&&!IFrameObj.contentDocument) {
			setTimeout('HSBsetup()',1);
			return;
		}
		Locator=lGO("Locator");
		xy=libGetLoc(Locator);
		pageBox=document.createElement("DIV");
		pageBox.className="HSBdefault";
		pageBox.setAttribute("id","htmlPage");
		libSetXY(pageBox,xy.x+boxLeft,xy.y+boxTop);
		libSetHW(pageBox,boxHeight,boxWidth+(navigator.userAgent.indexOf("MSIE")>=0?1:0));
		pageBox=document.body.appendChild(pageBox);
		IFrameSetup=true;
		if(typeof(initPage)!="undefined") typeof(initSkin)!="undefined"?getPage(initPage,initSkin):getPage(initPage);
	}
}
function getPage(url,skin) {
	if(url!='') {
		if(IFrameObj.contentDocument)IFrameDoc=IFrameObj.contentDocument;
		else if(IFrameObj.contentWindow)IFrameDoc=IFrameObj.contentWindow.document;
		else if(IFrameObj.document)IFrameDoc=IFrameObj.document;
		IFrameDoc.location.replace(url);
		pageBox.className=(typeof(skin)!="undefined")?skin:"HSBdefault";
		libSetVisibility(pageBox,"hidden");
		libSetHTML(pageBox,"&nbsp;");
	}
}
function showPage(doc) {
	libSetHTML(pageBox,doc.body.innerHTML);
	libSetVisibility(pageBox,"visible");
	pageBox.style.display=""
	if(IFrameObj.contentDocument)IFrameDoc=IFrameObj.contentDocument;
	else if(IFrameObj.contentWindow)IFrameDoc=IFrameObj.contentWindow.document;
	else if(IFrameObj.document)IFrameDoc=IFrameObj.document;
	IFrameDoc.location.replace("blank.html");
}
function restoreBox() {
	if(typeof(boxHeight)=="undefined") return;
	xy=libGetLoc(Locator);
	libSetXY(pageBox,xy.x+boxLeft,xy.y+boxTop);
}
function hideHSB() {
	pageBox.style.display="none";
}
function showHSB() {
	pageBox.style.display="";
}

//------- setup
var awaiting=null;
function onLoadStart() { awaiting=setInterval('HSBsetup()',20); };
window.onLoad = onLoadStart();
