var viewCount = 0;
var viewMax = 20;
var AUDAPP = new Object();
var FLAPP = new Object();
//var byte[] bytes = new byte[2048];

function initHive() {
  // alert(getElement('ASWF'));
   AUDAPP=getMedia('APPLET');
   FLAPP=getMedia('ASWF');
}

function fromASMessage(m) {
		JSMMessage("<<    "+m+"<br>");
		if(m=="callback") {
			FLAPP.toASMessage('callback');
			JSMMessage(m+"     >><br>");
		} 	
}

function APPLETtoAS(m) {
//	JSMMessage(m+"    >><br>");
	// loopback until flash is available
	if(FLAPP.toASMessage == undefined) {
		setTimeout("APPLETtoAS('"+m+"');",1000);
	}
	FLAPP.toASMessage(m+"");
}

function toConsole(m) {
	JSMMessage(m+"<br>");
}

function byteToConsole(b) {
	JSMMessage(m+"<br>");
}

function toAPPLETMessage(m) {
		JSMMessage("<<     "+m+"<br>");
		AUDAPP.messenger(m);		
}

function JSMMessage(m) {
	//alert(dataStorage);
/*
	var e = getElement('hiveOutput');
    if(e) {
		if(viewCount < viewMax) {
			e.innerHTML += m;
			viewCount++;
		} else {
			e.innerHTML = m;
			viewCount = 0;
		}
	}
*/
}

function getElement(el) {
	var elem;
		if( document.getElementById ) elem = document.getElementById(el); // this is the way the standards work
		else if( document.all ) elem = document.all[el];// this is the way old msie versions work
		else if( document.layers ) elem = document.layers[el]; // this is the way nn4 works
	return elem;
}

function getMedia(mName) {
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[mName] : document[mName];
}

/*
function moveImage() {
	//Keep on moving the image till the target is achieved
	if(x<dest_x) x = x + interval; 
	if(y<dest_y) y = y + interval;
	
	//Move the image to the new location
	document.getElementById("ufo").style.top  = y+'px';
	document.getElementById("ufo").style.left = x+'px';

	if ((x+interval < dest_x) && (y+interval < dest_y)) {
		//Keep on calling this function every 100 microsecond 
		//	till the target location is reached
		window.setTimeout('moveImage()',100);
	}
}*/

