//various scripts for physpics pages

// 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)
    }
}

// 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;
	}
}
