<!--

// heavily neutered general Javascript functions from the playbook...

// the layer menu will be relocated wrongly in NS4.0x when resize the window, 
//so we have to force the page reload to get the right layer position when the window is resized,
//IE and NS6 are fine, since they won't referesh the page when the window size changes.
if (navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4) {
        widthCheck = window.innerWidth;
        heightCheck = window.innerHeight;
        window.onResize = resizeFix;
}

function resizeFix() {
        if (widthCheck != window.innerWidth || heightCheck != window.innerHeight)
        document.location.href = document.location.href;
}

// PositionedWin - function to open a child popup positioned relative to the parent.
// Child window will either open at a certain (x,y) coordinate below the parent
// OR default to centering within the user's screen
// @author Ean Rollings
// @date March 12, 2002
// @params URL - the only required parameter.
// @params width, height - defaults to 600, 450 respectively
// @params options - list of window options to pass to the window.open function
//                   if you want to override the default positioning, you can pass
//                   left=XXX,top=YYY in the window options parameter.  PLEASE ONLY
//                   OVERRIDE IF COMPLETELY NECESSARY!!
// @params name - default name is 'popup_'+random number.  Can be overridden.
function PositionedWin(url,width,height,options,name) {
  // DEFAULTS //
  var winW = 800, winH = 600;
  var winO = ',scrollbars=1,toolbar=0,location=1,directories=1,status=1,menubar=1,resizable=1';
  
  //for vertical positioning detect for IE or NN
  if ((navigator.appName == "Microsoft Internet Explorer")){
      var parOffsetX = 140, parOffsetY = 90;
  }
  else {  
	  var parOffsetX = 140, parOffsetY = 215;
  } 
  
  var debug = 0; // 0 = off, 1 = on

  // PARENT WINDOW INFO //
  if (document.all) {
    var x = window.screenLeft;
    var y = window.screenTop;
    var w = window.document.body.offsetWidth;
    var h = window.document.body.offsetHeight;
  } else {
    var x = window.screenX;
    var y = window.screenY;
    var w = window.outerWidth;
    var h = window.outerHeight;
  }

  // CHILD WINDOW INFO //
  if (width) { winW = width; }
  if (height){ winH = height; }

  // some browsers don't have access to the parent's x and y coordinants
  // so default to centering the child in the center of the screen
  if ((!x && x != 0) || (!y && y != 0)) { // if x | y are NaN, default to centering in screen
    if (debug) { alert("WARNING! defaulting to centering in the screen!"); }
	var lPos = Math.round((screen.availWidth - winW) / 2);
	var tPos = Math.round((screen.availHeight - winH) / 2);
  } else {
    // if the child window will be off the screen, attempt to fix x and y so that
    // we don't run off the edge of the screen (I got varying results on this one
    // depending on what options I had turned on for the child)
    x += parOffsetX; y += parOffsetY;
    if ( (x + winW) > screen.availWidth ) { if (debug) { alert("fixing x"); } x = screen.availWidth - winW - 25; }
    if ( (y + winH) > screen.availHeight ) { if (debug) { alert("fixing y"); } y = screen.availHeight - winH - 25; }
	var lPos = x;
	var tPos = y;
  }

  if (options) {
    if (options.indexOf(',') != 0) { options = "," + options; }
    winO = options;
  }
  winO = ',width='+winW+',height='+winH+winO;
  // for overriding automatic positioning
  if (winO.indexOf("left=") == -1) {
    winO = ',left='+lPos+winO;
  }
  if (winO.indexOf("top=") == -1) {
    winO = ',top='+tPos+winO;
  }
  // sorry for the confusion, just trying to make it fool-proof
  // after all is said and done, if our winO starts with a comma, chop it off
  if (winO.indexOf(',') == 0) { winO = winO.substring(1); }
  
  var winName;
  if (!name) {
    var i = getRandom();
	winName = 'popup_'+i;
  } else {
    winName = name;
  }
  var newPosWindow = window.open(url, winName, winO);
  newPosWindow.focus();
  
  if ((navigator.appName == "Microsoft Internet Explorer" &&
      parseInt(navigator.appVersion) > 4) || (navigator.appName == "Netscape")){
      newPosWindow.focus();
  } 
}

function getRandom() {

	var randoms = Math.random();
   	randoms = randoms * 10000;
	return Math.round(randoms);
	
}


//close popup, target parent window behind function
function closeGoBack(url) {
   window.parent.opener.location.href = url;
   window.self.close();
}

//keep popup, target parent window behind function
function stayGoBack(url) {
   window.parent.opener.location.href = url;
   window.self.blur();
}

//rollover function
function globalOver(img) {
   if(document.images) {
     document.images[img].src = '/images/'+img+'_on.gif';
   }
 }

function globalOut(img) {
  if(document.images) {
    document.images[img].src = '/images/'+img+'_off.gif';
  }
}
//end rollover function


//generic name/value pair function
// return a hash (of sorts) of name value pairs from the querystring
// uasge: var qsParams = getQsParams();
// then: qsParams['url'] whould equal whatever url=XXX in the querystring

function getQsParams() {
   var qs = location.search; 
   qs = qs.substring(1);
   // create an 'array' called newArray with the name value pairs from the querystring
   var qsArray = new Array;
   qsArray = qs.split('&'); //creating an array in which the values are separated by ampersands in the code//
   var keyValueArray = new Array; //this one loads the names and values into a hash (of sorts)//  
   for(i=0; i<qsArray.length; i++) {
        var nameValue = qsArray[i].split('='); //splitting what we find between each ampersand into key value pairs //
        keyValueArray[nameValue[0]] = unescape(nameValue[1]); //we are then turning all the escaped characters back into the 'real thing' ie. %3F turns into a '?' //
   }
   return keyValueArray;
}
// end generic name/value pair function

// -->


