function animFreeSignup(){var cookie=getcookie("FreeSignupAnim");if(cookie==""){new Effect.Pulsate("freeSignUp");setcookie("FreeSignupAnim","done",7)}}
function animFreeSignupClearCookie(){setcookie("FreeSignupAnim","",7)}
function showBigScreenshot(){window.location="#";document.getElementById("bigScreenshotDiv").innerHTML="<img style='position: absolute; left: -487px;' onClick='closeBigDiv()' src='/screenshot_medium.jpg'>";document.getElementById("bigScreenshotDiv").style.visibility="";document.getElementById("bigScreenshotDiv").style.display="";}
function closeBigDiv(){document.getElementById("bigScreenshotDiv").style.visibility="hidden";document.getElementById("bigScreenshotDiv").style.display="none";}
function vid1(){hideHelpPopup();showOverlay1("/video/ManAppt/ManAppt.html");}
function vid2(){hideHelpPopup();showOverlay1("/video/ClientAppt/ClientAppt.html");}
function showOverlay1(src){window.location="#";var div=document.getElementById("overlayDiv1");var frame=document.getElementById("overlayFrame1");frame.src=src;div.style.display="";}
function closeOverlay1(){var div=document.getElementById("overlayDiv1");var frame=document.getElementById("overlayFrame1");div.style.visibility="hidden";frame.src="";}
function getcookie(cookiename){var cookiestring=""+document.cookie;var index1=cookiestring.indexOf(cookiename);if(index1==-1||cookiename=="")return"";var index2=cookiestring.indexOf(';',index1);if(index2==-1)index2=cookiestring.length;return unescape(cookiestring.substring(index1+cookiename.length+1,index2));}
function getexpirydate(nodays){var UTCstring;Today=new Date();nomilli=Date.parse(Today);Today.setTime(nomilli+nodays*24*60*60*1000);UTCstring=Today.toUTCString();return UTCstring;}
function setcookie(name,value,duration){cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);document.cookie=cookiestring;if(!getcookie(name)){return false;}
else{return true;}}
function helpPopup(title,body){document.getElementById("helpBoxTitle").innerHTML=unescape(title);document.getElementById("helpBoxBody").innerHTML=unescape(body);var div=document.getElementById("helpBox");div.style.visibility="";if(UIAnim)new Effect.Appear(div);else div.style.display="";}
function hideHelpPopup(){var div=document.getElementById('helpBox');if(div==null)return false;if(UIAnim)new Effect.DropOut(div);else div.style.display="none";}

var infoState = 1;
var featureState = 1;
var featurePeriod=20000;
var infoPeriod=featurePeriod/2;
var timerInfo;
var timerCountdown;
var countDownDisp=featurePeriod;

function navNext(n) {
window.clearTimeout (timerCountdown);
new Effect.Fade ("countdown");
toggleFeature()
}

function displaySecondTimeout() {
var dispNo;
if (countDownDisp < 0) dispNo = 0; else dispNo = countDownDisp;
document.getElementById ("counter").innerHTML = String(dispNo/1000);
countDownDisp -= 1000;

window.clearTimeout (timerCountdown);

if (countDownDisp <= -1000) {
new Effect.Fade ("countdown", {afterFinish: function (obj) { toggleFeature() }});
} else {
timerCountdown=setTimeout ("displaySecondTimeout()", 1000);
	}
}

function startTimer () {
document.getElementById ("counter").innerHTML = String(featurePeriod/1000);
new Effect.Appear ("countdown");
timerInfo=setTimeout("toggleInfo();",infoPeriod);
timerCountdown=setTimeout("displaySecondTimeout();",1000); 
}

function clearAllTimers() {
window.clearTimeout(timerInfo);
window.clearTimeout(timerCountdown);
}


function toggleInfo() {
	if (infoState==1) {
		infoState=2;
		window.clearTimeout (timerInfo);
		new Effect.Fade ("dotPointsDiv1");
		new Effect.SlideDown ("dotPointsDiv2");
		timerInfo=setTimeout("toggleInfo()",infoPeriod);  

	} else {
		infoState=1;
		window.clearTimeout (timerInfo);
		new Effect.Fade ("dotPointsDiv2");
		new Effect.SlideDown ("dotPointsDiv1");
		timerInfo=setTimeout("toggleInfo();",infoPeriod);  
	}
}
function timerClick() {
var o = document.getElementById ("counter");
if (o) {
o.id="counterPause";
clearAllTimers()
} else {
var o = document.getElementById ("counterPause");
o.id="counter";
timerCountdown=setTimeout("displaySecondTimeout();",1000);
}
 


}

function toggleFeature() {
	
	clearAllTimers();
	countDownDisp = featurePeriod;
	if (featureState==1) {
		var d = sendRequest ("/dev/stats.nsf/HomeStatsL2?OpenAgent");
		new Effect.Fade ("flipper", {afterFinish: function(obj) {
		document.getElementById ("spFeature1").innerHTML = d.responseText;
		new Effect.Appear ("spFeature1")
		}});
		featureState=2;

	} else if (featureState==2) {
		new Effect.Fade('spFeature1', {afterFinish: function (obj) { 
		document.getElementById ("spFeature1").innerHTML = document.getElementById ("statsFeature").innerHTML;
		new Effect.Appear('spFeature1') }})
		featureState=3;
		
	} else if (featureState==3) {
		var d = sendRequest ("/dev/stats.nsf/HomeStatsL2?OpenAgent");
		new Effect.Fade('spFeature1', {afterFinish: function (obj) { 
		document.getElementById ("spFeature1").innerHTML = d.responseText;
		new Effect.Appear('spFeature1') }})
		featureState=4;
	
	} else {
 		new Effect.Fade('spFeature1', {afterFinish: function (obj) { new
		Effect.Appear('flipper') }})
		toggleInfo();
		featureState=1;
	}
		clearAllTimers();
		timerCountdown=setTimeout("startTimer();",2000);

}
