window.onload = init;
function init() {
	document.forms[0].txtUserName.focus();
	}

function trim(str) { // remove leading and trailing spaces from a string
		return str.replace(/^\s+|\s+$/g, '');
	}
	function getDate() {
		var myDate = new Date(); 
		var myDisplayDate;
		var myMonthName=new Array(12);
			myMonthName[0]="January";
			myMonthName[1]="February";
			myMonthName[2]="March";
			myMonthName[3]="April";
			myMonthName[4]="May";
			myMonthName[5]="June";
			myMonthName[6]="July";
			myMonthName[7]="August";
			myMonthName[8]="September";
			myMonthName[9]="October";
			myMonthName[10]="November";
			myMonthName[11]="December";
		var myDayName=new Array(7);
			myDayName[0]="Sunday";
			myDayName[1]="Monday";
			myDayName[2]="Tuesday";
			myDayName[3]="Wednesday";
			myDayName[4]="Thursday";
			myDayName[5]="Friday";
			myDayName[6]="Saturday";
		myDisplayDate = myDayName[myDate.getDay()]+", "+myMonthName[myDate.getMonth()]+" "+myDate.getDate()+",  "+myDate.getFullYear();
		
		document.write(myDisplayDate);
	}
	// show layer
	function layerShow( layerName ) {
		document.getElementById(layerName).style.visibility='visible';
	}  	
	// hide layer
	function layerHide( layerName ) {
		document.getElementById(layerName).style.visibility='hidden';
	}
	var hdrActive = false;
	var hdrCurrent = 'none';
	var navCurrent = 'none';
	var hdrOffSwitch;
	function hdrChange(myLink,hdrID) {
		if ((hdr2Current != 'none') && (!hdr2Active)) {
			layerHide(hdr2Current);		
		}
		// Sets global hdr active flag;
		hdrActive = true;
		clearTimeout(hdrOffSwitch);
		// Hides old dropdown and sets global variable before showing new dropdown
		if (hdrCurrent != 'none') {
			layerHide(hdrCurrent);		
		}
		navCurrent = myLink.id;
		// If hdrID is passed in, set current dropdown id to global variable, shows new dropdown
		hdrCurrent = hdrID;
		if (hdrCurrent!='none') {
			layerShow(hdrCurrent);		
		}
	}
	function hdrHide() {
		if ((hdr2Current != 'none') && (!hdr2Active)) {
			layerHide(hdr2Current);		
		}
		if ((hdrCurrent != 'none') && (!hdrActive)) {
			layerHide(hdrCurrent);
		}
	}
	function hdrOut() {
		hdrActive = false;
		hdr2Active = false;
		clearTimeout(hdrOffSwitch);
		if (hdrCurrent!='none') {
			hdrOffSwitch = setTimeout("hdrHide();", 1000);
		}
	}
	function hdrOver() {
		hdrActive = true;
	}
	var hdr2Active = false;
	var hdr2Current = 'none';
	var hdr2OffSwitch;
	function hdr2Change(hdr2ID) {
		if (hdr2ID!='none') {
			// Sets global hdr active flag;
			if (hdr2Current!='none') {
				layerHide(hdr2Current);	
			}
			hdr2Active = true;
			// Sets current dropdown id to global variable, shows new dropdown
			hdr2Current = hdr2ID;
			layerShow(hdr2Current);	
		} else {
			if (hdr2Current!='none') {
				layerHide(hdr2Current);
			}
		}
	}
	function hdr2Out() {
		hdr2Active = false;
	}
	function hdr2Over() {
		hdrActive = true;
		hdr2Active = true;
	}
	/**************************************************************************
 	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 checkContact() {
		var isValid = true;
		for (var i = 1; i < document.forms[2].length-1; i++) {
			var myID = document.forms[2].elements[i].name;
			if ((document.forms[2].elements[i].value == "")&&(document.getElementById(myID).className=="formfield_req")) {
				document.getElementById(myID).style.backgroundColor="#ffcccc";
				isValid = false;
			} else {
				document.getElementById(myID).style.backgroundColor="#ffffff";
			}
		}
		if (document.forms[2].contact_method.selectedIndex == 2) {
			document.getElementById('email_address').className="formfield_req";
			if (!IsEmail(document.forms[2].email_address.value)) {
				document.getElementById("email_address").style.backgroundColor="#ffcccc";
				isValid = false;
			}
		} else {
			if (document.forms[2].contact_method.selectedIndex == 1) {
				document.getElementById('txtArea').className="formfield_req";
				document.getElementById('txt3Digit').className="formfield_req";
				document.getElementById('txt4Digit').className="formfield_req";
				if (document.forms[2].txtArea.value == "") {
					document.getElementById("txtArea").style.backgroundColor="#ffcccc";
					isValid = false;
				}
				if (document.forms[2].txt3Digit.value == "") {
					document.getElementById("txt3Digit").style.backgroundColor="#ffcccc";
					isValid = false;
				}
				if (document.forms[2].txt4Digit.value == "") {
					document.getElementById("txt4Digit").style.backgroundColor="#ffcccc";
					isValid = false;
				}
			}
		}
		if (isValid==false) {
			document.getElementById('form_error').style.display="block";
			document.location="#theForm";
			return false;
		}
	}
	function IsEmail(sEmail) {
		/***********************************************************
		Version 1.0
		Date: 03-23-04
		Description: Checks for valid email
		************************************************************/
		var result = false
  		var theStr = new String(sEmail)
  		var index = theStr.indexOf("@");
  		if (index > 0) {
		    var pindex = theStr.indexOf(".",index);
		    if ((pindex > index+1) && (theStr.length > pindex+1))
				result = true;
  		}
  		return result;
	}
	function doContactHider() {
		switch (document.forms[2].contact_method.selectedIndex) {
			case 1:
				document.getElementById('email').style.display="none";
				document.getElementById('email_address').className="formfield";
				document.forms[2].email_address.value = "";
				document.getElementById('phone').style.display="block";
				document.getElementById('txtArea').className="formfield_req";
				document.getElementById('txt3Digit').className="formfield_req";
				document.getElementById('txt4Digit').className="formfield_req";
				break;
			case 2:
				document.getElementById('phone').style.display="none";
				document.getElementById('txtArea').className="formfield";
				document.forms[2].txtArea.value = "";
				document.getElementById('txt3Digit').className="formfield";
				document.forms[2].txt3Digit.value = "";
				document.getElementById('txt4Digit').className="formfield";
				document.forms[2].txt4Digit.value = "";
				document.getElementById('email').style.display="block";
				document.getElementById('email_address').className="formfield_req";
				break;
			default:
				document.getElementById('email').style.display="none";
				document.getElementById('email_address').className="formfield";
				document.getElementById('phone').style.display="none";
				document.getElementById('txtArea').className="formfield";
				document.getElementById('txt3Digit').className="formfield";
				document.getElementById('txt4Digit').className="formfield";
				break;
		}
	}
	// Cursor coordinate functions
	var myX, myY, xyOn, myMouseX, myMouseY;
	xyOn = true;
	function getXYPosition(e){
			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";
			}
	}
	function toggleXY() {
		xyOn = !xyOn;
		if (!xyOn) {
			document.getElementById('xy').style.visibility = "hidden";
		} else {
			document.getElementById('xy').style.visibility = "visible";
		}
		if (document.getElementById('xyLink')) {
			document.getElementById('xyLink').blur();
		}
		return false;
	}
