function ShowLogin() {
  // hide lost password
  v=document.getElementById("login"); v.style.display='inline';
  // hide register
  v=document.getElementById("register"); v.style.display='none';
  // show login
  v=document.getElementById("lostpassword"); v.style.display='none';
}
function ShowRegister() {
  // hide lost password
  v=document.getElementById("login"); v.style.display='none';
  // hide register
  v=document.getElementById("register"); v.style.display='inline';
  // show login
  v=document.getElementById("lostpassword"); v.style.display='none';
}
function ShowLostPassword() {
  // hide lost password
  v=document.getElementById("login"); v.style.display='none';
  // hide register
  v=document.getElementById("register"); v.style.display='none';
  // show login
  v=document.getElementById("lostpassword"); v.style.display='inline';
}

function GotoImage() {
  // directly go to the image number
  var d, v;
  d=document.getElementById("t_image");
  v=d.value;
  if (v.length==0) { return; }
  window.location="view.php?id="+v;
}

bits = new Array();
for (i = 13; i < 25; i++) {
  bits[i] = new Image 
  bits[i].src = 'bits/a' + (i + 1) + '.png';
}
function ShowSearch() {
  v=document.getElementById("SearchWindow");
  v.style.visibility='visible';
}
function HideSearch() {
  v=document.getElementById("SearchWindow");
  v.style.visibility='hidden';
}
function ShowResults(numma) {
  v=document.getElementById("results");
  if (numma!=1) {
    v.innerHTML=numma+" results found";
  } else {
    v.innerHTML=numma+" result found";
  }
}
function ShowSearchNav(ZeroOne) {
  // passed with 0, show back
  // passed with 1, show next
  if (ZeroOne==0) {
    v=document.getElementById("SearchBack");
    v.style.display='inline';
  }
  if (ZeroOne==1) {
    v=document.getElementById("SearchNext");
    v.style.display='inline';
  }
}
function flip(pict,track)
{
  var florp  = "florp" + pict;
  document.images[florp].src=bits[track].src;
}



function alloff() {
  flip(1,4);
  flip(2,4);
  flip(3,4);
}  
function timer() {                
  tick = document.getElementById("wait");
  tick.style.visibility='visible';
}
function turnoff() {                
  tick = document.getElementById("uppity");
  tick.style.visibility='hidden';
}
//Count me up
maxL=188;
var bName = navigator.appName;
function taLimit(taObj) {
  if (taObj.value.length==maxL) return false;
  return true;
}
function taCount(taObj,Cnt) { 
  objCnt=createObject(Cnt);
  objVal=taObj.value;
  if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
  if (objCnt) {
    if(bName == "Netscape"){	
	objCnt.textContent=maxL-objVal.length;
    }
    else { 
      objCnt.innerText=maxL-objVal.length;
    }
  }
  return true;
}
function createObject(objId) {
  if (document.getElementById) return document.getElementById(objId);
  else if (document.layers) return eval("document." + objId);
  else if (document.all) return eval("document.all." + objId);
  else return eval("document." + objId);
}
function textLimit(field) {
  return taCount(field,'myCounter');
  if (field.value.length > maxL) {
    alert("You can only enter in a maximum amount of " + maxL + " characters.  The excess will be truncated.");
    field.value = field.value.substring(0, maxL);
  }
}



function detailer() {                
  details2 = document.getElementById('details');
  details2.style.visibility='visible';
}
function Reporter() {                
  duh = document.getElementById('report');
  duh.style.visibility='visible';
  document.frmreport.issue.focus();
}
function NoReporter() {                
  duh = document.getElementById('report');
  duh.style.visibility='hidden';
}
function turnoff() {                
  details2 = document.getElementById('details');
  details2.style.visibility='hidden';
}



function ShowLogbert() {
  details2 = document.getElementById('logbert');
  details2.style.visibility='visible';
}
function HideLogbert() {
  details2 = document.getElementById('logbert');
  details2.style.visibility='hidden';
}
function ShowContact() {                
  details2 = document.getElementById('contact');
  details2.style.visibility='visible';
}
function HideContact() {                
  details2 = document.getElementById('contact');
  details2.style.visibility='hidden';
}
function ShowAccountSettings() {                
  details2 = document.getElementById('accountsettings');
  details2.style.visibility='visible';
}
function HideAccountSettings() {                
  details2 = document.getElementById('accountsettings');
  details2.style.visibility='hidden';
}


function DeleteImage(id) {
  if (confirm("Are you sure you want to delete this image?")) {
    location.href="imagedelete.php?id="+id;
  }
}

function RemoveAccount(id) {
  if (confirm("Are you sure you want to remove your account?")) {
    if (confirm("This cannot be reversed.  All images will be deleted.  Are you sure?")) {
      location.href="unlinkaccount.php?id="+id;
    }
  }
}

// from http://www.quirksmode.org/js/detect.html
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
