///////////////////////////////////////////////////
//      mFloat Interface by MarkWillis.co.uk     //
/*************************************************/
var mFloatRoot = 'http://www.inbite.com/inc/floater/';
var mFloatViewportWidth;
var mFloatViewportHeight;
var MouseX = 0; var MouseY = 0; var overit = 0;
function TrackingMousePosition(e)
{
	e = e || window.event;
	if (e.pageX)
	{
		MouseX = e.pageX;
		MouseY = e.pageY;
		scanViewport();
		if(MouseX + 350 > mFloatViewportWidth){MouseX = MouseX - 300;}
		
		// mFloat - active movement (disabld by default)
		if(document.getElementById('mFloatBlock').style.display == "block")
		{
			//document.getElementById('mFloatBlock').style.left = (MouseX + 10) + "px";
			//document.getElementById('mFloatBlock').style.top = (MouseY + 25) + "px";
		}
		// Bubble - active movment
		if(document.getElementById('the-bubble').style.display == "block"){
			document.getElementById('the-bubble').style.left = (MouseX + 10) + "px";
			document.getElementById('the-bubble').style.top = (MouseY + 10) + "px";
		}
	}
	else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		y = window.event.clientY+document.documentElement.scrollTop;
		scanViewport();
		if(x + 350 > mFloatViewportWidth){x = x - 300;}
		
		if(document.getElementById('mFloatBlock').style.display == "block")
		{
			//document.getElementById('mFloatBlock').style.left = (x + 10) + "px";
			//document.getElementById('mFloatBlock').style.top = (y + 25) + "px";
		}
		if(document.getElementById('the-bubble').style.display == "block"){
			document.getElementById('the-bubble').style.left = (x + 10) + "px";
			document.getElementById('the-bubble').style.top = (y + 10) + "px";
		}
	}
}
//window.onmouseover = TrackingMousePosition;
//window.onmousemove = TrackingMousePosition;
document.onmousemove = TrackingMousePosition;
// 'normal' browsers 
function scanViewport()
{
if (typeof window.innerWidth != 'undefined')
{
	mFloatViewportWidth = window.innerWidth;
	mFloatViewportHeight = window.innerHeight;
}
// IE6
else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
{
	mFloatViewportWidth = document.documentElement.clientWidth;
	mFloatViewportHeight = document.documentElement.clientHeight;
}
// even older IE :O
else
{
	mFloatViewportWidth = document.getElementsByTagName('body')[0].clientWidth;
	mFloatViewportHeight = document.getElementsByTagName('body')[0].clientHeight;
}
}
scanViewport();

