// JavaScript Document
function isAlphaNum(subject) {
	var myTest = /^([a-zA-Z0-9\s_-]+)$/; //remove the \s to disallow spaces
	return myTest.test(subject);
}
function getDate() {
	var time = new Date(); 
	document.write(time);
}
// show layer
function layerShow( layerName ) {
	document.getElementById(layerName).style.visibility='visible';
}  	
// hide layer
function layerHide( layerName ) {
	document.getElementById(layerName).style.visibility='hidden';
}
function findPos(oLink,myTerm) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		document.getElementById(myTerm).style.top = posY + "px";
		document.getElementById(myTerm).style.left = posX + "px";
	} else {
		document.getElementById(myTerm).style.top = posY + "px";
		document.getElementById(myTerm).style.left = posX + "px";
	}
	document.getElementById(myTerm).style.visibility = "visible";
}
function findPosR(oLink,myTerm) {
	if( oLink.offsetParent ) {
		for( var posX = 0, posY = 0; oLink.offsetParent; oLink = oLink.offsetParent ) {
			posX += oLink.offsetLeft;
			posY += oLink.offsetTop;
		}
		document.getElementById(myTerm).style.top = posY + "px";
		document.getElementById(myTerm).style.right = document.getElementById("wrapper").style.marginRight;
	} else {
		document.getElementById(myTerm).style.top = posY + "px";
		document.getElementById(myTerm).style.right = document.getElementById("wrapper").style.marginRight;
	}
	document.getElementById(myTerm).style.visibility = "visible";
}
function closeTerm(myTerm) {
	document.getElementById(myTerm).style.visibility = "hidden";
}
var myWin;
myWin = "";
function popWinOpen(zURL,zWidth,zHeight) {
	var popFeatures = "width=" + zWidth + ",height=" + zHeight + ",toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1";
	myWin = window.open(zURL,'myWin',popFeatures); 
	myWin.focus();
}
function popWinClose() {
	// this will close the same 'myWin' popup that we opened
	myWin = window.open('','myWin','');
	myWin.close();
}
function pushURL(myURL) {
	// this will load a new URL into the 'myWin' popup that we opened, or open a new 'myWin'
	if ((!myWin.closed && myWin.location)) {
		myWin.location = myURL;
	} else {
		var popFeatures = "width=600,height=400,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1";
		myWin = window.open(myURL,'myWin',popFeatures); 
	}
	myWin.focus();
}
var moveMent;
var dateTop = 160;
function dateMove() {
	if (dateTop > 120) {
		document.getElementById("header_date").style.top = (dateTop-2)+'px';
		dateTop = dateTop-2;
		clearTimeout(moveMent);
		moveMent = setTimeout("dateMove();", 30);
	}
}
var leftnavMove;
var leftnavX = -220;
function leftnavOpen() {
	if (leftnavX < 0) {
		document.getElementById("leftnav").style.left = (leftnavX+20)+'px';
		leftnavX = leftnavX+20;
		clearTimeout(leftnavMove);
		leftnavMove = setTimeout("leftnavOpen();", 10);
	}
}
function leftnavClose() {
	if (leftnavX > -220) {
		document.getElementById("leftnav").style.left = (leftnavX-20)+'px';
		leftnavX = leftnavX-20;
		clearTimeout(leftnavMove);
		leftnavMove = setTimeout("leftnavClose();", 10);
	}
}
function drawLeetLink() {
	var leetPool = new Array();
	var convPool = new Array();
	leetPool[1]="Leetspeek ";
	leetPool[2]="L337 Speak ";
	leetPool[3]="L33t 5p34k ";
	leetPool[4]="Elite Speak ";
	leetPool[5]="Hacker Speak ";
	convPool[1]="Converter";
	convPool[2]="Translator";
	var leetSeed = Math.round((leetPool.length-2) * Math.random())+1;
	var convSeed = Math.round((convPool.length-2) * Math.random())+1;
	document.getElementById("leetLink").innerHTML = leetPool[leetSeed]+convPool[convSeed];
}
var cipherPos=0;
function drawCipherHeader() {
	var cipherPool = new Array();
	cipherPool=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","+","~","!","@","#","$","%","&","*","?"];
	var realTitle = "cipher builder";
	var myTitle = realTitle.substring(0,cipherPos);
	//for( var i=1; i<15; i++ ) {
	var cipherChar = "";
	var cipherLength = 14 - cipherPos;
	for (var i = 1; i <= cipherLength; i++) {
		var cipherSeed = Math.round((cipherPool.length-2) * Math.random())+1;
		cipherChar = cipherChar + cipherPool[cipherSeed];
	}
	cipherPos++;
	myTitle = myTitle + cipherChar;
	document.getElementById("content_head_links").innerHTML = myTitle;
	if (cipherPos<15) {
		setTimeout("drawCipherHeader();", 150);
	}
}
/**************************************************************************
swapImage() and swapImage2() can be use in conjuction with
swapImgRestore() and swapImgRestore2() to perform multiple rollovers
for one mouse event and later return either image to its previous state
USAGE:
onMouseOver="swapImage('imgName','','/pathToImageRollover.jpg',1);"
onMouseOut="swapImgRestore();"
***************************************************************************/
// image rollover helper function
function findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}	
// image rollover
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// secondary image rollover
function swapImage2() {
  var i,j=0,x,a=swapImage2.arguments; document.sr2=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr2[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// tertiary image rollover
function swapImage3() {
  var i,j=0,x,a=swapImage3.arguments; document.sr3=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr3[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// image restore
function swapImgRestore() {
	var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
// secondary image restore
function swapImgRestore2() {
	var i,x,a=document.sr2; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
// tertiary image restore
function swapImgRestore3() {
	var i,x,a=document.sr3; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function promoOn(promo,depth) {
	var myDivs = promo.getElementsByTagName("div");
	myDivs[1].style.color = "#ffffff";
	myDivs[4].style.color = "#ffffff";
	var myImage = promo.getElementsByTagName("img");
	var mySource = "img/promo_sep_on.gif";
	mySource = depth + mySource;
	myImage[0].src = mySource;
}
function promoOff(promo,depth) {
	var myDivs = promo.getElementsByTagName("div");
	myDivs[1].style.color = "#006699";
	myDivs[4].style.color = "#cccccc";
	var myImage = promo.getElementsByTagName("img");
	var mySource = "img/promo_sep.gif";
	mySource = depth + mySource;
	myImage[0].src = mySource;
}
function trim(str) { // remove leading and trailing spaces from a string
	return str.replace(/^\s+|\s+$/g, '');
}
var cookiePrefix = "";
var myPage = location.href;
var wwwFlag = myPage.indexOf('www');
if (wwwFlag > 0) {
	cookiePrefix = "www";
}
var cookie_name = cookiePrefix + "cbCookie";
var YouEntered;
var YouWrote;
function cookieSet(myForm) {
	if (isAlphaNum(trim(myForm.cookie.value))||(myForm.cookie.value=="brenz.net")) {
		if (document.cookie != document.cookie) {
			index = document.cookie.indexOf(cookie_name);
		} else {
			index = -1;
		}
		if (index == -1) {
			YouEntered=document.forms[1].cookie.value;
			document.cookie=cookie_name+"="+YouEntered+"cbEndCookie; expires=Monday, 04-Apr-2020 05:00:00 GMT";
		}
		//alert("Your text -- " + YouEntered + " -- has been stored in a client-side cookie.");
		return true;
	} else {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Please enter alphanumeric text, no special characters, 25 characters max.<br />";
		myForm.cookie.value="";
		return false;	
	}
}
function cookieGet(returnFlag) {
	if(document.cookie)	{
		index = document.cookie.indexOf(cookie_name);
		if (index != -1) {
			namestart = (document.cookie.indexOf("=", index) + 1);
			nameend = document.cookie.indexOf("cbEndCookie;", index);
				if (nameend == -1) {
					nameend = 0;
				}
			YouWrote = document.cookie.substring(namestart, nameend);
			if (returnFlag != "none") {
				return YouWrote;
			}
		}
	}
}
function cookieDelete() {
		if (document.cookie != document.cookie) {
			index = document.cookie.indexOf(cookie_name);
		} else {
			index = -1;
		}
		if (index == -1) {
			document.cookie=cookie_name+"=GONEcbEndCookie; expires=Monday, 19-Aug-1996 05:00:00 GMT";
		}
		document.location = "delete_cookie.asp";
}
function emailSubmit() {
	if (trim(document.forms[1].subject.value) == "") {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "The SUBJECT: field must contain a value in order to send this message.<br />";
		document.forms[1].subject.focus();
		return false;
	} else {
		return true;
	}
}
function loginFocus() {
	document.forms[0].txtUserName.focus();
}
function loginSubmit() {
	if (document.forms[0].txtUserName.value == "gam") {
		document.location = "/client/help.asp?userid=gam";
		return false;
	} else {
		if (document.forms[0].txtUserName.value == "thecashexchange") {
			document.location = "/client/help.asp?userid=thecashexchange";
			return false;
		} else {
			document.forms[0].txtUserName.value = document.forms[0].txtUserName.value + "@brenz.net";
			var theform;
		theform = document.forms[0];
			var eventTarget="LoginImageButton";
			var eventArgument="";
			theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
			theform.__EVENTARGUMENT.value = eventArgument;
			theform.submit();
			return true;
		}
	}
}
function checkFileName() {
	document.getElementById("msgError").style.backgroundColor="#ccffff";
	document.getElementById("msgError").style.border="1px solid #ccffff";
	document.getElementById("msgError").innerHTML = "<br />";
	var strUser = document.forms[1].userName.value;
	if (strUser == "") {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Please enter your name.<br />";
		document.forms[1].userName.focus();
		return false;
	}
	var strFile = document.forms[1].fileName.value.toLowerCase();
	if (strFile == "") {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Please choose a filename.<br />";
		document.forms[1].fileName.focus();
		return false;
	}
	if (strFile.indexOf("\"")>-1||strFile.indexOf("]")>-1||strFile.indexOf("[")>-1||strFile.indexOf("}")>-1||strFile.indexOf("{")>-1||strFile.indexOf(",")>-1||strFile.indexOf(">")>-1||strFile.indexOf("<")>-1||strFile.indexOf("|")>-1||strFile.indexOf("'")>-1||strFile.indexOf("`")>-1||strFile.indexOf(";")>-1||strFile.indexOf("?")>-1||strFile.indexOf(":")>-1||strFile.indexOf("=")>-1||strFile.indexOf("+")>-1||strFile.indexOf(")")>-1||strFile.indexOf("(")>-1||strFile.indexOf("*")>-1||strFile.indexOf("&")>-1||strFile.indexOf("^")>-1||strFile.indexOf("$")>-1||strFile.indexOf("#")>-1||strFile.indexOf("!")>-1||strFile.indexOf("~")>-1||strFile.indexOf(".")>-1||strFile.indexOf("\\")>-1||strFile.indexOf("/")>-1||strFile.indexOf("%")>-1||strFile.indexOf("@")>-1||strFile.indexOf(" ")>-1) {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Sorry, please choose another filename, without punctuation.<br />";
		document.forms[1].fileName.value = "";
		document.forms[1].fileName.focus();
		return false;
	}
	for (var i = 1; i < document.forms[1].length-1; i++) {
		if (document.forms[1].elements[i].value == "") {
			document.getElementById("msgError").style.border = '1px solid #990000';
			document.getElementById("msgError").style.backgroundColor = '#ffccff';
			document.getElementById("msgError").innerHTML = "This will only work if you complete all of the fields.<br />";
			document.forms[1].elements[i].focus();
			return false;
		}
	}
	if (strFile=="index"||strFile=="default"||strFile=="thessaloniki"||strFile=="innit"||strFile=="8-bitgamer") {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "This file name is protected - please choose a non-protected file name.<br />";
		document.forms[1].fileName.focus();
		return false;
	} else {
		return true;
	}
}
function checkID() {
	if ((document.forms[1].nbrNeeded.value > 20000) || (document.forms[1].nbrNeeded.value == "") || (isNaN(document.forms[1].nbrNeeded.value)) || (document.forms[1].nbrNeeded.value == "0")) {
		document.getElementById("msgError").style.color = '#990000';
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Please provide a number of ID's under 20000.";
		document.forms[1].nbrNeeded.focus();
		return false;
	}
	if ((document.forms[1].nbrRndDigits.value > 50) || (document.forms[1].nbrRndDigits.value == "") || (isNaN(document.forms[1].nbrRndDigits.value))) {
		document.getElementById("msgError").style.color = '#990000';
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "Please provide a number of random digits under 50.";
		document.forms[1].nbrRndDigits.focus();
		return false;
	}
}
var makeSmallID = false;
function sampleID() {
	var myDigits = document.forms[1].nbrRndDigits.value;
	var myPrefix = document.forms[1].myPrefix.value;
	var mySuffix = document.forms[1].mySuffix.value;
	strRandom = "A98DB973KWL8XP1LZ94KJF0BMA5PEZ8C6490FWEI01QJMN32YU";
	if (makeSmallID) {
		strRandom = strRandom.toLowerCase();
	}
	var myRandomDigits = strRandom.substr(0,myDigits);	
	var mySampleID = myPrefix + myRandomDigits + mySuffix;
	document.getElementById("msgError").style.color = '#003366';
	document.getElementById("msgError").style.border = '1px solid #003366';
	document.getElementById("msgError").style.backgroundColor = '#66ccff';
	document.getElementById("msgError").innerHTML = "Sample ID: <strong>" + mySampleID + "</strong>";
}
function makeSmall() {
	var myCheckBox = document.forms[1].asLowerCase;
	if (myCheckBox.checked) {
		makeSmallID = true;
	} else {
		makeSmallID = false;		
	}
	sampleID();
}
// Cursor coordinate functions
var myX, myY, xyOn, myMouseX, myMouseY;
xyOn = true;
function getXYPosition(e){
	if (leftnavX <= -220) {
		myMouseX=(e||event).clientX;
		myMouseY=(e||event).clientY;
		if (myMouseX + 100 > document.documentElement.clientWidth) {
			myX = myMouseX - (myMouseX + 80 - (document.documentElement.clientWidth));
		} else {
			myX = myMouseX + 20;	
		}
		if (myMouseY + 64 > document.documentElement.clientHeight) {
			myY = myMouseY - (myMouseY + 44 - (document.documentElement.clientHeight));
		} else {
			myY = myMouseY + 20;	
		}
		if (document.documentElement.scrollTop > 0) {
			myY = myY + document.documentElement.scrollTop;
			myMouseY = myMouseY + document.documentElement.scrollTop;
		}
		document.getElementById('xy').style.top = myY + "px";
		document.getElementById('xy').style.left = myX + "px";
		document.getElementById('xy').innerHTML = "X is " + myMouseX + "<br />Y is " + myMouseY;
		document.getElementById('xy').innerHTML = document.getElementById('xy').innerHTML;
		if (xyOn) {
			document.getElementById('xy').style.visibility = "visible";
		} else {
			document.getElementById('xy').style.visibility = "hidden";
		}
	} else {
		document.getElementById('xy').style.visibility = "hidden";
	}
}
function toggleXY() {
	xyOn = !xyOn;
	if (!xyOn) {
		document.getElementById('xy').style.visibility = "hidden";
	} else {
		document.getElementById('xy').style.visibility = "visible";
	}
	document.getElementById('xyLink').blur();
	return false;
}
function flashLogo() {
	if (noNonsense==false) {
		if (logoOn) {
			swapImage('home','','img/brenznet.gif',1);
			logoOn = !logoOn;
			setTimeout("flashLogo();",600);
		} else {
			swapImage('home','','img/brenznet_on.gif',1);
			logoOn = !logoOn;
			setTimeout("flashLogo();",300);
		}
	}
}
function showTraits() {
	if (noNonsense==false) {
		if (lastTrait == (aryMyTraits.length)) {
			lastTrait = 1;	
		}
		var rndDirection = Math.round(6*Math.random());
		switch (rndDirection) {
			case 0:
			case 1: 
				traitTop(aryMyTraits[lastTrait]);
				break;
			case 2:
			case 3:
				traitUnder(aryMyTraits[lastTrait]);
				break;
			case 4:
				traitRight(aryMyTraits[lastTrait]);
				break;
			case 5:
			case 6:
				traitLeft(aryMyTraits[lastTrait]);
				break;
			default:
				traitLeft(aryMyTraits[lastTrait]);
				break;
		}
		lastTrait = lastTrait + 1;
	}
}
function traitTop(trait) {
	document.getElementById("tTop").innerHTML = '<div class="finger_left" style="float:left"></div>'+trait;
	document.getElementById("tTop").style.left = "180px";
	document.getElementById("tTop").style.top = "-15px";
	tTopY = -15;
	document.getElementById("tTop").style.visibility = "visible";
	tTopSouth();
}
function tTopSouth() {
	if (tTopY<10) {
		document.getElementById("tTop").style.top = (tTopY+2)+'px';
		clearTimeout(tTopMove);
		tTopMove = setTimeout("tTopSouth();", 30);
		tTopY = tTopY + 2;
	} else {
		setTimeout("document.getElementById('tTop').style.visibility = 'hidden';showTraits();",3000);
	}
}
function traitUnder(trait) {
	document.getElementById("tUnder").innerHTML = '<div class="finger_left" style="float:left"></div>'+trait;
	document.getElementById("tUnder").style.left = "180px";
	document.getElementById("tUnder").style.top = "45px";
	tUnderY = 45;
	document.getElementById("tUnder").style.visibility = "visible";
	tUnderNorth();
}
function tUnderNorth() {
	if (tUnderY>12) {
		document.getElementById("tUnder").style.top = (tUnderY-2)+'px';
		clearTimeout(tUnderMove);
		tUnderMove = setTimeout("tUnderNorth();", 30);
		tUnderY = tUnderY - 2;
	} else {
		setTimeout("document.getElementById('tUnder').style.visibility = 'hidden';showTraits();",3000);
	}
}
function traitRight(trait) {
	document.getElementById("tRight").innerHTML = '<div class="finger_left" style="float:left"></div>'+trait;
	document.getElementById("tRight").style.left = "680px";
	document.getElementById("tRight").style.top = "11px";
	tRightX = 680;
	document.getElementById("tRight").style.visibility = "visible";
	tRightWest();
}
function tRightWest() {
	if (tRightX>180) {
		document.getElementById("tRight").style.left = (tRightX-5)+'px';
		clearTimeout(tRightMove);
		tRightMove = setTimeout("tRightWest();", 10);
		tRightX = tRightX - 5;
	} else {
		setTimeout("document.getElementById('tRight').style.visibility = 'hidden';showTraits();",3000);
	}
}
function traitLeft(trait) {
	document.getElementById("tLeft1").innerHTML = '<div class="finger_right" style="float:right"></div>'+trait;
	document.getElementById("tLeft1").style.left = "-300px";
	document.getElementById("tLeft1").style.top = "11px";
	document.getElementById("tLeft1").style.zIndex = "3";
	tLeftX = -300;
	document.getElementById("tLeft1").style.visibility = "visible";
	tLeftEast();
}
function tLeftEast() {
	if (tLeftX<-130) {
		document.getElementById("tLeft1").style.left = (tLeftX+5)+'px';
		clearTimeout(tLeftMove);
		tLeftMove = setTimeout("tLeftEast();", 10);
		tLeftX = tLeftX + 5;
	} else {
		setTimeout("traitLeft2();",500);
	}
}
function traitLeft2() {
	if (lastTrait == (aryMyTraits.length)) {
		lastTrait = 1;	
	}
	var left2Trait = aryMyTraits[lastTrait];
	lastTrait = lastTrait + 1;
	document.getElementById("tLeft2").innerHTML = '<div class="finger_right" style="float:right"></div>'+left2Trait;
	document.getElementById("tLeft2").style.left = "-130px";
	document.getElementById("tLeft2").style.top = "11px";
	document.getElementById("tLeft2").style.zIndex = "2";
	tLeftY = 11;
	document.getElementById("tLeft2").style.visibility = "visible";
	tLeft2South();
}
function tLeft2South() {
	if (tLeftY<30) {
		document.getElementById("tLeft2").style.top = (tLeftY+1)+'px';
		clearTimeout(tLeftMove);
		tLeftMove = setTimeout("tLeft2South();", 10);
		tLeftY = tLeftY + 1;
	} else {
		setTimeout("traitLeft3();",250);
	}
}
function traitLeft3() {
	if (lastTrait == (aryMyTraits.length)) {
		lastTrait = 1;	
	}
	var left3Trait = aryMyTraits[lastTrait];
	lastTrait = lastTrait + 1;
	document.getElementById("tLeft3").innerHTML = '<div class="finger_right" style="float:right"></div>'+left3Trait;
	document.getElementById("tLeft3").style.left = "-130px";
	document.getElementById("tLeft3").style.top = "30px";
	document.getElementById("tLeft3").style.zIndex = "1";
	tLeftY = 30;
	document.getElementById("tLeft3").style.visibility = "visible";
	tLeft3South();
}
function tLeft3South() {
	if (tLeftY<49) {
		document.getElementById("tLeft3").style.top = (tLeftY+1)+'px';
		clearTimeout(tLeftMove);
		tLeftMove = setTimeout("tLeft3South();", 10);
		tLeftY = tLeftY + 1;
	} else {
		setTimeout("document.getElementById('tLeft1').style.visibility = 'hidden';document.getElementById('tLeft2').style.visibility = 'hidden';document.getElementById('tLeft3').style.visibility = 'hidden';showTraits();",4000);
	}
}
function nonSense(position) {
	if (position=="stop") {
		swapImage('home','','img/brenznet.gif',1);
		document.getElementById("chrisbrenz").innerHTML = '<a href="javascript:nonSense(\'start\');">Start the nonsense.</a>';
		document.getElementById("chrisbrenz").style.backgroundColor='#003366';
		document.getElementById("chrisbrenz").style.width = '110px';
		noNonsense = true;
	} else {
		document.getElementById("chrisbrenz").style.width = '200px';
		document.getElementById("chrisbrenz").style.backgroundColor='#ffffff';
		var chrisbrenz;
		chrisbrenz = '<strong>&lt;&lt; my self-portrait</strong><br />';
		chrisbrenz+= 'Yes, that\'s me up here lurking behind the brenz.net logo. ';
		chrisbrenz+= 'Well, me from a coupla\' two-three years ago anyway...<br />';
		chrisbrenz+= '<div id="nonsense">';
		chrisbrenz+= '<a href="javascript:nonSense(\'stop\');">Stop the nonsense.</a>';
		chrisbrenz+= '</div>';
		document.getElementById("chrisbrenz").innerHTML = chrisbrenz;
		noNonsense = false;
		flashLogo();
		showTraits();
	}
}
function lunchboxOpen( lunchID ) {
	document.getElementById('lunch_' + lunchID).style.display = "block";
	document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxClose('" + lunchID + "');\">Close Lunchbox " + lunchID + "...</a>";
}

function lunchboxClose( lunchID ) {
	document.getElementById('lunch_' + lunchID).style.display = "none";
	document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxOpen('" + lunchID + "');\">Open Lunchbox " + lunchID + "...</a>";
}
function alphaNumCheck(value) { // for VIN Checksum validation
	var myRegxp = /^[a-zA-Z0-9]{17}$/;
	if (myRegxp.test(value)==false) { 
		return false;
	} else {
		return true;
	}
}
function checkVIN(){
	var checkDigit="";
	var alphaPool = new Array(); // List of all allowable alpha digits (no I, O, or Q)
	alphaPool=["","a","b","c","d","e","f","g","h","j","k","l","m","n","p","r","s","t","u","v","w","x","y","z"];
	var alphaValue = new Array(); // Corresponding numeric value for alpha digits
	alphaValue=["",1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9];
	var digitWeight = new Array(); // Corresponding weight of VIN digits
	digitWeight=["",8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2];
	var finalWeight = new Array(); // Numeric value of each digit, multiplied by corresponding digit weight
	var myVIN = document.forms[1].userVIN.value.toLowerCase(); // VIN from input form
	if (alphaNumCheck(myVIN)) {
		var aryVinDigit = new Array();
		for (var i = 1; i <= 17; i++) { // parse the VIN and assign digits to an array
			aryVinDigit[i] = myVIN.substring(i-1,i);
		}
		var aryVinValue = new Array();
		for (var i = 1; i <= 17; i++) { // create array of numeric values corresponding to vin digits
			if (isNaN(aryVinDigit[i])) { // for alpha characters only
				var goodAlpha = false;
				//aryVinValue[i] = 8;
				for (var x = 1; x <= 23; x++) { // search alpha pool to find which letter in this digit
					if (aryVinDigit[i]==alphaPool[x]) {
						aryVinValue[i] = alphaValue[x]; // assign numeric value for this letter
						x = 24; // we found our man, exit the for loop
						goodAlpha = true;
					}
				}
				if (!goodAlpha) {
					document.getElementById("msgError").style.border = '1px solid #990000';
					document.getElementById("msgError").style.backgroundColor = '#ffccff';
					document.getElementById("msgError").innerHTML = "The VIN contains one or more invalid characters.  The letters I, O, and Q are not allowed.";
					i = 18; //stop checking VIN digits and report the error
					return false;
				}
			} else {
				aryVinValue[i] = aryVinDigit[i]; // numeric digit from VIN is used
			}
		}
		var totalWeight = 0; // sum of products of all digits (except 9th)
		for (var i = 1; i <= 8; i++) { // get weighted value of digits 1-8 and 10-17
			finalWeight[i] = aryVinValue[i] * digitWeight[i]; // digits 1 through 8
			finalWeight[i+8] = aryVinValue[i+9] * digitWeight[i+9]; // digits 10 through 17
			totalWeight = totalWeight + finalWeight[i] + finalWeight[i+8];
		}
		checkDigit = totalWeight%11;
		if (checkDigit == 10) {
			checkDigit = "x";
		}
		var msgAlert = "";
		document.forms[1].userVIN.value = myVIN;
		document.forms[1].vinDigit.value = aryVinDigit[9];
		document.forms[1].checkDigit.value = checkDigit;
		if (checkDigit==aryVinDigit[9]) {
			document.forms[1].isValid.value = "true";
		}
		return true;
	} else {
		document.getElementById("msgError").style.border = '1px solid #990000';
		document.getElementById("msgError").style.backgroundColor = '#ffccff';
		document.getElementById("msgError").innerHTML = "The VIN must be exactly 17 alpha-numeric digits, with no punctuation or spaces.";
		return false;
	}
}
function zTop(thumbID) {
	thumbID.style.zIndex = "100";
	var myDivs = thumbID.getElementsByTagName("div");
	myDivs[0].style.visibility = "visible";
}
function zBottom(thumbID) {
	thumbID.style.zIndex = "1";
	var myDivs = thumbID.getElementsByTagName("div");
	myDivs[0].style.visibility = "hidden";
}
function showFolio(myNbr) {
	for (var i = 1; i <= 5; i++) {
		document.getElementById("folio"+i).style.display = "none";
	}
	document.getElementById("folio"+myNbr).style.display = "block";
}
    // addAddressToMap() is called when the geocoder returns an
    // answer.  It adds a marker to the map with an open info window
    // showing the nicely formatted version of the address and the country code.
    function addAddressToMap(response) {
      map.clearOverlays();
      if (trim(document.forms[1].q.value) == "") {
				document.getElementById("geocodes").style.display = "none";
				document.getElementById("msgError").style.display = "block";
				document.getElementById("msgError").innerHTML = "You'll need to enter some location information in order for this to work...";
				map.setCenter(new GLatLng(34, -20), 2);
				return false;
			}
			if (!response || response.Status.code != 200) {
				document.getElementById("geocodes").style.display = "none";
        document.getElementById("msgError").style.display = "block";
				document.getElementById("msgError").innerHTML = "Sorry, we were unable to geocode that address.  Try using more/less detail or spelling variations.";
				map.setCenter(new GLatLng(34, -20), 2);
      } else {
        place = response.Placemark[0];
				document.getElementById("msgError").style.display = "none";
        document.getElementById("geocodes").innerHTML = "<table cellspacing='10'><tr><th>Location</th><th>Latitude</th><th>Longitude</th></tr><tr><td>" + place.address + "</td><td>" + place.Point.coordinates[1] + "</td><td>" + place.Point.coordinates[0] + "</td></tr></table>";
				document.getElementById("geocodes").style.display = "block";				
				point = new GLatLng(place.Point.coordinates[1],
                            place.Point.coordinates[0]);
        marker = new GMarker(point);
				map.setCenter(point, 5);
        map.addOverlay(marker);
				marker.openInfoWindowHtml(place.address);
      }
    }

