$(function(){


	// Initialization of Animated Collapse Objects
	for(i=0;i<textArray.length;i++){
	eval("ac.addDiv('" + textArray[i] + "','fade=1')");
	}
	ac.init();



});


	TopUp.host = "http://www.theklubhouse.com/";
	TopUp.images_path = "topup/images/top_up/";



// Define All Object IDs for Animated Collapse
textArray = new Array('text0','text1','text2','text3','text4','text5','text6');

var Xconstraint=1000;  // Width of available movement
var Ymax=1;            // MAX # OF PIXEL STEPS IN THE "X" DIRECTION
var Xmax=1;            // MAX # OF PIXEL STEPS IN THE "Y" DIRECTION
var Tmax=3000;         // MAX # OF MILLISECONDS BETWEEN PARAMETER CHANGES
var imgMinW=102;       // Image Minimized Width
var imgMaxW=204;       // Image Maximized Width
var tailMarginMin=37;  // Tail Minimized Margin
var tailMarginMax=88;  // Tail Maximized Margin
var topMax = 20;       // MAX top location for images
var botMax = 200;	   // MAX bottom location for images
var indefamt = 4       // pixel change step of inflate/deflate
var indefspeed = 10    // interval time in ms for inflate/deflate change
var imginflate = ""    // just a definition, no adjust
var imgdeflate = ""    // just a definition, no adjust
var curImg = "-1";     // Current Selected Image

//FLOATING IMAGE LIST

var floatimages=new Array();
floatimages[0]='balloon_partypackages.png';
floatimages[1]='balloon_openplay.png';
floatimages[2]='balloon_classes.png';
floatimages[3]='balloon_peekinside.png';
floatimages[4]='balloon_contactus.png';
floatimages[5]='balloon_location.png';

var floattails = new Array();
floattails[0] = "pink";
floattails[1] = "blue";
floattails[2] = "yellow";
floattails[3] = "green";
floattails[4] = "orange";
floattails[5] = "red";

//*********DO NOT EDIT BELOW***********


var IE = navigator.appName.indexOf("Microsoft")>-1 ? true: false;
var wind_w, wind_h, t='', IDs=new Array();

for(i=0; i<floatimages.length; i++){
	tailcode ="<div id='tail" + i + "' class='tail' style='margin-left:" + tailMarginMin + "px;'><embed type='application/x-shockwave-flash' " +
     "pluginspage='http:\/\/www.macromedia.com\/go\/getflashplayer' " +
     "width='30' height='200' " +
     "name='baloontail"+i+"' src='baloontail_"+floattails[i]+".swf' " +
     "wmode='transparent' bgcolor='#FFFFFF' quality='high' " +
     "swLiveConnect='true' allowScriptAccess='samedomain'><\/embed><\/div>";

	t+='<div id="pic'+i+'" style="position:absolute; visibility:hidden;width:10px; height:10px">';
	t+='<img id="float'+i+'" class="floatimg" src="'+floatimages[i]+'" name="p'+i+'" border="0" style="width:102px;" onmouseover="doInflate('+i+');" onmouseout="doDeflate('+i+');" onclick="showInfo('+i+');">';
	t+=tailcode;
	t+='</div>';
}
document.write(t);

function moveimage(num){
if(getidleft(num)+IDs[num].W+IDs[num].Xstep >= wind_w+getscrollx())IDs[num].Xdir=false;
if(getidleft(num)-IDs[num].Xstep<=getscrollx())IDs[num].Xdir=true;
//if(getidtop(num)+IDs[num].H+IDs[num].Ystep >= wind_h+getscrolly())IDs[num].Ydir=false;
if(getidtop(num)+IDs[num].H+IDs[num].Ystep >= botMax+getscrolly())IDs[num].Ydir=false;
if(getidtop(num)-IDs[num].Ystep<=getscrolly())IDs[num].Ydir=true;
moveidby(num, (IDs[num].Xdir)? IDs[num].Xstep :  -IDs[num].Xstep , (IDs[num].Ydir)?  IDs[num].Ystep:  -IDs[num].Ystep);
}

