
var intTop;
var intLeft=160;

if (isNS) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove=mtrack;

function mtrack(e) {
   var Text= 'Coordinates: ';
   if (isNS) {
       mouseX=GetmouseX(e);
       //mouseX=e.pageX;
       mouseY=GetmouseY(e);
       //mouseY=e.pageY;
       }
   else 
   { mouseX=event.x+document.documentElement.scrollLeft;
     mouseY=event.y+document.documentElement.scrollTop;
     }

 }

 function SendPreferences(strSection, strDir) {

     document.location = 'Default.asp?Section=' + strSection + '&dir=' + strDir + '&size=' + document.getElementById(strSection).style.height
     //"userstats", "up"
 }
 
function addride(rideid) {
var filestring;
filestring = "addride.asp?ride_id=" + rideid;
//alert(filestring);
var newwinar = window.open(filestring,'addride',config='width=460,height=420,top=10,left=10,scrollbars=yes,resizable');
newwinar.focus();
}

function gothere(strURL) {
	document.location = strURL;
}

function addroute(routeid) {
var filestring;
filestring = "addroute.asp?route_id=" + routeid;
var newwin = window.open(filestring, 'addroute', config='width=400,height=430,top=10,left=10,scrollbars=yes,resizable');
newwin.focus();
}

function addbike(bikeid) {
var filestring;
filestring = "addbike.asp?bike_id=" + bikeid;
var newwin = window.open(filestring, 'addbike', config='width=400,height=480,top=10,left=10,scrollbars=yes,resizable');
newwin.focus();
}

function runSlideShow(){

if (document.all){
document.images.slide.style.filter="blendTrans(duration=2)";
document.images.slide.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.slide.filters.blendTrans.Apply();}
document.images.slide.src = preLoad[jss].src;
if (document.all) document.images.slide.filters.blendTrans.Play();
jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout('runSlideShow()', 5000);
}

//tss = setTimeout('runSlideShow()', 5000);


function showmessage (strText) {
  
  hidemessage();
var intScroll = document.body.scrollTop;
var clwidth
intTop = mouseY+document.body.scrollTop;
intLeft = mouseX+15+document.body.scrollLeft;

if (isNS) {
		if (document.getElementById) {
			clwidth=window.innerWidth;}
		else {clwidth=window.innerWidth;}
	}
	else {clwidth=document.body.clientWidth;}
		
if (intTop<intScroll) 
  {message.style.top = intTop; }
if (intLeft > clwidth-280) 
  { intLeft = intLeft - 280;}

if (isNS)
 if (!(document.getElementById)){
   eval("document.innermessage.innerHTML=strText;");
   eval("document.message.visibility=VISIBLE");
 	 eval("document.message.left=intLeft");
	 eval("document.message.top=intTop"); }
  else {
  //alert(document.getElementById('message').style.top);
    eval("document.getElementById('innermessage').innerHTML=strText;");
    eval("document.getElementById('message').style.visibility=VISIBLE");
    eval("document.getElementById('message').style.left=intLeft+'px';");
    eval("document.getElementById('message').style.top=intTop+'px';"); }
else
{ eval("document.all.message.style.visibility=VISIBLE;");
  eval("document.all.innermessage.innerHTML=strText;");
  document.all.message.style.left=intLeft;
	document.all.message.style.top=intTop;}
}

function hidemessage() {
if (isNS)
 if (!(document.getElementById)){
  eval("document.message.visibility=HIDDEN");
  }
  else {
    eval("document.getElementById('message').style.visibility=HIDDEN");
 }
else
{ 
  eval("document.all.message.style.visibility=HIDDEN;");
}
}

