var catfishHeight; //Checks the total height of the catfish add for sliding, this is calculated in the function "catFishInit"

//Used to detect IE
var isIE/*@cc_on = {
  // quirksmode : (document.compatMode=="BackCompat"),
  version : parseFloat(navigator.appVersion.match(/MSIE (.+?);/)[1])
}@*/;

//Wraps the body content in a fake div, this is needed for IE since it doesn't support the fixed position properly
function wrapFish() {
	//Loads the extra style sheet needed for IE
	var cssNode = document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = 'catfish_ie.css';
	cssNode.media = 'screen';
	cssNode.title = 'dynamicLoadedSheet';
	document.getElementsByTagName("head")[0].appendChild(cssNode);

	var catfish = document.getElementById('catfish');
	var subelements = [];
	for (var i = 0; i < document.body.childNodes.length; i++) {
 		subelements[i] = document.body.childNodes[i];
	}
	//This div adds padding so the catfish doesn't cover content at the bottom
	subelements[i] = document.createElement('div');
	subelements[i].id = "catfishIESpace";

	var zip = document.createElement('div');
	zip.id = "zip";

	for (var i = 0; i < subelements.length; i++) {
		zip.appendChild(subelements[i]); 
	}
	if(isIE) scroll(0,0);
	document.body.appendChild(zip);
	document.body.appendChild(catfish);
}


if(isIE) {
	var catfishEndSlide = 1; //IE seems to prefer being set to bottom:-1px instead of  bottom:0px;
} else {
	var catfishEndSlide = 0;
}

function catfishSlide(height,direction) {
	var catfish = document.getElementById("catfish");
	if(height == (catfishHeight * -1) && direction == "down") {
		catfish.style.display = "none";
		document.getElementsByTagName("html")[0].style.padding = "0";
		document.getElementsByTagName("body")[0].style.padding = "0";
		if(isIE) {
			var extraSpace = document.getElementById("catfishIESpace");
			extraSpace .parentNode.removeChild(extraSpace);
		}
	} else {
		catfish.style.bottom = height+"px";
	}
}

function catfishClose() {
	for(i=catfishEndSlide;i<= catfishHeight;i++) {
		setTimeout("catfishSlide('-"+i+"','down')", (i)*(6));
	}
}

function catfishOpen() {
	/*for(i=catfishHeight;i>=catfishEndSlide;i--) {
		setTimeout("catfishSlide('-"+i+"','up')", (i-catfishHeight)*(-6));
	}*/
	document.getElementById("catfish").style.bottom = catfishEndSlide+"px";
}

function catFishInit() {
	catfishHeight = document.getElementById('catfish').offsetHeight + document.getElementById('catfishTop').offsetHeight;
	if(isIE) wrapFish();
	catfishOpen();
}
catFishInit();
//setTimeout("catFishInit();",100000);


