// news insertion scripts

var req;
var which;
var testurl = "";

function retrieveURL(url) {
	testurl = url; //set up a way to test which news id to drop .txt into.
    if (window.XMLHttpRequest) { // Non-IE browsers
      req = new XMLHttpRequest();
      req.onreadystatechange = processStateChange;
      try {
        req.open("GET", url, true);
      } catch (e) {
        alert(e);
      }
      req.send(null);
    } else if (window.ActiveXObject) { // IE
      req = new ActiveXObject("Microsoft.XMLHTTP");
      if (req) {
        req.onreadystatechange = processStateChange;
        req.open("GET", url, true);
        req.send();
      }
    }
  }
  
  
function SetContent() {
	if(testurl.indexOf("intctr")!=-1) { // check for IntCtr news hook.
	document.getElementById("news-intctr").innerHTML = req.responseText;
					   } else if (testurl.indexOf("hsm")!=-1) { // check for hsm
	document.getElementById("news-hsm").innerHTML = req.responseText;
					   } else { // otherwise, assume it's daytime
	document.getElementById("news-daytime").innerHTML = req.responseText;
					   } 
	
}

  function processStateChange() {
	if (req.readyState == 4) { // Complete
      if (req.status == 200) { // OK response
		SetContent();
		//document.getElementById("news-daytime").innerHTML = req.responseText;
		} else {
        // alert("Problem: " + req.statusText);
      }
    }
  }
  
  // homepage rollover boxes
  
  function hiliteBox(boxToHilite) {
	  var hiliteThis = document.getElementById(boxToHilite);
	  
	  	hiliteThis.style.backgroundColor="#F4F4F4";

  }
  
    function unHiliteBox(boxToHilite) {
	  var hiliteThis = document.getElementById(boxToHilite);
	  	hiliteThis.style.backgroundColor="";
	
  }
  
  
  
// sub page image rotator

function SpinImage(area,path,hght,count,extra){
// area=filename, path is directory where images are stored (minus trailing slash), hght is image height,count is total number of rotating images, extra is just built in for future use, so it's null now	 
 var numOfImages = count;
 var image_number=Math.round(Math.random()*numOfImages);     //randomly select an image
 var fileType = ".jpg";
 var image_choices = new Array();
 
 for(var i=0;i<=numOfImages;i++){
	 image_choices[i] = path+"/"+area+i+fileType;
	 
 	}
document.writeln('<IMG src='+image_choices[image_number]+' width=409 height='+hght+' name=PageImage alt=-- border=0 >');

}