// Default variables ******************************************************************************



// Browser detect *********************************************************************************

var browserN4 = false;
var browserIE = false;
var browserN6 = false;

if(document.layers){
	browserN4 = true;
} else if(document.all) {
	browserIE = true;
} else if(document.getElementById) {
	browserN6 = true;
}

// Style sheet selected based on browser **********************************************************

function writeStyleLink(){
	if(browserN4){myStyle = "style_n4.css";}else{myStyle = "style.css";}
	var browserStyle = "<link rel='STYLESHEET' type='text/css' href='/jscss/" + myStyle + "'>";
	var printStyle = "<link rel='STYLESHEET' type='text/css' href='/jscss/print.css'>";
	document.write(browserStyle);
	if(FORM_DATA ['printable'])document.write(printStyle);
}


// Image preload and rollovers ********************************************************************

function preload0() {

if (document.images) {
	imgOver = new Image();
	imgOver.src = "/images/FFB119.gif";
	imgOut = new Image();
	imgOut.src = "/images/spacer.gif";
}
}

function preload1() {

	img1on = new Image();
	img1on.src = "/images/1b_about_1_o.gif";
	img1off = new Image();
	img1off.src = "/images/1b_about_1.gif";
	
	img2on = new Image();
	img2on.src = "/images/1b_about_2_o.gif";
	img2off = new Image();
	img2off.src = "/images/1b_about_2.gif";
	
	img3on = new Image();
	img3on.src = "/images/1b_about_3_o.gif";
	img3off = new Image();
	img3off.src = "/images/1b_about_3.gif";

	img4on = new Image();
	img4on.src = "/images/1b_challenges_1_o.gif";
	img4off = new Image();
	img4off.src = "/images/1b_challenges_1.gif";
	
	img5on = new Image();
	img5on.src = "/images/1b_challenges_2_o.gif";
	img5off = new Image();
	img5off.src = "/images/1b_challenges_2.gif";
	
	img6on = new Image();
	img6on.src = "/images/1b_challenges_3_o.gif";
	img6off = new Image();
	img6off.src = "/images/1b_challenges_3.gif";

	img7on = new Image();
	img7on.src = "/images/1b_results_1_o.gif";
	img7off = new Image();
	img7off.src = "/images/1b_results_1.gif";
	
	img8on = new Image();
	img8on.src = "/images/1b_results_2_o.gif";
	img8off = new Image();
	img8off.src = "/images/1b_results_2.gif";
	
	img9on = new Image();
	img9on.src = "/images/1b_results_3_o.gif";
	img9off = new Image();
	img9off.src = "/images/1b_results_3.gif";

}

function imgOn(imgName) {if (document.images) {document[imgName].src = eval(imgName + "on.src");}}
function imgOff(imgName) {if (document.images) {document[imgName].src = eval(imgName + "off.src");}}

function rollOver(i) {
	a = "img" + i + "L";
	b = "img" + i + "R";
	document[a].src = imgOver.src;
	document[b].src = imgOver.src;	
}

function rollOff(i) {
	a = "img" + i + "L";
	b = "img" + i + "R";	
	document[a].src = imgOut.src;
	document[b].src = imgOut.src;
}

function stickButton(i) {
	eval("img" + i + ".src = img" + i + "on.src");
	eval("img" + i + "off.src = img" + i + "on.src");
}




// Positioning functions  *************************************************************************

function getX(obj){
  if(document.layers){
  	return eval(obj).x;
	//return eval(obj).pageX;    // ************* x for image pos, pageX for layer pos
  } else {
  	return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
  }
}

function getY(obj) {
	if(document.layers){
  		return eval(obj).y;     // ************* y for image pos, pageY for layer pos
		//return eval(obj).pageY;
	} else {
  		return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
	}
}

// GET Parsing Module *****************************************************************************

function createRequestObject() {
  
  FORM_DATA = new Object();
    // The Object ("Array") where our data will be stored.
  
  separator = ',';
    // The token used to separate data from multi-select inputs
  
  query = '' + this.location;
    // Get the current URL so we can parse out the data.
    // Adding a null-string '' forces an implicit type cast
    // from property to string, for NS2 compatibility.
    
  query = query.substring((query.indexOf('?')) + 1);
    // Keep everything after the question mark '?'.
  
  if (query.length < 1) { return false; }  // Perhaps we got some bad data?
  
  keypairs = new Object();
  numKP = 1;
    // Local vars used to store and keep track of name/value pairs
    // as we parse them back into a usable form.
    
  while (query.indexOf('&') > -1) {
    keypairs[numKP] = query.substring(0,query.indexOf('&'));
    query = query.substring((query.indexOf('&')) + 1);
    numKP++;
      // Split the query string at each '&', storing the left-hand side
      // of the split in a new keypairs[] holder, and chopping the query
      // so that it gets the value of the right-hand string.
  }

  keypairs[numKP] = query;
    // Store what's left in the query string as the final keypairs[] data.
  
  for (i in keypairs) {
    keyName = keypairs[i].substring(0,keypairs[i].indexOf('='));
      // Left of '=' is name.
    keyValue = keypairs[i].substring((keypairs[i].indexOf('=')) + 1);
      // Right of '=' is value.
    while (keyValue.indexOf('+') > -1) {
      keyValue = keyValue.substring(0,keyValue.indexOf('+')) + ' ' + keyValue.substring(keyValue.indexOf('+') + 1);
        // Replace each '+' in data string with a space.
    }
    
    keyValue = unescape(keyValue);
      // Unescape non-alphanumerics
      
    if (FORM_DATA[keyName]) {
      FORM_DATA[keyName] = FORM_DATA[keyName] + separator + keyValue;
        // Object already exists, it is probably a multi-select input,
        // and we need to generate a separator-delimited string
        // by appending to what we already have stored.
    } else {
      FORM_DATA[keyName] = keyValue;
        // Normal case: name gets value.
    }
  }

  return FORM_DATA;
}

FORM_DATA = createRequestObject();
  // This is the array/object containing the GET data.
  // Retrieve information with "FORM_DATA [ 'key' ] = value".

	
// MISC ********************************************************************************************
	
function writeBackTop(){
//alert(getY(document.images['posImgBot']));
	currBot = getY(document.images['posImgBot']);
	if (currBot > 490) {
		if(document.layers){
			// document.divtop.display = 'inline'; //does not work
		} else if(document.all) {
			document.all.divtop.style.display = 'inline';
		} else if(document.getElementById) {
			document.getElementById("divtop").style.display = 'inline';
		}
	}
}

