// ## TIMER STUFF FOR NEW WINDOW ##
// ## Must remember to re:write this in other non-ie browsers!! ##

var the_count = 1;
var the_timeinterval = 0;
var the_timeout;
var next_window;
var isIE = "false";
var timerindex = 1;

bName = navigator.appName; 
bVer = parseInt(navigator.appVersion);
br = "other";
if (bName=="Microsoft Internet Explorer" && bVer >= 4){	br = "ie4x";isIE="true"; } // END IF
if (bName == "Netscape" && bVer >= 5){ br = "ns5x"; }
// alert("[" + bName + "][" + bVer + "][" + br + "]");


// CHECK TO SEE IF BROWSER IS IE OR NOT !!


// ## START THE TIMER STUFF OFF ##
function StartTimer(){
					// ## RESET BUTTONS ##
					if(isIE=="true"){
									window.document.all("dobutton").disabled = true;
									window.document.all("undobutton").disabled = "";
									the_timeinterval	=	window.document.timer_form.timeinterval.value;
									} // END IF
					if(br=="ns5x"){
									// alert(window.document["timer_form"].elements["dobutton"].disabled);
									window.document["timer_form"].elements["dobutton"].disabled = true;
									window.document["timer_form"].elements["undobutton"].disabled = "";
									the_timeinterval = window.document["timer_form"].elements["timeinterval"].value;
									} // END IF
					
					if(br!="ns5x"&&isIE=="false"){
												// ## TESTING !! ##
												the_timeinterval = 5;
												timerindex	=	window.document["timer_form"].elements["timeinterval"].selectedIndex;
												if(timerindex==0){the_timeinterval=1;} // END IF
												if(timerindex==1){the_timeinterval=2;} // END IF
												if(timerindex==2){the_timeinterval=5;} // END IF
												if(timerindex==3){the_timeinterval=10;} // END IF
												if(timerindex==4){the_timeinterval=15;} // END IF
												if(timerindex==5){the_timeinterval=20;} // END IF
												if(timerindex==6){the_timeinterval=25;} // END IF
												if(timerindex==7){the_timeinterval=30;} // END IF
												if(timerindex==8){the_timeinterval=60;} // END IF
												// alert("Other browser detected!");
												// alert("[" + window.document["timer_form"].elements["timeinterval"].selectedIndex + "]");												
												} // END IF					

					window.status = "[--> TIMER IS RUNNING : NEW WINDOW EVERY " + the_timeinterval + " MINUTES ! <--]";
					doTimer();
					} // END Function