function showdesc (strText) {
  noDesc();
  hidemessage();
var intScroll = document.body.scrollTop;
var clwidth
intTop = mouseY+document.body.scrollTop;
intLeft = mouseX+15+document.body.scrollLeft;

if (isNS) {
		if (document.getElementById) {
			clwidth=window.innerWidth;}
		else {clwidth=window.innerWidth;}
	}
	else {clwidth=document.body.clientWidth;}
		
if (intTop<intScroll) 
  {info.style.top = intTop; }
if (intLeft > clwidth-280) 
  { intLeft = intLeft - 280;}

if (isNS)
 if (!(document.getElementById)){
   eval("document.info.innerHTML=strText;");
   eval("document.info.visibility=VISIBLE");
 	 eval("document.info.left=intLeft");
	 eval("document.info.top=intTop"); }
  else {
  //alert(document.getElementById('info').style.top);
    eval("document.getElementById('info').innerHTML=strText;");
    eval("document.getElementById('info').style.visibility=VISIBLE");
    eval("document.getElementById('info').style.left=intLeft+'px';");
    eval("document.getElementById('info').style.top=intTop+'px';"); }
else
{ eval("document.all.info.style.visibility=VISIBLE;");
  eval("document.all.info.innerHTML=strText;");
  document.all.info.style.left=intLeft;
	document.all.info.style.top=intTop;}
}

function hidedesc() {
if (isNS)
 if (!(document.getElementById)){
  eval("document.info.visibility=HIDDEN");
  }
  else {
    eval("document.getElementById('info').style.visibility=HIDDEN");
 }
else
{ 
  eval("document.all.info.style.visibility=HIDDEN;");
}
}

function doDesc() {

	var newleft = mouseX-170;
	var newtop  = mouseY;
  hidedesc();
  noDesc()
	clearTimeout(MenuTimer);
	if (isNS) {
		if (document.getElementById) {
			clheight=window.innerHeight;
			clwidth=window.innerWidth;
		}
		else {
			clheight=window.innerHeight;
			clwidth=window.innerWidth;
		}
	}
	else {
		clheight=document.body.clientHeight;
		clwidth=document.body.clientWidth;
	}

	
	MenuTimer = setTimeout('noDesc()', 4000);
}

function noDesc() {
}

function gotopage (strType, strReturn) {
var thedate = new Date();

thedate = thedate.getMonth()+1 + "/" + thedate.getDate()  +  "/" + thedate.getYear();
 
//if (isNS)
// if (!(document.getElementById)){
//  thedate = document.aform.dateval.value;  }
//  else {    thedate = document.getElementById('dateval').value; }
//else
//{  thedate = document.getelementbyid("dateval").value; }

if (strReturn=='undefined') {strReturn = 'calendar.asp'}

clearTimeout(MenuTimer);
noDesc();

switch (strType) {
  case 'medical':
	window.open ('AddMedNote.asp?return='+strReturn+'&Note_Date='+thedate, "CalAdd", config='width=420,height=370,top=10,left=10,scrollbars=yes,resizable,status=no');
    break;
  case 'ride':
	window.location = 'AddFullRide.asp?return='+strReturn+'&Ride_Date='+thedate;
    break;
  case 'wrench':
	window.open ('AddMaintenance.asp?return='+strReturn+'&Note_Date='+thedate, "CalAdd", config='width=420,height=250,top=10,left=10,scrollbars=yes,resizable,status=no');
    break;
  case 'weight':
	window.open ('addstat.asp?return='+strReturn+'&stat_id=0&Stat_Date='+thedate, "CalAdd", config='width=480,height=600,top=10,left=10,scrollbars=yes,resizable,status=no');
    break;
  case 'note':
	window.open ('addnote.asp?return='+strReturn+'&note_id=0&note_Date='+thedate, "CalAdd", config='width=420,height=250,top=10,left=10,scrollbars=yes,resizable,status=no');
    break;
 }
}

function GetmouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}

function GetmouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

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;
}
// Functions that swaps images. */

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_nbGroup(event, grpName) { //v6.0
var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])?args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) { img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr) for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

/* Functions that handle preload. */
function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function GetScaleFromServer(intID, dteDate, callbackFunction){
var url='Scale.asp?Users_ID='+intID+'&WeightDate='+dteDate;

var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");

document.getElementById('BigWeight').innerHTML = ".......";
//document.getElementById('BigWeight').style.fontSize = "13px";
//document.getElementById('BigWeight').style.lineHeight = "35px";
document.getElementById('BigWeight').style.color = "#336699";
request.open("GET", url, true);
request.onreadystatechange = function(){
        if (request.readyState == 4 && request.status == 200) {
                if (request.responseText){document.getElementById('scale').innerHTML = request.responseText}
        }
};
request.send(null)

}

