// Popups need to be higher in XP SP2, due to Status Bar
var YOffset;
if (window.navigator.userAgent.indexOf("SV1") != -1) {
	YOffset=25;
}
else {
	YOffset=0;
}

// Mouseover

var nrm = new Array();
var omo = new Array();
var loaded = (!(navigator.userAgent.indexOf('Netscape6')+1));
var ocl = new Array();
var select = -1;
var name2 = "";
var temp = 0;

if (document.images)
{
		if (window.stuff) {
	        for (i=0;i<stuff.length;i++)
	        {
	                nrm[i] = new Image;
	                nrm[i].src = base + stuff[i] + ".gif"
	                omo[i] = new Image;
	                omo[i].src = base + stuff[i] + "2.gif";
					ocl[i] = new Image;
					ocl[i].src = base + stuff[i] + "2.gif";
					
	        }
		}
		if (window.stuff2) {
			for (i=stuff.length;i<stuff2.length;i++)
		       {
		               nrm[i] = new Image;
		               nrm[i].src = base2 + stuff2[i] + ".jpg"
		               omo[i] = new Image;
		               omo[i].src = base2 + stuff2[i] + "2.jpg";
					ocl[i] = new Image;
					ocl[i].src = base2 + stuff2[i] + "2.jpg";
					
		       }
		}
	
		if (window.stuff3) {
			for (i=stuff.length;i<stuff3.length;i++)
		       {
		               nrm[i] = new Image;
		               nrm[i].src = base3 + stuff3[i] + ".gif"
		               omo[i] = new Image;
		               omo[i].src = base3 + stuff3[i] + "2.gif";
					ocl[i] = new Image;
					ocl[i].src = base3 + stuff3[i] + "2.gif";
					
		       }
		}
}

function over(no)
{
        if (document.images && select != no && loaded)
        {
                document.images['img'+no].src = omo[no].src
        }
}

function out(no)
{
        if (document.images && select != no && loaded)
        {
                document.images['img'+no].src = nrm[no].src
        }
}

function clic(no)
{
	if (document.images && loaded)
	{
		document.images['img'+no].src = ocl[no].src
		temp = select;
		select = no;
		if (temp != -1) {out(temp)}
	}
}

// Intro

function lowlight(j) {

for (i=5;i<10;i++) {
out(i);
menu_show('info'+i,'','hide');
menu_show('info'+i+'a','','hide');
}
over(j);
menu_show('info'+j,'','show');
menu_show('info'+j+'a','','show');
}

// Layers

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function menu_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=menu_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function menue_findObj(n){
	var x,t; if((n.indexOf("?"))>0&&parent.frames.length){t=n.split("?");
	x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
	}else{x=document.getElementById(n)}return x;
}

function menu_show() { //v3.0A Modified by Al Sparber and Massimo Foti for NN6 Compatibility
  var i,p,v,obj,args=menu_show.arguments;if(document.getElementById){
   for (i=0; i<(args.length-2); i+=3){ obj=menue_findObj(args[i]);v=args[i+2];
   v=(v=='show')?'visible':(v='hide')?'hidden':v;
   if(obj)obj.style.visibility=v;}} else{
  for (i=0; i<(args.length-2); i+=3) if ((obj=menu_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }}
}

function adetail(adate){
	wHandle=window.open('agenda_detail.asp?start='+adate,'agenda_detail','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width=280,height=200');
}

// Popup
function popup(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'rc','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

// MP Preview
function mppreview(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'mppreview','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

// Flash Detection
function detection(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'detection','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

// Info Popup
function info_popup(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'infopopup','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

function info_popup_scroll(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'infopopup','toolbar=0,scrollbars=yes,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}


// Real-Age
function bmi(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'infopopup','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

function kfett(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'infopopup2','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

// Screenshot Popup 
function screenshots(imageSrc) { 
	fileName = 'popup/screenshots.asp?' + escape(imageSrc);
	myWindowHandle = window.open(fileName,'screenshot','directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no,width=700,height=459');
	myWindowHandle.window.moveTo((screen.width/2)-(700/2),(screen.height/2)-(459/2));
}

// Info Popup
function flash_popup(PURL,PWidth,PHeight){
	wHandle=window.open(PURL,'flashpopup','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

// TV Episode
function tv_episode(id,s,v,PWidth,PHeight){
	wHandle=window.open('tvepisodes/tvepisodes.asp?id='+id+'&s='+s+'&v='+v+'','tvepisodepopup','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

function tv_episode2(id,s,v,PWidth,PHeight){
	wHandle=window.open('tvepisodes/tvepisodes_static.asp?id='+id+'&s='+s+'&v='+v+'','tvepisodepopup','toolbar=0,scrollbars=no,location=0,status=0,menubars=0,resizable=0,width='+PWidth+',height='+PHeight);
	wHandle.window.moveTo((screen.width/2)-(PWidth/2),(screen.height/2)-(PHeight/2));
}

screen_id=1;
screens_total=8;

function screen(ID) {
	if (screen_id >= screens_total) {
		screen_id=1;
	}
	else {
		screen_id++;
	}
	ID=screen_id;
	for (x=1; x<=screens_total;x++) {
		menu_show('screen_'+x,'','hide');
		menu_show('screen_label_'+x,'','hide');
	}
	menu_show('screen_'+ID,'','show');
	menu_show('screen_label_'+ID,'','show');
}

function show_test(id) {
	for (x=7; x<=16;x++) {
		menu_show('test_'+x,'','hide');
	}
	menu_show('test_'+id,'','show');
}

function calc_bmi(form) {
	var height;
	var weight;
	
	height=form.height.value;
	weight=form.weight.value;
	
	if (IsNumeric(height)&&IsNumeric(weight)) {
		if (height>0&&weight>0) {
			form.bmi_result.value=Math.round(weight/((height/100)*(height/100))*10)/10;
		}
		else {
			form.bmi_result.value='?';
		}
	}
	else {
		form.bmi_result.value='?';
	}
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
 function disableDays(myForm) {
	if (myForm.reminderday1.disabled) {
		myForm.reminderday1.disabled=false;
		myForm.reminderday2.disabled=false;
		myForm.reminderday3.disabled=false;
		myForm.reminderday4.disabled=false;
		myForm.reminderday5.disabled=false;
		myForm.reminderday6.disabled=false;
		myForm.reminderday7.disabled=false;
		myForm.reminderpause.disabled=false;
		myForm.rpstart.disabled=false;
		myForm.rpend.disabled=false;
	}
	else {
		myForm.reminderday1.disabled=true;
		myForm.reminderday2.disabled=true;
		myForm.reminderday3.disabled=true;
		myForm.reminderday4.disabled=true;
		myForm.reminderday5.disabled=true;
		myForm.reminderday6.disabled=true;
		myForm.reminderday7.disabled=true;
		myForm.reminderpause.disabled=true;
		myForm.rpstart.disabled=true;
		myForm.rpend.disabled=true;
	}
 }
 
 function showSettingsHint() {
	document.getElementById('settingshint').style.display="block";
 }

 function displayStandDuration() {
    sitfield=document.getElementById('sitduration');
    standfield=document.getElementById('standduration');
	if (sitfield.options[sitfield.selectedIndex].value=='0') {
		standfield.style.display="none";
	} else {
		standfield.style.display="inline";
	}
 }
		