function mFloatOpen(useMouse, useY, command, query)
{
	// useMouse: set to 1 if you want to have mFloat popup at the mouse's location (centered), set to 0 if you want manual Y pos
	// useY: manual y location of mFloat popup (vertical position)
	
	var useHeight = 0;
	if(document.getElementById('mFloatBlock').style.display == "block")
	{
		// Already open, lets keep it a steady height
		var setInnerHeight = document.getElementById('mFloatInner').offsetHeight;
		useHeight = 1;
	}
	
	var x = 0; var y = 0;
	var oY = useY;
	if(MouseX)
	{
		x = MouseX;
		
		if(useMouse == 1){
		y = MouseY;
		}else{
		scroll(0,(oY - 10));
		y = oY;
		}
	}
	else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		if(useMouse == 1){
		y = window.event.clientY+document.documentElement.scrollTop;
		}else{
		scroll(0,(oY - 10));
		y = oY;
		}
	}
	document.getElementById('mFloatBlock').style.left = ((mFloatViewportWidth / 2) - 300) + "px";
	document.getElementById('mFloatBlock').style.top = (y + 10) + "px";
	document.getElementById('mFloatBlock').innerHTML = '<div class="mFloat-inner" id="mFloatInner"><div class="mFloat-close"><a href="#" onclick="return mFloatClose();"><!-- close --></a></div><div class="mFloat-main"><h3>loading...</h3></div></div>';
	if(useHeight == 1){document.getElementById('mFloatInner').style.height = setInnerHeight + "px";}
	document.getElementById('mFloatBlock').className = 'mFloatBlock-on';
	document.getElementById('mFloatBlock').style.display = "block";
	var d = new Date();
	var tsec = d.getSeconds();
	var ajaxRequest;
	try{ajaxRequest = new XMLHttpRequest(); } catch (e){try{ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");} catch (e) {try{ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e){return true;}}}
	ajaxRequest.onreadystatechange = function()
	{
	if(ajaxRequest.readyState == 4){
		document.getElementById('mFloatBlock').innerHTML = ajaxRequest.responseText;
	}
	}
	var addQuery = query.replace(/amp/g, '&');
	var queryString = mFloatRoot + command + '?time=' + tsec + addQuery;
	ajaxRequest.open("GET", queryString, true);
	ajaxRequest.send(null);
	return false;
}
function mFloatClose()
{
	document.getElementById('mFloatBlock').innerHTML = ''; document.getElementById('mFloatBlock').className = 'aianBlock-off'; document.getElementById('mFloatBlock').style.display = "none";
	return false;
}


/////////////////////////////////////////////////////////////<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// mBubble ::: mFloat extension, by Mark Willis

function showBubble(imageID, bubbleTITLE, bubbleCONTENT){
document.getElementById('the-bubble').innerHTML = "<div class=\"bubble-inside\"><b>" + bubbleTITLE + "</b><br />" + bubbleCONTENT + "</div>";
document.getElementById('the-bubble').className = 'bubble-on';
document.getElementById('the-bubble').style.display = "block";
var x = 0; var y = 0;
if (MouseX)
	{
		x = MouseX;
		y = MouseY;
	}
else
	{
		x = window.event.clientX+document.documentElement.scrollLeft;
		y = window.event.clientY+document.documentElement.scrollTop;
	}
if(x + 350 > mFloatViewportWidth){x = x - 300;}
document.getElementById('the-bubble').style.left = (x + 10) + "px";
document.getElementById('the-bubble').style.top = (y + 10) + "px";
overit = 1;
}

function clearBubble(){
document.getElementById('the-bubble').innerHTML = '';
document.getElementById('the-bubble').className = 'bubble-off';
document.getElementById('the-bubble').style.display = "none";
overit = 0;
}


// Facebook Fan Page thing
function toggleFBFan()
{

	scanViewport();
	document.getElementById('fbFan').style.left = ((mFloatViewportWidth / 2) - 150) + "px";
	document.getElementById('fbFan').style.top = "100px";
	
	
	if(document.getElementById('fbFan').className != "fbFanHolder-on")
	{
		document.getElementById('fbFan').className = "fbFanHolder-on";
	}else{
		document.getElementById('fbFan').className = "fbFanHolder-off";
	}
	return false;
}





// CrossFader by BrandSpankingNew.net
var useBSNns;

if (useBSNns)
{
	if (typeof(bsn) == "undefined")
		bsn = {}
	var _bsn = bsn;
}
else
{
	var _bsn = this;
}


_bsn.Crossfader = function (divs, fadetime, delay )
{	
	this.nAct = -1;
	this.aDivs = divs;
	
	for (var i=0;i<divs.length;i++)
	{
		document.getElementById(divs[i]).style.opacity = 0;
		document.getElementById(divs[i]).style.filter = "alpha(opacity=0)";
		document.getElementById(divs[i]).style.visibility = "hidden";
	}
	
	this.nDur = fadetime;
	this.nDelay = delay;
		
	this._newfade();
}


_bsn.Crossfader.prototype._newfade = function()
{
	if (this.nID1)
		clearInterval(this.nID1);
	
	this.nOldAct = this.nAct;
	this.nAct++;
	if (!this.aDivs[this.nAct])	this.nAct = 0;
	
	if (this.nAct == this.nOldAct)
		return false;
	
	document.getElementById( this.aDivs[this.nAct] ).style.visibility = "visible";
	
	this.nInt = 50;
	this.nTime = 0;
	
	var p=this;
	this.nID2 = setInterval(function() { p._fade() }, this.nInt);
}


_bsn.Crossfader.prototype._fade = function()
{
	this.nTime += this.nInt;
	
	var ieop = Math.round( this._easeInOut(this.nTime, 0, 1, this.nDur) * 100 );
	var op = ieop / 100;
	document.getElementById( this.aDivs[this.nAct] ).style.opacity = op;
	document.getElementById( this.aDivs[this.nAct] ).style.filter = "alpha(opacity="+ieop+")";
	
	if (this.nOldAct > -1)
	{
		document.getElementById( this.aDivs[this.nOldAct] ).style.opacity = 1 - op;
		document.getElementById( this.aDivs[this.nOldAct] ).style.filter = "alpha(opacity="+(100 - ieop)+")";
	}
	
	if (this.nTime == this.nDur)
	{
		clearInterval( this.nID2 );
		
		if (this.nOldAct > -1)
			document.getElementById( this.aDivs[this.nOldAct] ).style.visibility = "hidden";	
		
		var p=this;
		this.nID1 = setInterval(function() { p._newfade() }, this.nDelay);
	}
}



_bsn.Crossfader.prototype._easeInOut = function(t,b,c,d)
{
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}