/*======================================================================*\
||	Copyright (c) 2010 Webhog Inc. All Rights Reserved.		||
||									||
||	WindowBounce javascript						||
||									||
||	Webhog Inc. o/a  World Wide Web Manitoba			||
||	306-690 St Joseph Street, Winnipeg, Manitoba r2h 3e2		||
||	Telephone: (204) 927.2100 | Toll Free: 1.877.932.4647		||
||									||
||	Names and Trademarks are Owned by the Copyright Holder.		||
\*======================================================================*/


var	ie		= document.all,
	dom		= document.getElementById,
	ns4		= document.layers,
	bouncelimit	= 8, //(must be divisible by 8)
	direction		= "up",
	d		= document;

var	objEnd		= 200,
	objBounceHeight	= 80,
	objBounces	= 1,
	objSpeed		= 50,
	objFrames	= 30;

function ToggleHover(obj,isHover) {
	var	hoverPattern	= /\bHover/,
		unhoverPattern	= /\bUnhover/;
	obj.className		= obj.className.replace((!isHover?hoverPattern:unhoverPattern),isHover?"Hover":"Unhover");
}


function initbox(){
	if (!dom&&!ie&&!ns4)
		return;
	styles		= d.createElement("link");
	styles.rel		= "stylesheet";
	styles.href	= "css/Special.css" 
	styles.type	= "text/css";
	d.getElementsByTagName("head")[0].appendChild(styles);
	crossobj		= (dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin;
	myEnder		= parseInt(crossobj.top);
	if(myEnder != null && myEnder > 5)
		objEnd		= myEnder;
	scroll_top	= (ie)? document.body.scrollTop : window.pageYOffset;
	crossobj.top	= scroll_top-250;
	crossobj.visibility	= (dom||ie)? "visible" : "show";
	bouncestart	= setInterval("bouncein();",objSpeed);
}

function followobj(){
	scroll_top	= (ie)? document.body.scrollTop : window.pageYOffset;
	if (parseInt(crossobj.top) < objEnd+scroll_top)
		crossobj.top	= parseInt(crossobj.top)+5;
	else{
		crossobj.top	= objEnd+scroll_top;
	}
}
var	bounceAction	= "DownStart",
	bounceHeight	= objBounceHeight,
	bounceBottom,
	bounceCount	= 0,
	isBounceUp,
	bncElastic	= 0.15,
	bncReHeight	= 0.60,
	bncReFrames	= 0.50;
function bouncein(){
	scroll_top	= (ie)? document.body.scrollTop : window.pageYOffset;
	switch(bounceAction) {
		case "DownStart": 
			isBounceUp	= bounceCount < objBounces;
			bounceCount++;
			bounceAction	= "Down";
			bounceBottom	= isBounceUp?Math.ceil(bounceHeight * bncElastic) + objEnd : objEnd;
		case "Down": 
			if (parseInt(crossobj.top) < bounceBottom + scroll_top)
				crossobj.top	= parseInt(crossobj.top)+objFrames;
			else{
				crossobj.top	= bounceBottom+scroll_top;
				if(isBounceUp)
					bounceAction	= "UpStart";
				else {
					clearInterval(bouncestart);
					followit		= setInterval("followobj()",1);
				}
			}

			break;
		case "UpStart": 
			objFrames	= Math.ceil(objFrames * bncReFrames);
			bounceAction	= "Up";
		case "Up": 
			if (parseInt(crossobj.top) > (objEnd - bounceHeight) + scroll_top - objFrames)
				crossobj.top	= parseInt(crossobj.top) - objFrames;
			else{
				crossobj.top	= (objEnd - bounceHeight) + scroll_top - objFrames;
				bounceHeight	= Math.ceil(bounceHeight * bncReHeight);
				bounceAction	= "DownStart";
			}

			break;
		default:
			clearInterval(bouncestart);
			break;
	}
}
function dismissbox(){
	if (window.bouncestart)
		clearInterval(bouncestart);
	if (window.followit)
		clearInterval(followit);
	crossobj.visibility	= "hidden";
}
function get_cookie(Name) {
	var	search		= Name + "=",
		returnvalue	= "";
	if (document.cookie.length > 0) {
		offset		= document.cookie.indexOf(search);
		if (offset != -1) {
			offset		+= search.length;
			end		= document.cookie.indexOf(";", offset);
			if (end == -1)
				end		= document.cookie.length;
			returnvalue	= unescape(document.cookie.substring(offset, end));
		}
	}
	return returnvalue;
}
