//Google adSense variables<!--
google_ad_client = "pub-1596956539298667";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_type = "text";
//2007-07-18: Channel0
google_ad_channel = "1971382050";
google_color_border = "336699";
google_color_bg = "FFFFFF";
google_color_link = "0000FF";
google_color_text = "000000";
google_color_url = "008000";
google_ui_features = "rc:6";
//-->

var xmlhttp;
var bodyElementId = 'bodyDiv';
var currentElement;
var accumulateReadyState;
var imageId = 0;
var imageIdMax = 6;
var timerInterval = 5000;//milliseconds

function init(){
	showBody('home', 'snippet');
	startTimer();
}

function version(){
	return ('beta: 200708020652');
}

function showBody(what, type){
	//type: null=image; snippet=page snippet
	var loadingHTML = '<span id=loadingHTML class=loadingHTML>Loading...!</span>'
	currentElement = document.getElementById(bodyElementId);
	currentElement.innerHTML = loadingHTML+ ' ' + what;
//	if (what.length < 15 ){//display the HTML snippet
	if (type == 'snippet'){
		loadXMLDoc(what + 'Snippet.html');
		state_Change();
	}
	else{//assume(swear word) displaying full image
		currentElement.innerHTML = '<div id="fullImageDiv" align="center"><img align="center" alt="' + what + '" title="' + what + '" src="' + what + '"></a></div>';
	}
}

function so_clearInnerHTML(obj) {
	// so long as obj has children, remove them
	while(obj.firstChild) obj.removeChild(obj.firstChild);
}

function loadXMLDoc(url){
	var tempTxt='';
	xmlhttp=null;
	accumulateReadyState='';
	// code for Mozilla, etc.
	if (window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}
	// code for IE
	else if (window.ActiveXObject){
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null){
		xmlhttp.onreadystatechange=state_Change;
		try{
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}catch(err){
			if (xmlhttp.readyState != 4){
				tempTxt = '<span id="loadXML" class="catastrophicError">';
				tempTxt += 'Content not found!';
				tempTxt += '</span>';
				currentElement.innerHTML = tempTxt;
			}
		}
	}else{
		currentElement.innerHTML = '<span id="loadXML" class="catastrophicError">Your browser does not support XMLHTTP!</span>';
	}
}

function state_Change(){
	var readyStateRequired = 4;
	var statusRequired = 200;
	var loc = window.location;
	var tempTxt='';
	//if no host assume(swear word!) debugging using url file:///
	if (window.location.host == ''){statusRequired = 0;}
	// if xmlhttp shows "loaded"
	accumulateReadyState = accumulateReadyState + xmlhttp.readyState + ', ';
	//alert(accumulateReadyState);
	if (xmlhttp.readyState==readyStateRequired){
		if (xmlhttp.status==statusRequired){
			currentElement.innerHTML = xmlhttp.responseText;
    		}else{
			tempTxt = '<span id="stateChange:" ';
			tempTxt += 'class="catastrophicError">';
			if (xmlhttp.status==404){
				tempTxt += 'Content not found!';
			}else{
				tempTxt += 'Network Error!, Incorrect request state!, ';
				tempTxt += '[' + xmlhttp.readyState + '] != ';
				tempTxt += readyStateRequired + '.';
				tempTxt += '<br>States accumulated: ';
				tempTxt += accumulateReadyState
				tempTxt += '<br>Status: ';
				tempTxt += '[' + xmlhttp.status + '] != ' + statusRequired;
			}
			tempTxt += '</span>';
			currentElement.innerHTML = tempTxt;
		}
	}
}

function changeHeaderImage(){
	if (imageId > imageIdMax){imageId = 0;}
	//switch imageId{
//		case 0:	//
//		break;
//		default: alert('Warning!, Unexpected value in changeHeaderImage()')
//	}
	//alert(imageId);
//	var iansHeaderImage = document.getElementById('iansHeaderImage');
//	iansHeaderImage.src = imageId;
//src="images/TheWrightCompany-NetworkAdministrater.thumb.jpg"
	document.images['headerImage'].src='images/headerImage.thumb.' + imageId + '.jpg'
//	currentElement.innerHTML = '<h1>' + imageId + '</h1>';
	imageId++;
}

//******************TIMER functions********
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com

var timerID = 0;
var tStart  = null;

function updateTimer() {
   if(timerID) {
      clearTimeout(timerID);
      clockID  = 0;
   }

   if(!tStart)
      tStart   = new Date();

   var   tDate = new Date();
   var   tDiff = tDate.getTime() - tStart.getTime();

   tDate.setTime(tDiff);

//   document.theTimer.theTime.value = "" + tDate.getMinutes() + ":"  + tDate.getSeconds();
	changeHeaderImage();
   timerID = setTimeout("updateTimer()", timerInterval);
}

function startTimer() {
   tStart   = new Date();

   //document.theTimer.theTime.value = "00:00";

   timerID  = setTimeout("updateTimer()", timerInterval);
}

function stopTimer() {
   if(timerID) {
      clearTimeout(timerID);
      timerID  = 0;
   }

   tStart = null;
}

function resetTimer() {
   tStart = null;

   //document.theTimer.theTime.value = "00:00";
}
//*************end TIMER functions**************

//************SCROLL functions*********
// Scrolling Ad Javascript
// copyright 3rd September 2004, by Stephen Chapman
// permission to use this Javascript on your web page is granted
// provided that all of the code in this script (including these
// comments) is used without any alteration

var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;
if (stdDOM){
	aDOM = 1;
}else{
	ieDOM = document.all; 
	if (ieDOM){
		aDOM = 1;
	}else{
		var nsDOM = ((navigator.appName.indexOf('Netscape') != -1) && (parseInt(navigator.appVersion) ==4)); 
		if (nsDOM) aDOM = 1;
	}
}

function findDOM(objectId, wS) {
	if (stdDOM) return wS ? document.getElementById(objectId).style:
	document.getElementById(objectId);
	if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];
	if (nsDOM) return document.layers[objectId];
}

function findLivePageWidth() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}

function findAdWidth(objectID) {
	var obj = findDOM(objectID,0);
	if(obj.offsetWidth) return obj.offsetWidth;
	if (obj.clip) return obj.clip.width;
	return 220;
}

var right = 1;
var countdown = 10;
var slideDelay = 0;
var objStyle = null;

function startAd(objectID) {
	if (aDOM) {
 		objStyle = findDOM(objectID,1);
		var rightBoundary = findLivePageWidth() - findAdWidth(objectID)-20;
		rightBoundary -= rightBoundary % 2;
		slideAd(10,rightBoundary,rightBoundary);
	}
}

function slideAd(currentPos, finalPos,rightBoundary) {
	if (currentPos != finalPos) {
		if (currentPos > finalPos){
			currentPos -= 2;
		}else{
			currentPos += 2;
			objStyle.left = currentPos;
		}
	}else {
		countdown--;
		if (right) {
			finalPos = 0;
			currentPos = rightBoundary;
			right = 0;
		}else{
			finalPos = rightBoundary;
			currentPos = 0; right = 1;
		}
	}
	if (countdown > 0) setTimeout('slideAd('+currentPos+','+finalPos+','+rightBoundary+')',slideDelay);
	if (countdown == 0) objStyle.visibility = 'hidden';
	return;
}

function hideAd(objectID) {
	objStyle = findDOM(objectID,1);
	objStyle.visibility = 'hidden';
}

function displayAd(adText,cd) {
	document.write('<div id="mainAd" ><div align="center">\n'+adText+'\n<\/div><\/div>');
	countdown = cd;
	startAd('mainAd');
}
//**************end SCROLL functions************