var showTimer;
function showTerm(id) {
		termFlag = true;	
		document.getElementById('xy').innerHTML = document.getElementById(id).innerHTML;				
		showTimer = setTimeout("document.getElementById('xy').style.visibility = 'visible';",100);
	}
	function hideTerm(id) {
		showTimer = setTimeout("document.getElementById('xy').style.visibility = 'hidden';",100);
		termFlag = false;
	}
	var termFlag;
	termFlag = false;
	function getTermPosition(e){
		myMouseX=(e||event).clientX;
		myMouseY=(e||event).clientY;
		if (myMouseX + 260 > document.documentElement.clientWidth) {
			myX = myMouseX - (myMouseX + 240 - (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;
		}
		if (termFlag == true) {
		document.getElementById('xy').style.top = myY + "px";
		document.getElementById('xy').style.left = myX + "px";
		}
	}

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[2].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[2].userName.focus();
		return false;
	}
	var strFile = document.forms[2].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[2].fileName.focus();
		return false;
	}
	if (!isAlphaNumNoSpace(strFile)) {
	//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[2].fileName.value = "";
		document.forms[2].fileName.focus();
		return false;
	}
	for (var i = 1; i < document.forms[2].length-1; i++) {
		if (document.forms[2].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[2].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[2].fileName.focus();
		return false;
	} else {
		return true;
	}
}


	function checkID() {
		if ((document.forms[2].nbrNeeded.value > 20000) || (document.forms[2].nbrNeeded.value == "") || (isNaN(document.forms[2].nbrNeeded.value)) || (document.forms[2].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[2].nbrNeeded.focus();
			return false;
		}
		if ((document.forms[2].nbrRndDigits.value > 50) || (document.forms[2].nbrRndDigits.value == "") || (isNaN(document.forms[2].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[2].nbrRndDigits.focus();
			return false;
		}
	}
	var makeSmallID = false;
	function sampleID() {
		var myDigits = document.forms[2].nbrRndDigits.value;
		var myPrefix = document.forms[2].myPrefix.value;
		var mySuffix = document.forms[2].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[2].asLowerCase;
		if (myCheckBox.checked) {
			makeSmallID = true;
		} else {
			makeSmallID = false;		
		}
		sampleID();
	}
	function emailSubmit() {
		if (trim(document.forms[2].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[2].subject.focus();
			return false;
		} else {
			return true;
		}
	}
	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[2].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[2].userVIN.value = myVIN;
			document.forms[2].vinDigit.value = aryVinDigit[9];
			document.forms[2].checkDigit.value = checkDigit;
			if (checkDigit==aryVinDigit[9]) {
				document.forms[2].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 loginSubmit() {
		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;
}
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 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);
	}
}
    // 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[2].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><strong>" + place.address + "</strong></td><td><strong>" + place.Point.coordinates[1] + "</strong></td><td><strong>" + place.Point.coordinates[0] + "</strong></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);
      }
    }
function isAlphaNum(subject) {
	var myTest = /^([a-zA-Z0-9\s_-]+)$/; //remove the \s to disallow spaces
	return myTest.test(subject);
}
function isAlphaNumNoSpace(subject) {
	var myTest = /^([a-zA-Z0-9_-]+)$/; //remove the \s to disallow spaces
	return myTest.test(subject);
}
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[2].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 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 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";
}
