﻿function ShowSubscribePopup() {
	Resize("SubscribePopupContainer", 385, 300);
	MaintainState("up");
	Hide('PopupUpCtrl');
	Show('PopupDownCtrl', 'block');
	Obj("SubscribePopup").style.bottom = "0px";
}

function HideSubscribePopup() {	
	MaintainState("down");
	Hide('PopupDownCtrl');
	Show('PopupUpCtrl', 'block');
	Obj("SubscribePopup").style.bottom = "-212px";
	Resize("SubscribePopupContainer", 385, 55);
}

function CloseSubscribePopup() {
	MaintainState("closed");
	Hide("SubscribePopupContainer");
	Hide("SubscribePopup");
}

function SideIn(sID, i, limit) {
	Resize("SubscribePopupContainer", 385, 300);
	
	if (i < limit) {
		//i++;
		i = i + 2;
		Obj(sID).style.bottom = i + "px";
		var slideInRecursionCall = "SideIn(\"" + sID + "\", " + i + ", " + limit + ")";
		var slideInTimer = setTimeout(slideInRecursionCall, 1);
	}
	else {
		Obj(sID).style.bottom = i + "px";
		Hide('PopupUpCtrl');
		Show('PopupDownCtrl', 'block');
		MaintainState("up");
		clearTimeout(slideInTimer);
	}
	
}

function SideOut(sID, i, limit) {
	
	if (i > limit) {
		//i--;
		i = i - 2;
		Obj(sID).style.bottom = i + "px";
		var slideOutRecursionCall = "SideOut(\"" + sID + "\", " + i + ", " + limit + ")";
		var slideOutTimer = setTimeout(slideOutRecursionCall, 1);
	}
	else {
		Hide('PopupDownCtrl');
		Show('PopupUpCtrl', 'block');
		MaintainState('down');

		if (initTimeoutActive == "true") {
			clearTimeout(onloadSlideOutTimer);
		}
		
		clearTimeout(slideOutTimer);		
	}

	Resize("SubscribePopupContainer", 385, 88);
}

function MaintainState(sValue) {
	CreateCookie("SubscribePopup", sValue, 45);
}

function ClearAllTimeouts() {
	clearTimeout(onloadSlideOutTimer);
	clearTimeout(slideInTimer);
	clearTimeout(slideOutTimer);
}