//various scripts for physpics pages

dbgmsg = new Function("msg", 
		(typeof debugWin == "undefined") ? "" : "debugMsg(msg)");

// swap(id, beswapped) 
//    the object at 'id' must have these fields:
//		id   - an identifier
//		src  - probably an image URL
// 		swappic - alternate value for src
//		isswapped - boolean, initially false
//   when isswapped is true, fields src and swappic
//		are given the opposite of their initial value
//   if src and swappic are images of different sizes, 
//	  	the width and height attributes should be omited
// Example: <td ... onmouseout="swap('zf', false)" 
//			onmouseover="swap('zf', true)">...<img ...
//		id="zf" src=twobeers.jpg  swappic="fred.jpg" isswapped="false">
//		...</td>
function swap(id, beswapped) {
    var image=document.getElementById(id)
    if (image.getAttribute("isswapped") != beswapped) {
	    var src = image.getAttribute("src", 0)
	    image.setAttribute("src", image.getAttribute("swappic"))
	    image.setAttribute("swappic", src)
	    image.setAttribute("isswapped", beswapped)
    }
}

function dirbarspanin(id) {
	var mid = document.getElementById("mid"+id);
	var front = document.getElementById("front"+id);
	//dbgmsg("dirbar in to: " + mid.id);
	mid.style.color = 'rgb(141,227,255)';
	front.style.color = 'rgb(0,51,204)';
}
function dirbarspanout(id) {
	var mid = document.getElementById("mid"+id);
	var front = document.getElementById("front"+id);
	//dbgmsg("dirbar out");
	mid.style.color = 'rgb(0,51,204)';
	front.style.color = 'rgb(141,227,255)';
}

hasfocused = false;
function searchfocus() {
	box = document.getElementById("searchbox");
	box.style.color = "black";
	arrow = document.getElementById("searcharrow");
	arrow.src="/images/searcharrow.png";
	if ( ! hasfocused) {
		box.value = "";
		hasfocused = true;
	}
}
function searchblur() {
	box = document.getElementById("searchbox");
	box.style.color = "#CCCCCC";
	arrow = document.getElementById("searcharrow");
	arrow.src="/images/searcharrow-gray.png";
}



// http://jibbering.com/2002/4/httprequest.html
// to get string from server
/*
sample usage sending to text.txt:
if (xmlhttp) {
 xmlhttp.open("GET", "test.txt",true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   alert(xmlhttp.responseText)
  }
 }
 xmlhttp.send(null)
}
*/
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

