// JavaScript Document
/* This master JS file detects browsers, detects screen size, places flash, createsAJAXrequest*/


















/// PLEASE NOTE.  MANY OF THE FUNCTIONS ON THIS PAGE ARE NOT USED.  THIS WAS ADAPTED FROM MASTER.JS  FUNCTION MOVDIV, MOVDIV2 (ON THE BOTTOM) ARE USED FOR SURE.








//ajax function to create a request
  var request = null;
function createRequest() 
  {try {
    request = new XMLHttpRequest();
  } catch (trymicrosoft) {
    try {
      request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (othermicrosoft) {
      try {
        request = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (failed) {
        request = null;
      }
    }
  }

  if (request == null) {
    alert("Error creating request object!");
  } 
}




//incomplete function to return the browser
function findbrowser()
{
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
}




//creates getElementsByClassName
/*Written by Jonathan Snook, http://www.snook.ca/jonathan
Add-ons by Robert Nyman, http://www.robertnyman.com*/
function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements);
}






//play sounds on the website
//needs to be adapted to master js - used on hoboditty about page
var ver=parseInt(navigator.appVersion);
var ie4=(ver>3  && navigator.appName!="Netscape")?1:0;
var ns4=(ver>3  && navigator.appName=="Netscape")?1:0;
var ns3=(ver==3 && navigator.appName=="Netscape")?1:0;

function playSound() {
 if (ie4) document.all['BGSOUND_ID'].src='images/whatrulookinat.mp3';
 if ((ns4||ns3)
  && navigator.javaEnabled()
  && navigator.mimeTypes['audio/x-midi']
  && self.document.guitar.IsReady()
 )
 {
  self.document.guitar.play();
 }
}
<!--document.write("<embed src='images/whatrulookinat.mp3'> ");document.write('<noembed>');document.write("<bgsound src='images/whatrulookinat.mp3'>");document.write('</noembed>');-->
//playSound();
//use stopSound() to stop it





//incomplete function distinguish whether webpage can be displayed in highres
function screensize()
{
if ((screen.width>=1024) && (screen.height>=768))
{
 window.location="highres.html";
}
else
{
  window.location="lowres.html";
}
}





//incomplete function to display flash depending on url, width, height
function setflash(hurl,hwidth,hheight)
{
	var url = hurl;
	var width = hwidth;
	var height = hheight;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '">\n');
	document.write('<param name="movie" value="' + url + '" />\n');
	document.write('<param name=quality value=high />\n');
	document.write('<embed src="' + url + '" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>\n');
	document.write('</object>\n');

}





//stops sounds on the website - Untested?
//needs to be adapted to master js - used on hoboditty about page
function stopSound() {
 if (ie4) document.all['BGSOUND_ID'].src='images/jsilence.mid';
 if ((ns4||ns3)
  && navigator.javaEnabled()
  && navigator.mimeTypes['audio/x-midi']
 )
 {
  self.document.guitar.stop();
 }
}




//moves div from point a to point b to a to b
//script pulled from apple website.  I book marked it; there is more there.
//need to change it before it becomes master - used on hoboditty about page
var the_timeout;
var the_timeoutSTART;
var direction="down";
var change="no";
function moveDiv()
{
  // get the stylesheet
  //
  var new_bottom;
  var the_style = getStyleObject("myDivSTART");
  if (the_style)
  {
    // get the current coordinate and add 5
    //
    var current_bottom = parseInt(the_style.bottom);
	//alert(current_bottom + "ONE");
	if (direction == "up")
    {
      new_bottom = current_bottom + 3;
	  //alert("TWO - pt1: " + new_bottom);
    } 
    else 
    {
      new_bottom = current_bottom - 5;
	  //alert("TWO - pt2: " + new_bottom);
	}
	
	if (new_bottom > 0)
    {
      direction = "down";
	  clearTimeout(the_timeout); 
	  return false;
	  //alert("THREE - pt1: " + direction);
      //window.document.bee.src = "bee_left.gif";
    }

    if (new_bottom < -300)
    {
      direction = "up";
	  change = "yes";
    }
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      the_style.bottom = new_bottom;
	  //alert("FOUR - pt1: " + new_bottom);
    }
    else 
    {  
      the_style.bottom = new_bottom + "px";
	  //alert("FOUR - pt2: " + new_bottom);
    }
    
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
	//alert("FIVE: " + new_bottom);
	if(change=="yes")
	{
    	change="no";
		new_bottom = new_bottom + 20;
		//alert(the_style);
		the_timeoutSTART = setTimeout('moveDiv2();' ,1000);
	}
	else
	{
		the_timeout = setTimeout('moveDiv();',10);
	}
  }
}
function moveDiv2()
{
  // get the stylesheet
  //
  var new_bottom;
  var the_style = getStyleObject("myDiv");
  if (the_style)
  {
    // get the current coordinate and add 5
    //
    var current_bottom = parseInt(the_style.bottom);
	//alert(current_bottom + "TWO");
	if (direction == "up")
    {
      new_bottom = current_bottom + 4;
	  //alert("TWO - pt1: " + new_bottom);
    } 
    else 
    {
      new_bottom = current_bottom - 5;
	  //alert("TWO - pt2: " + new_bottom);
	}
	
	if (new_bottom > 0)
    {
      direction = "down";
	  change="yes";
	  //alert("THREE - pt1: " + direction);
      //window.document.bee.src = "bee_left.gif";
    }

    if (new_bottom < -800)
    {
      //direction = "up";
	  clearTimeout(the_timeoutSTART); 
	  return false;
	  //moveDiv();
	  //alert("THREE - pt2: " + direction);
      //window.document.bee.src = "bee_right.gif";
    }
    // set the left property of the DIV, add px at the
    // end unless this is NN4
    //
    if (document.layers) 
    {
      the_style.bottom = new_bottom;
	  //alert("FOUR - pt1: " + new_bottom);
    }
    else 
    {  
      the_style.bottom = new_bottom + "px";
	  //alert("FOUR - pt2: " + new_bottom);
    }
    
    // if we haven't gone to far, call moveDiv() again in a bit
    // 
	//alert("FIVE: " + new_bottom);
	if(change=="yes")
	{
    	change="no";
		the_timeout = setTimeout('moveDiv2();',4000);
		<!--document.write("<embed src='images/whatrulookinat.mp3'> ");document.write('<noembed>');document.write("<bgsound src='images/whatrulookinat.mp3'>");document.write('</noembed>');-->
		//playSound();
	}
	else
	{
		the_timeout = setTimeout('moveDiv2();',10);
	}
  }
}
//<a href="#" onClick="clearTimeout(the_timeout); return false;">stop wandering</a>
//test for browser - called from function above - need to change for it to be master
function getStyleObject(objectId) 
{
    // cross-browser function to get an object's style object given its
    if(document.getElementById && document.getElementById(objectId)) {
	// W3C DOM
	//alert("w3c" + objectId);
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
	// MSIE 4 DOM
	//alert("ms4");
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
	// NN 4 DOM.. note: this won't find nested layers
	//alert("nn4");
	return document.layers[objectId];
    } else {
	//alert("blah");
	return false;
    }
} // getStyleObject