function getnewprops(num){
IDs[num].Ydir=Math.floor(Math.random()*2)>0;
IDs[num].Xdir=Math.floor(Math.random()*2)>0;
IDs[num].Ystep=Math.ceil(Math.random()*Ymax);
IDs[num].Xstep=Math.ceil(Math.random()*Xmax)
setTimeout('getnewprops('+num+')', Math.floor(Math.random()*Tmax));
}

function getscrollx(){
if(IE){return document.body.scrollLeft}else{return window.pageXOffset}
}

function getscrolly(){
if(IE){return document.body.scrollTop}else{return window.pageYOffset}
}

function getid(name){
return document.getElementById(name);
}

function moveidto(num,x,y){
IDs[num].style.left=x+'px';
IDs[num].style.top=y+'px';
}

function getidleft(num){
return parseInt(IDs[num].style.left);
}

function getidtop(num){
return parseInt(IDs[num].style.top);
}

function moveidby(num,dx,dy){
IDs[num].style.left=(getidleft(num)+dx)+'px';
IDs[num].style.top=(getidtop(num)+dy)+'px';
}

function getwindowwidth(){
if(IE){return document.body.clientWidth}else{return window.innerWidth}
}

function getwindowheight(){
if(IE){return document.body.clientHeight}else{return window.innerHeight}
}

function init(){
wind_w=getwindowwidth();
wind_h=getwindowheight();


animateWidth = (floatimages.length) * (imgMaxW * .6);
animateLeft = ((wind_w/2) - (animateWidth/2)) - (imgMaxW/2);

	for(i=0; i<floatimages.length; i++){
	IDs[i]=getid('pic'+i);
	IDs[i].W=document.images["p"+i].width;
	IDs[i].H=document.images["p"+i].height;
	getnewprops(i);
	//moveidto(i , Math.floor(Math.random()*(wind_w-IDs[i].W)), Math.floor(Math.random()*(wind_h-IDs[i].H)));
	//moveidto(i , Math.floor(Math.random()*(wind_w-IDs[i].W)), Math.floor(Math.random()*(topMax-IDs[i].H)));
	
	moveidto(i , animateLeft , topMax );
	animateLeft = animateLeft + (imgMaxW * .8);
	
	IDs[i].style.visibility = "visible";
	startfly=setInterval('moveimage('+i+')',Math.floor(Math.random()*100)+100);
	}
}

function showInfo(val){
for(t=0;t<textArray.length;t++){
document.getElementById(textArray[t]).style.display = 'none';
}
ac.toggle(textArray[val]);
}

function doInflate(val){
curImg = val;
clearInterval(imgdeflate);
IDs[val].style.zIndex = floatimages.length;
imginflate = setInterval ( "inflate(curImg)", indefspeed );
}

function inflate(val){
	if(parseInt(document.getElementById("float"+val).style.width) <= imgMaxW){
	document.getElementById("float"+val).style.width = (parseInt(document.getElementById("float"+val).style.width) + indefamt) + "px" ;
	IDs[val].style.left=(getidleft(val)-2)+'px';
	document.getElementById("tail"+val).style.marginLeft = (parseInt(document.getElementById("tail"+val).style.marginLeft) + (indefamt/2)) + "px";
	}else{
	document.getElementById("float"+val).style.width = imgMaxW + "px";
	clearInterval(imginflate);
	}
}

function doDeflate(val){
if(val != ""){curImg = val}
clearInterval(imginflate);
IDs[val].style.zIndex = 0;
imgdeflate = setInterval ( "deflate(curImg)", indefspeed );
}

function deflate(val){
	if(parseInt(document.getElementById("float"+val).style.width) >= imgMinW){
	document.getElementById("float"+val).style.width = ((parseInt(document.getElementById("float"+val).style.width)) - indefamt) + "px" ;
	IDs[val].style.left=(getidleft(val)+2)+'px';
	document.getElementById("tail"+val).style.marginLeft = (parseInt(document.getElementById("tail"+val).style.marginLeft) - (indefamt/2)) + "px";
	}else{
	document.getElementById("float"+val).style.width = imgMinW + "px";
	document.getElementById("tail"+val).style.marginLeft = tailMarginMin + "px";
	clearInterval(imgdeflate);
	}
}

function resetAll(){
self.location.reload();
}

window.onload=init;