// ## DO A TIMER EVENT ##
function doTimer(){
					// ## for cookie handling ##
					var cookiestring;					 
					 if(isIE=="true"){	window.document.timer_form.the_text.value = the_count;
										the_timeinterval	=	window.document.timer_form.timeinterval.value;
									 } // END IF
					else{
						if(br=="ns5x"){
										window.document["timer_form"].elements["the_text"].value = the_count;
										the_timeinterval = window.document["timer_form"].elements["timeinterval"].value;
										} // END IF
						if(br!="ns5x"&&br!="ie4x"){
													// NOT ENTIRELY SURE WHY I COULDN'T QUERY THE VALUE BUT HEH!!
													the_timeinterval = 5;
													timerindex	=	window.document["timer_form"].elements["timeinterval"].selectedIndex;
													if(timerindex==0){the_timeinterval=1;} // END IF
													if(timerindex==1){the_timeinterval=2;} // END IF
													if(timerindex==2){the_timeinterval=5;} // END IF
													if(timerindex==3){the_timeinterval=10;} // END IF
													if(timerindex==4){the_timeinterval=15;} // END IF
													if(timerindex==5){the_timeinterval=20;} // END IF
													if(timerindex==6){the_timeinterval=25;} // END IF
													if(timerindex==7){the_timeinterval=30;} // END IF
													if(timerindex==8){the_timeinterval=60;} // END IF
													// alert("[" + the_timeinterval + "]");
													}
						
						} // END ELSE
					  
					  
					  
					  
						// alert(the_timeinterval);
					  if (the_count>0){	
									// ## KICK OFF NEW WINDOW ##
									// DEPENDANT ON TYPE SELECTED ON PAGE !!
									if (isIE=="true"){
														if (window.document.all("WindowType").selectedIndex==0){next_window	=	"ShowLearningWindow('question.asp','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
														else {next_window = "openIT('nextwindow" + the_count + "');" } // END ELSE
													 } // END IF
									else{
										if(br=="ns5x"){next_window = "ShowLearningWindow('question.asp','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
										else{next_window = "ShowLearningWindow('question_ob.asp','nextwindow" + the_count + "','width=796,height=322,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
										} // END ELSE
									

var expDays = 1;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


									if(document.cookie){
														var CurrentOpenWindowCount = GetCookie('OpenWindowCount');
														// alert("[" + CurrentOpenWindowCount + "]");
														// if(parseInt(CurrentOpenWindowCount)<=0){CurrentOpenWindowCount=0;} // end if
														
														
														
														
														var CheckWindowCount = 0;
														if(isIE=="true"){CheckWindowCount = 5;} // end if
														else{CheckWindowCount = 5;} // end else
														
														
														if(parseInt(CurrentOpenWindowCount)>=CheckWindowCount){
																								clearTimeout(the_timeout);
																								UndoTimer();
																								alert("FRENCHASSISTANT.COM (tm) - I've walked off and left my timer on message.\n\nYou have too many FRENCHASSISTANT.COM windows open.\nSo rather than litter your destop with thousands of them we have shutdown the autotimer!\n\nThe open window limit is 5 if you do not have 5 windows open...\nThen there is a problem and you can reset the count by going to the FAQ page.\nIf problems persist then email us and we'll help out.");
																								} // end if
														else{
																OpenWindowCounter()
																// alert("local script: CurrentCount:" + CurrentOpenWindowCount);
																eval(next_window);} // end else
														} // end if
									else{eval(next_window);} // end else
									
									} // END IF
					  the_count += 1;
					  the_timeinterval	=	(the_timeinterval * 60);
					  the_timeout = setTimeout("doTimer();", (the_timeinterval*1000));
}	// END Function

// ## CANCEL THE TIMER ##
function UndoTimer(){
					clearTimeout(the_timeout);
					  window.document.timer_form.the_text.value = 0;
					// ## RESET BUTTONS ##
					if(isIE=="true"){
									window.document.all("dobutton").disabled = "";
									window.document.all("undobutton").disabled = true;
									} // END IF
					if(br=="ns5x"){
									window.document["timer_form"].elements["dobutton"].disabled = "";
									window.document["timer_form"].elements["undobutton"].disabled = true;
									} // END IF

					window.status = "";
}	// END Function


// ## DO ONE !! ##
function ShowSinglePopup(){
	// alert('Do one!');
	the_count = 1000;
	if(isIE=="true"){
					if (window.document.all("WindowType").selectedIndex==0){next_window	=	"ShowLearningWindow('question.asp','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
					else {next_window = "openIT('nextwindow" + the_count + "');" } // END ELSE
					} // END IF
	else{
		if(br=="ns5x"){next_window = "ShowLearningWindow('question.asp','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
		else{next_window = "ShowLearningWindow('question_ob.asp','nextwindow" + the_count + "','width=796,height=322,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END ELSE
		} // END ELSE
	

	if(document.cookie){
						var CurrentOpenWindowCount = GetCookie('OpenWindowCount')
						// alert("CurrentCount:" + CurrentOpenWindowCount);
						if(parseInt(CurrentOpenWindowCount)>=5){
																alert("FRENCHASSISTANT.COM (tm) - Too many open windows!.\n\nYou have too many FRENCHASSISTANT.COM windows open.\nSo rather than litter your destop with thousands of them we try and keep track of them.!\n\nThe open window limit is 5 if you do not have 5 windows open...\nThen there is a problem and you can reset the count by going to the FAQ page.\nIf problems persist then email us and we'll help out.");
																} // end if
						else{eval(next_window);} // end else
						} // END IF
	else{eval(next_window);} // end else

} // END Function


function ShowDemoPopup(){
	// alert('Do one window from HTML file!');
	var soundfiletype = "";
	if(isIE=="true"||br=="ns5x"){
					if(window.document["demoform"].elements["soundformat"][0].checked==true){soundfiletype=1;}
					if(window.document["demoform"].elements["soundformat"][1].checked==true){soundfiletype=2;}
					if(window.document["demoform"].elements["soundformat"][2].checked==true){soundfiletype=3;}
					} // END IF
	else{soundfiletype=1;}
	the_count = "DemoWindow";
	if(isIE=="true"||br=="ns5x"){next_window	=	"ShowLearningWindow('question_demo.asp?soundfiletype=" + soundfiletype + "','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
	else{next_window = "alert('Your browser is not supported OR has not been detected. Please e-mail us if you think it should be!  [ general@frenchassistant.com ]');"} // end else
	//next_window	=	"ShowLearningWindow('question_demo.asp?soundfiletype=" + soundfiletype + "','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
	//else{next_window = "ShowLearningWindow('question_demo_ob.htm','nextwindow" + the_count + "','width=796,height=322,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END ELSE
	eval(next_window);
} // END Function

function ShowDemoPopup2(){
	// alert('Do one window from HTML file!');
	var soundfiletype = "";
	if(isIE=="true"||br=="ns5x"){
					if(window.document["demoform2"].elements["soundformat2"][0].checked==true){soundfiletype=1;}
					if(window.document["demoform2"].elements["soundformat2"][1].checked==true){soundfiletype=2;}
					if(window.document["demoform2"].elements["soundformat2"][2].checked==true){soundfiletype=3;}
					} // END IF
	else{soundfiletype=1;}
	the_count = "DemoWindow";
	if(isIE=="true"||br=="ns5x"){next_window	=	"ShowLearningWindow('question_demo.asp?soundfiletype=" + soundfiletype + "','nextwindow" + the_count + "','width=796,height=316,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END IF
	else{next_window = "ShowLearningWindow('question_demo_ob.htm','nextwindow" + the_count + "','width=796,height=322,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";} // END ELSE
	eval(next_window);
} // END Function

function NavigateToLessons(){
	document.location.href='lessons.asp';
	} // end function



function ShowCustomWindow(theURL,theWidth,theHeight){
	// Function to show any window of specified size!
	var CustomWindowCode = ""
	// CustomWindowCode	=	ShowLearningWindow('" + theURL + ','nextwindow" + the_count + "','width=" + theWidth + ",height=" + theHeight + ",resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";
	// eval(CustomWindowCode);
} // END IF


function openIT(newwindowname) {
	theurl="question.asp"
	wname = newwindowname;
	W=800;
	H=322;
	windowCERRARa 		= "images/close_a.gif"
	windowCERRARd 		= "images/close_d.gif"
	windowCERRARo 		= "images/close_o.gif"
	windowTIT 	    	= "<font color=#FFFFFF><b>W W W . F R E  N C H A S S I S T A N T . C O M : Copyright (c) 2003 FRENCHASSISTANT.COM. All rights reserved.</b></font>"
	windowBORDERCOLOR   	= "#000000"
	windowBORDERCOLORsel	= "#000000"
	windowTITBGCOLOR    	= "#A0BFD4"
	windowTITBGCOLORsel 	= "#A0BFD4"

	openchromeless(theurl, wname, W, H, windowCERRARa, windowCERRARd, windowCERRARo, windowTIT, windowBORDERCOLOR, windowBORDERCOLORsel, windowTITBGCOLOR, windowTITBGCOLORsel)
}



// ## OPEN UP A NEW WINDOW OR SOMETHING ##
function ShowLearningWindow(theURL,winName,features) { //v1.0a!
							window.open(theURL,winName,features);
						     } // end function





function DisplayHelp(HelpMenuItemID,HelpMenuIndex){
		tempURL = "/help/help.asp?MenuItemIndex=" + HelpMenuItemID + "&MenuIndex=" + HelpMenuIndex;
		// alert(tempURL);		
		helpwindow = "ShowLearningWindow(tempURL,'HelpWindow" + HelpMenuItemID + "','width=798,height=432,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";
		eval(helpwindow);
} // end function


function DisplaySoundHelp(){
		tempURL = "/help/Soundhelp.asp";
		// alert(tempURL);		
		helpwindow = "ShowLearningWindow(tempURL,'SoundHelpWindow','width=498,height=282,resizeable=0,scrollbars=0,toolbar=0,status=0,menubar=0,channelmode=0,directories=0,fullscreen=0,location=0')";
		eval(helpwindow);
} // end function


// ## STUFF FOR MENU'S ##
var oLastBtn=0;
	function RaiseButton(){
		window.event.cancelBubble=true;
		oBtn = window.event.srcElement;
		var bChosen = false;
		if(oLastBtn && oLastBtn != oBtn){
			HideButton();
		}
		if(oBtn.buttonType){
			oBtn.className = oBtn.buttonType + "Up";
			oLastBtn=oBtn;
			}
		else {
		oLastBtn = 0;
		}
	}
	function DepressButton(){
		window.event.cancelBubble=true;
		oBtn = window.event.srcElement;
		if(oBtn.buttonType){
			oBtn.className = oBtn.buttonType + "Down"; 
		}
	}
	
	function HideButton(){
		if ((oLastBtn.buttonType == "LeftNavChosen") || (oLastBtn.buttonType == "LeftNavSubChosen")) {
			oLastBtn.className = oLastBtn.buttonType;
		}
		else {
		oLastBtn.className = oLastBtn.buttonType + "Off";
		}
	}


	function textRoll(strTextColor)
	  {
		window.event.srcElement.style.color = strTextColor;
		window.event.cancelBubble = true;
		}
		
		
	var ToolBar_Supported = ToolBar_Supported;
		if (ToolBar_Supported != null && ToolBar_Supported == true)
	{
	TBDownLevelDiv.style.display ='none';
	drawToolbar();
	var fBrowserOK = true;
	}
	
	function bgRoll(strTextColor)
	{
		window.event.srcElement.style.backgroundColor = strTextColor;
		window.event.cancelBubble = true;
	}
	function fntRoll(strTextColor)
	{
  		window.event.srcElement.style.color = strTextColor;
		window.event.cancelBubble = true;
	}

	// (sort of) disable image theft!! (sort of!) //
	function disableEvent()
	{
		return false;
	}

