//Watson Industries, Inc. JavaScript archive


//********** Functions for changing the images involved with the main navigation buttons ********
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_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 MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); 
  return x;
}

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];
    }
}

//******** Watson Functions ****************************************

//Opens a new window with an image and title below it.  Used for app pictures.
function OpenWindow(img_loc,app,w,h,app_link){
  w=w+60;h=h+120; //Add a whitespace border around the image to be displayed
  var cStr;
  cStr=String.fromCharCode(60,47,115,99,114,105,112,116,62);  //this spells out the html to close the <script> declaration below.  Writing it in directly caused javascript to appear in some browsers.
  html=["","","","",""];
  html[0]="<html><head><script>self.resizeTo("+w+","+h+")"+cStr;	//put in a script to resize the window
  html[1]="<title>"+app+"</title><link rel='stylesheet' href='watson.css' type='text/css'></head><body>";	//reference the .css file
  html[2]="<center><img src='"+img_loc+"'border=0>";								//place the image in the window
  if(app_link==""){												//if an app note link is not passed
    html[3]="<br><span class=headings>"+app+"</span><br>";}							//place the app title as a heading
  else{				   										//otherwise code it as a link
    html[3]="<br><a class=headings title='Click here for an app note on "+app+"' href='"+app_link+"'>"+app+"</a><br>";
  }
  html[4]="<a href='' onClick='self.close()'>Close</a></center></body></html>";	//place a link that allows the window to close
  
  ImageWindow=window.open(img_loc,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizeable=no,copyhistory=no,innerwidth=" + w + ",innerheight="+h+"width="+w+"height="+h);
  ImageWindow.document.write(html[0]+html[1]+html[2]+html[3]+html[4]);
  ImageWindow.document.close();
}

function changeHdr(txt){
  document.getElementById("Img_hdr").innerHTML = "Watson Industries<br>"+ txt;
}
function changeTxt(txt){
  document.getElementById("Img_text").innerHTML = txt;
}

PgPos=0;
init=false;

function FilterData(Data){
	if (init==false){			  			 //Initialize the PgPos variable with the current page position.
	init=true;
	PgPos=Data;}
	else{
		Diff=Data-PgPos;					//Calculate the absolute value of the difference between the
	   	if (Diff<0){Diff=Diff*-1}			//current menu position and the current position of the viewer
	   	if (Diff>800){						//If the difference is large,
	    	PgPos=PgPos+((Data-PgPos)*0.9)}	//then jump most of the way to the current position.
	   else{
			PgPos = PgPos+((Data-PgPos)/2);	//Otherwise, approach the current value more slowly.
	    }
	  }
	}
		
function MoveMenu(){
	var iebody=(document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body;
	var ieY=document.all? iebody.scrollTop : pageYOffset;
	
	var staticObjects=document.all? document.all.staticmenu : document.getElementById("staticmenu");
	if(ieY<=270){ieY=270}
	FilterData(ieY);
	if (document.all||document.getElementById){
		staticObjects.style.position="absolute";
		staticObjects.style.top=PgPos+"px";
	}
}
  
/* Open submenu */
function menuopen(topmenu,submenu,menuimage){
	topmenu.className="open";
	submenu.className="opened";
	topmenu.src="../images/open.bmp";
	topmenu.alt="-";
}

/* Close submenu */
function menuclose(topmenu,submenu,menuimage){
	topmenu.className="close";
	submenu.className="closed";
	topmenu.src="../images/closed.bmp";
	topmenu.alt="+";
}


function check() {
x = document.getElementById ("searchbox").value;
if(x.length!=0){
  y = x.split(" ");
  y=y.join("+");
  url="http://www.google.com/search?sitesearch=www.watson-gyro.com&as_q=" + y + "&x=8&y=10";
  document.getElementById("searchbutton").href=url;
  }
  else{document.getElementById("searchbutton").href="Google Site Search";}
}

function srch() {
x = document.getElementById ("searchbox").value;
if(x.length!=0){return true;}
else{return false;}
}

function trapCR(e){
if(e.keyCode==13){
  x = document.getElementById ("searchbox").value;
  y=document.getElementById("searchbutton").href
  if(x.length!=0){window.open(y);}
  return false;}
else{return true;}
}