/*************************************************************************************
* This code may be borrowed as long as it used for non-commercial purposes and this
* comment block is left intact.  A link back to my site would be greatly appreciated, 
* http://bugimus.com/
* You CANNOT use any images from my site without my permission!!!
* If you have any questions please drop me a line bugs@bugimus.com
* Copyright © 1999-2001 Bugimus
**************************************************************************************/

// Determine browser.
var IE5=false;var NN4=false; var NN6=false;
if(document.all) IE5=true
else if(document.layers) NN4=true
else if(document.getElementById) NN6=true

if(NN4) window.location="http://www.bugimus.com/bugula/index.html"

// Define globals.
textflagOn=false;
sitemapflagOn=false;
bugflagOn=false;
pageState=0; // 0=button1, 1=button2, etc.
MAXPAGES=10;
initComplete=false;
var g_inputbox_sz=20  // for IE and everything else but...
if(NN6)g_inputbox_sz=10

function pageOn() {
	if(!sitemap.active)
	if( !page.active && !textflagOn ) {
		textflagOn=true;
		page.chase(205,35);
		if(initComplete) showBug();
	}
}

function pageOff() {
	if( !page.active && textflagOn ) {
		page.chase(-70,-570);
		textflagOn=false;
		if(!textflagOn&&!sitemapflagOn)hideBug();
	}
}

function sitemapOn() {
	if(!page.active)
	if( !sitemap.active && !sitemapflagOn ) {
		sitemapflagOn=true;
		sitemap.chase(20,200);
		if(initComplete) showBug();
	}
}

function sitemapOff() {
	if( !sitemap.active && sitemapflagOn ) {
		sitemap.chase(-680,200);
		sitemapflagOn=false;
		if(!textflagOn&&!sitemapflagOn)hideBug();
	}
}

// Petal coordinates as a group.
px=2;
py=-2;
aperature=45;

// Hide petal coordinates.
p1hx=25+px;   p1hy=25+py;
p2hx=25+px;   p2hy=25+py;
p3hx=25+px;   p3hy=75+py;
p4hx=75+px;   p4hy=25+py;

// Show petal coordinates.
p1sx=p1hx;  p1sy=p1hy-aperature;
p2sx=p2hx-aperature;  p2sy=p2hy;
p3sx=p3hx;  p3sy=p3hy+aperature;
p4sx=p4hx+aperature;  p4sy=p4hy;

function showBug() {
	if( !petal4.active && !bugflagOn ) {
		petal1.chase(p1sx,p1sy);
		petal2.chase(p2sx,p2sy);
		petal3.chase(p3sx,p3sy);
		petal4.chase(p4sx,p4sy);
		bugflagOn=true;
	}
}

function hideBug() {
	if( !petal4.active && bugflagOn ) {
		petal1.chase(p1hx,p1hy);
		petal2.chase(p2hx,p2hy);
		petal3.chase(p3hx,p3hy);
		petal4.chase(p4hx,p4hy);
		bugflagOn=false;
	}
}

function pageInit() {
	petal1 = new movingObject("petal1","petal1Div",p1hx,p1hy,50);
	petal2 = new movingObject("petal2","petal2Div",p2hx,p2hy,50);
	petal3 = new movingObject("petal3","petal3Div",p3hx,p3hy,50);
	petal4 = new movingObject("petal4","petal4Div",p4hx,p4hy,50);

	document.getElementById("globeDiv").style.visibility="visible";
	document.getElementById("leftbarDiv").style.visibility="visible";
	document.getElementById("topbarDiv").style.visibility="visible";
	document.getElementById("petal1Div").style.visibility="visible";
	document.getElementById("petal2Div").style.visibility="visible";
	document.getElementById("petal3Div").style.visibility="visible";
	document.getElementById("petal4Div").style.visibility="visible";
	document.getElementById("chromebugDiv").style.visibility="visible";
	setTimeout("document.getElementById('button1Div').style.visibility='visible'",  300);
	setTimeout("document.getElementById('button2Div').style.visibility='visible'",  600);
	setTimeout("document.getElementById('button3Div').style.visibility='visible'",  900);
	setTimeout("document.getElementById('button4Div').style.visibility='visible'", 1200);
	setTimeout("document.getElementById('button5Div').style.visibility='visible'", 1500);
	setTimeout("document.getElementById('button6Div').style.visibility='visible'", 1800);
	setTimeout("showBug()", 2000);

	sitemap = new movingObject("sitemap","sitemapDiv",0,0,20);
	sitemap.warp(-680,200);
	sitemap.show();
	
	page = new movingObject("page","pageDiv",0,0,20);
	if(!textflagOn)pageOn();
	page.warp(205,35);
	page.show();
	if(pageState<0||pageState>MAXPAGES)pageState=0;
	
	initComplete=true;
}

if( document.images ) {
	bugmorph1 = new series( "bugmorph1", 75, "chromebugDiv" );
	bugmorph2 = new series( "bugmorph2", 75, "chromebugDiv" );
	bugmorph3 = new series( "bugmorph3", 75, "chromebugDiv" );
	bugmorph4 = new series( "bugmorph4", 75, "chromebugDiv" );
	bugmorph5 = new series( "bugmorph5", 75, "chromebugDiv" );
	bugmorph6 = new series( "bugmorph6", 75, "chromebugDiv" );
}
function loadImages() {
	if( document.images ) { 
		bugmorph1.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph1.loadimage( "purplescape/gfx/chromebug_welcome1.jpg" );
		bugmorph1.loadimage( "purplescape/gfx/chromebug_welcome0.jpg" );

		bugmorph2.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph2.loadimage( "purplescape/gfx/chromebug_dhtml1.jpg" );
		bugmorph2.loadimage( "purplescape/gfx/chromebug_dhtml0.jpg" );

		bugmorph3.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph3.loadimage( "purplescape/gfx/chromebug_wallpaper1.jpg" );
		bugmorph3.loadimage( "purplescape/gfx/chromebug_wallpaper0.jpg" );

		bugmorph4.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph4.loadimage( "purplescape/gfx/chromebug_contact1.jpg" );
		bugmorph4.loadimage( "purplescape/gfx/chromebug_contact0.jpg" );

		bugmorph5.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph5.loadimage( "purplescape/gfx/chromebug_links1.jpg" );
		bugmorph5.loadimage( "purplescape/gfx/chromebug_links0.jpg" );

		bugmorph6.loadimage( "purplescape/gfx/chromebug0.jpg" );
		bugmorph6.loadimage( "purplescape/gfx/chromebug_sitemap1.jpg" );
		bugmorph6.loadimage( "purplescape/gfx/chromebug_sitemap0.jpg" );
	}
}

function windowPop(url,name,features) {
	window.open(url,name,features)
}

var g_numdivs=10
function xinit() {
	loadImages()
	pageInit()
	xshowDiv(0)
}
function xshowDiv( which ) {
	for(i=0;i<g_numdivs;i++) {
		eval("document.getElementById('p"+i+"').style.visibility='hidden'")
	}
	eval("document.getElementById('p"+which+"').style.visibility='visible'")
}

onload=xinit
