/*
	GLOBAL JAVASCRIPT INCLUDE
	BO DESIGN
	CREATED 2/10/10
	Peter DeMarco
	Ten Squirrel, LLC
*/


var d = window.document;

//////////////////////////////////////
//  GENERIC RETURN ELEMENT FUNCTION //
//////////////////////////////////////

function getE( v ) {
  // e is for element!
  e = false;

  if ( d.getElementById ) {
    e = d.getElementById( v );
  }
  else if ( d.all ) {
    e = d.all[ v ];
  }

  return e;
}


/*
	AJAX BASE FUNCTIONALITY
*/

var xmlhttp = null;
var displayDiv = "";
var nextFunc = "";

////////////////////////////////
//	BASIC AJAX LOADER					//
////////////////////////////////

function getPage( url, second ) {

	if ( second != false ) nextFunc = second;
	else nextFunc = "";

	xmlhttp=null;
	if (window.XMLHttpRequest) {// code for all new browsers
  	xmlhttp=new XMLHttpRequest();
  }
	else if (window.ActiveXObject) {// code for IE5 and IE6
  	xmlhttp=new ActiveXObject( "Microsoft.XMLHTTP" );
  }
	if (xmlhttp!=null) {
		xmlhttp.onreadystatechange=stateChange;
		xmlhttp.open( "GET", url, true );
		xmlhttp.send( null );
  }
}

////////////////////////////////
//	EVENT HANDLER FOR HTTP		//
//	STATE CHANGE							//
////////////////////////////////

function stateChange() {
	if (xmlhttp.readyState==4) {// 4 = "loaded"
		if (xmlhttp.status==200) {// 200 = OK
			e = getE( displayDiv );
			e.innerHTML = xmlhttp.responseText;
			if ( nextFunc != "" ) eval( nextFunc );
		}
	}
}


function flip( e, img ) {
	e.src = "/_img/nav/" + img;
}

function bgFlip( e, hex ) {
  e.parentNode.style.backgroundColor=hex;
}