
window.onload = Initialize;

windowLoaded = false;
previousNum = 0;
function Initialize()
{ 
   windowLoaded = true;
   ShowInfo(0)   
}

function star(id,imageName,wish,sender,topPosition,leftPosition)
{
	this.id = id;
	this.imageName = imageName;
	this.wish = wish;
	this.sender = sender;
	this.topPosition = topPosition;
	this.leftPosition = leftPosition;
}
	
function ShowInfo(num)
{
	if(!windowLoaded)
		return;

	//if(document.embeds[num] != null &&  document.embeds[num].IsReady() == true)
	//eval("document.midiPlayerBG.stop()");
	//eval("document.midiPlayer" + num + ".play()");
	HideInfo(previousNum);
	ShowItem('divWish'+num,'visible');
}
function HideInfo(num)
{
	if(!windowLoaded)
		return;

	//if (document.embeds[num] != null &&  document.embeds[num].IsReady() == true)
	//eval("document.midiPlayer" + num + ".stop()");

	ShowItem('divWish'+num,'hidden');	
}

function CreateSky()
{
	if(document.all)
	{
		maxHeight = document.body.clientHeight;
		maxWidth = document.body.clientWidth;
	}	
	else
	{
		maxHeight = 400;
		maxWidth = 700;
	}	

	randTopPositionPrevious = 0;
	randTopPositionPreviousPrevious = 0;
	for(i=0; i<stars.length; i++)
	{
		do
		{
			randTopPosition = Math.floor((maxHeight-93) * Math.random()) + 93;
		} while ( (Math.abs(randTopPosition-randTopPositionPrevious)<(maxHeight/5)) || (Math.abs(randTopPosition-randTopPositionPreviousPrevious)<(maxHeight/5)) )
		randLeftPosition = i*60 ;
		stars[i].topPosition = randTopPosition;
		stars[i].leftPosition = randLeftPosition;
		randTopPositionPreviousPrevious = randTopPositionPrevious;
		randTopPositionPrevious = randTopPosition;
	}
	
	skyText = "";
	//skyText += "<EMBED name=midiPlayerBG id=midiPlayerBG src='images/bg.mid' HIDDEN=TRUE height=0 width=0 autostart=true loop=0>";
	skyText += "<BGSOUND src='images/bg.mid' loop=-1>";
	skyText += "<div id=divStar" + i + "  class=DIVSTAR style='position:absolute;top:0px;left:0px;'></div>\n";

	
	for(i=0; i<stars.length; i++)
	{
		topPosition = stars[i].topPosition;
		leftPosition = stars[i].leftPosition;
		//myStar = (myId==stars[i].id) ? " <br><img src='images/arrow.gif'> " : " ";
		myStar = " ";
		skyText += "<div id=divStar" + i + "  class=DIVSTAR style='position:absolute;top:" + topPosition  + "px;left:" + leftPosition +"px;' onmouseover='javascript:ShowInfo(" + i + ")'  onmouseout='javascript:HideInfo(" + i + ")'><img src='images/" + stars[i].imageName + "'>" + "<br>" + stars[i].sender + myStar + "</div>\n";
		/*
		if(document.all)
			wishVisibilityState="hidden";
		else
			wishVisibilityState="visible";	
		*/	
		wishVisibilityState="hidden";
			
		skyText += "<div id=divWish" + i + "  class=DIVWISH style='position:absolute;top:" + (topPosition-15)  + "px;left:" + leftPosition +"px;visibility:" + wishVisibilityState + ";z-index:2;'>" + stars[i].wish + "</div>\n";
		//midiFile = "images/" + i%5 + ".mid";
	    //skyText += "<EMBED name=midiPlayer" + i + " id=midiPlayer" + i + " src='" + midiFile + "' HIDDEN=TRUE height=0 width=0 autostart=false loop=0>"
	}
	//alert(skyText)
	document.write(skyText);
}

browLayer = '';
typeSt = '';


if (document.all)
{
  		browLayer = 'document.all';
  		typeSt = '.style';
}
else
{
		browLayer = 'document.layers';
   		typeSt = '';
}

function MoveItem(itemName,topParam,leftParam)
{
 	if (itemName != "")
	{
	  	document.getElementById(itemName).style.top = topParam;
	  	document.getElementById(itemName).style.left = leftParam;
		/*
		eval(browLayer + '["' + itemName + '"]' + typeSt + '.top=' + topParam);
	  	eval(browLayer + '["' + itemName + '"]' + typeSt + '.left=' + leftParam);
	  	*/
	}	
}

function ShowItem(itemName,mode)
{
 	
	if (itemName != "")
		document.getElementById(itemName).style.visibility = mode;
	  	//eval(browLayer + '["' + itemName + '"]' + typeSt + '.visibility="' + mode + '"');
}


function msieversion()
{		
	var ua = window.navigator.userAgent
	var msie = ua.indexOf ( "MSIE " )
	if ( msie > 0 )		// is Microsoft Internet Explorer; return version number
		return parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) )
	else
		return 0	// is other browser
}
runningIE5 = (msieversion() >= 5);

