var theBrowser = navigator.userAgent;
var theVersion = navigator.appVersion;
var tagLineBar = true;
var navBarTop = true;
var navBarBottom = true;
var detailSize = 0;
var theRec = "";
var theContent = "";
var theDetail = false;
var pageSize = 0;
var detailFull = 440;
var bOpacity = 99;
var lOpacity = 20;
var yScroll = 0;
var winLoaded = false;

function initElements() {
	pageSize = document.body.clientWidth;
	//var closebox = document.getElementById('closebox');
	//closebox.onclick = hideDetail;
}

window.onload = function() {
	initElements();
	winLoaded = true;
}

function popup(theImage) {
	doWin = window.open('','popup','width=500,height=500,scrollbars=0');
//	doWin.document.write('<script language="Javascript" type="text/javascript">var popupwidth=0;var popupheight=0;<\/script>');
	doWin.document.write('<html lang="en"><head><title>' + theImage + '<\/title><\/head><body style="background:#CCCA97;margin:0px" onblur="window.close()">');
	doWin.document.write('<div align="center"><img src="images/' + theImage + '" alt="" name="popimage" onload="window.resizeTo(this.width,this.height + 12)"><\/div>');
	doWin.document.write('<\/body><\/html>');
//	doWin.document.write('<script language="Javascript" type="text/javascript">alert(popupheight);window.resizeTo(500,window.innerHeight-popupheight);<\/script>');
	doWin.document.close();
}

window.onresize = function() {
	 //setColumns();
	 pageSize = document.body.clientWidth;
}

function setScroll() {
	if (window.pageYOffset) {
		yScroll = window.pageYOffset;
	} else {
		yScroll = document.body.parentElement.scrollTop;
	}
}

window.onscroll = function() {
	setScroll();
}

function setRec(theRec, theContent) {
	this.theContent = theContent;
	this.theRec = theRec;
	showDetail();
}

function openDetail() {
	if (detailSize < detailFull) {
		detailSize = detailSize + 60;
		document.getElementById(theRec).style.width = detailSize + "px";
		document.getElementById(theRec).style.height = detailSize + "px";
		//document.getElementById('counter').innerHTML = detailSize;
		//document.getElementById('debug').innerHTML = theRec;
		window.setTimeout("openDetail()", 50);
	} else {
		theDetail = true;
		document.getElementById(theContent).style.display = "block";
	}
}

function fadeBackground() {
	if (bOpacity > lOpacity) {
		bOpacity = bOpacity - 10;
		//document.getElementById('heart').style.filter = "alpha(opacity:" + bOpacity + ")";
		//document.getElementById('heart').style.opacity = bOpacity/100;
		//window.setTimeout("fadeBackground()", 100);
	}
}

function brightenBackground () {
	bOpacity = 99;
	//document.getElementById('heart').style.opacity = bOpacity/100;
	//document.getElementById('heart').style.filter = "alpha(opacity:" + bOpacity + ")";
}

function showDetail() {
	if (winLoaded) {
		if (!theDetail) {
			var detailArea = Math.round((pageSize/2) - (detailFull/2));
			document.getElementById(theRec).style.left = detailArea + "px";
			document.getElementById(theRec).style.top = yScroll + "px";
			document.getElementById(theRec).style.display = "block";
			openDetail();
			//(theBrowser.indexOf('Safari') != -1) ? null:fadeBackground();
		}
	}
}

function hideDetail() {
	if (theDetail) {
		detailSize = 0;
		document.getElementById(theRec).style.display = "none";
		document.getElementById(theContent).style.display = "none";
		//document.getElementById('heart').style.visibility = "visible";
		//(theBrowser.indexOf('Safari') != -1) ? null:brightenBackground();
		theDetail = false;
		
	}
}