// adds function to onload event without removing old events - checks for existance first
if (typeof addLoadEvent != 'function') {
	addLoadEvent = function (func) {
		if (typeof window.onload != 'function') {
			window.onload = func;
		} else {
			var oldonload = window.onload;
			window.onload = function() {
				oldonload();
				func();
			}
		}
	}
}
// saves document.getElementById() function to getId() shorthand - checks for existance first
if (typeof getId != 'function') getId = function(value) {	return document.getElementById(value) }

/* ---------- font size ---------- */
function txtSize(value) {
	document.body.style.fontSize = value + "%";
	getSend("txtSize.asp?txtSize=" + value, null)
}
function setup() {
	if (getId('txtSmall')) getId('txtSmall').href="javascript:void(txtSize('80'))";
	if (getId('txtNormal')) getId('txtNormal').href="javascript:void(txtSize('100'))";
	if (getId('txtBig')) getId('txtBig').href="javascript:void(txtSize('120'))";
	//document.body.innerHTML += "<div id='prodWindow'></div>"; // needed for product finder
}
addLoadEvent (setup); // adds the setup function to the onload event

/* ----- product menu hover ----- */
function callId(id) {
		getId ('prodWindow').style.display = 'block';
		getSend ('prodFinder.asp?pid='+id, 'prodWindow');
}
function hideId(id) { getId ('prodWindow').style.display = 'none'; }




/* ---------- ajax script ---------- */
// Auth:					Jonathan Allen
// file created:	05-06-2007
// last updated:	07-06-2007
// v1.2.1

// EXAMPLE OF USE:
// <script type="text/javascript" src="ajax.js"></script>
// <div id="container"></div>
// <a href="javascript:getSend('getUser.php?usrId=2','container')">get user information</a>

// ----- ajax request -----
var subElem = null;																													// set blank id for subject element
function getSend(url, target) {
	if (http.readyState == 0 || http.readyState == 4) {												// check availability
		subElem = document.getElementById(target);															// save target Id
		http.open("GET", "/AjaxFiles/" + url, true);														// send request - method (get) - URL of ducument - true for asynchronous
		if (target != null) http.onreadystatechange = getResponse;							// get returned information if needed
		http.send(null);																												// for post only - null as using get method
	} else setTimeout("getSend('"+url+"', '"+ target+"')", 10);								// wait and recall if not currently available
}

// ----- retrieve file -----
function getResponse() {
	if (http.readyState == 4) {																								// check for ready state
		subElem.style.backgroundImage = "none";																	// remove loading image
		subElem.innerHTML = http.responseText; 																	// save response to subject
	}
}

// ----- send request -----
function getHTTPObject() {
   var httpObject = null;																										// set blank object variable
   if (window.XMLHttpRequest) httpObject = new XMLHttpRequest();						// check XMLHttpRequest object is available 
   else httpObject = new ActiveXObject("Microsoft.XMLHTTP");								// use ActiveX instead (how do you format again? :D)
	if (httpObject != null) { return httpObject; }														// returns object if aiablable
  else {																																		//	if nothing available (truely boned)
		alert ("I'm sorry, but your browser does not support Ajax!");						// let them know their browser sucks
		return false;																														// return false as nothing available
	}
}
var http = getHTTPObject();																									// sets http object for ajax use


