//
// Random Person Image
// 

var imageArray = ["images/floater-person-01.png", "images/floater-person-02.png", "images/floater-person-03.png", "images/floater-person-04.png", "images/floater-person-05.png"];
var imageNum = Math.floor( Math.random()*imageArray.length );
var preload = new Image();
preload.src = imageArray[imageNum];

//
// Floater Scroll Mode
//

function getY( oElement )
{
	var iReturnValue = 0;
	while( oElement != null )
	{
		iReturnValue += oElement.offsetTop;
		oElement = oElement.offsetParent;
	}
	return iReturnValue;
}

var boxPos = -60;
var boxHeight = 206;
var boxPadTop = 2; 
var boxPadBot = 21;
var boxMinY = boxPos + getY( document.getElementById('floater') );

window.onscroll = function floaterscroll()
{			 
	var boxTop = getY( document.getElementById('floater') );
	var boxBot = boxTop + boxHeight;
	var pageTop = posTop();
	var pageBot = posBottom();
	if( pageTop > boxTop+boxPadTop ) { boxPos = boxPos + pageTop - boxTop + boxPadTop; }
	if( pageBot < boxBot-boxPadBot ) { boxPos = boxPos + pageBot - boxBot + boxPadBot; }
	if( boxPos < boxMinY ) { boxPos = boxMinY; }
	document.getElementById('floater').style.top = boxPos+'px';
};
           

   
// Browser Window Size & Position functions. copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005. You may copy these functions, but please keep the copyright notice as well
function pageWidth() { return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; }
function pageHeight() { return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null; }
function posLeft() { return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0; }
function posTop() { return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0; }
function posRight() { return posLeft()+pageWidth(); }
function posBottom() { return posTop()+pageHeight(); }

/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 * Script featured on Dynamic Drive (http://www.dynamicdrive.com) 12.08.2005
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot !== null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  , 10))) { o.root.style.left   = "0px"; }
		if (o.vmode  && isNaN(parseInt(o.root.style.top   , 10))) { o.root.style.top    = "0px"; }
		if (!o.hmode && isNaN(parseInt(o.root.style.right , 10))) { o.root.style.right  = "0px"; }
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom, 10))) { o.root.style.bottom = "0px"; }

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom, 10);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right , 10);
		o.root.onDragStart(x, y);

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX !== null) {	o.minMouseX	= e.clientX - x + o.minX; }
			if (o.maxX !== null) {	o.maxMouseX	= o.minMouseX + o.maxX - o.minX; }
		} else {
			if (o.minX !== null) { o.maxMouseX = -o.minX + e.clientX + x; }
			if (o.maxX !== null) { o.minMouseX = -o.maxX + e.clientX + x; }
		}

		if (o.vmode) {
			if (o.minY !== null) {	o.minMouseY	= e.clientY - y + o.minY; }
			if (o.maxY !== null) {	o.maxMouseY	= o.minMouseY + o.maxY - o.minY; }
		} else {
			if (o.minY !== null) { o.maxMouseY = -o.minY + e.clientY + y; }
			if (o.maxY !== null) { o.minMouseY = -o.maxY + e.clientY + y; }
		}

		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom, 10);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right , 10);
		var nx, ny;

		if (o.minX !== null) { ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX); }
		if (o.maxX !== null) { ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX); }
		if (o.minY !== null) { ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY); }
		if (o.maxY !== null) { ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY); }

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		{ nx = o.xMapper(y); }
		else if (o.yMapper)	{ ny = o.yMapper(x); }

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"], 10), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"], 10) );
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') { e = window.event; }
		if (typeof e.layerX == 'undefined') { e.layerX = e.offsetX; }
		if (typeof e.layerY == 'undefined') { e.layerY = e.offsetY; }
		return e;
	}
};

//
// Fix Flash wmode="transparent"
//

// loop through every embed tag on the site
/*
window.onload = function flashwmode()
{
	var embeds = window.frames[0].getElementsByTagName('embed');
	var html = 0;
	for(i=0; i<embeds.length; i++)  {
	    var embed = embeds[i];
	    var new_embed = 0;
	    // everything but Firefox & Konqueror
	    if(embed.outerHTML) {
	        html = embed.outerHTML;
	        // replace an existing wmode parameter
	        if(html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
	            { new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i,"wmode='transparent'"); }
	        // add a new wmode parameter
	        else 
	            { new_embed = html.replace(/<embed\s/i,"<embed wmode='transparent' "); }
	        // replace the old embed object with the fixed version
	        embed.insertAdjacentHTML('beforeBegin',new_embed);
	        embed.parentNode.removeChild(embed);
	    } else {
	        // cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
	        new_embed = embed.cloneNode(true);
	        if(!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase()=='window'){ new_embed.setAttribute('wmode','transparent'); }
	        embed.parentNode.replaceChild(new_embed,embed);
	    }
	}
	// loop through every object tag on the site
	var objects = window.frames[0].document.getElementsByTagName('object');
	for(i=0; i<objects.length; i++) {
	    object = objects[i];
	    var new_object;
	    // object is an IE specific tag so we can use outerHTML here
	    if(object.outerHTML) {
	        html = object.outerHTML;
	        // replace an existing wmode parameter
	        if(html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
	            { new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i,"<param name='wmode' value='transparent' />"); }
	        // add a new wmode parameter
	        else 
	            { new_object = html.replace(/<\/object\>/i,"<param name='wmode' value='transparent' />\n</object>"); }
	        // loop through each of the param tags
	        var children = object.childNodes;
	        for(j=0; j<children.length; j++) {
	            if(children[j].getAttribute('name').match(/flashvars/i)) {
	                new_object = html.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i,"<param name='flashvars' value='"+children[j].getAttribute('value')+"' />");
	            }
	        }
	        // replace the old embed object with the fixed versiony
	        object.insertAdjacentHTML('beforeBegin',new_object);
	        object.parentNode.removeChild(object);
	    }
	}
};
*/

