var PAGE_MIN_WIDTH = 600;
var PAGE_MAX_WIDTH = 900;

function fitWidth() {
	if(document.body.clientWidth > PAGE_MAX_WIDTH) return PAGE_MAX_WIDTH + "px";
	if(document.body.clientWidth < PAGE_MIN_WIDTH) return PAGE_MIN_WIDTH + "px";
	return "100%";
}

function findElementPos(elemFind)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent )


	return Array(elemX, elemY);
}

function openImage(title, url){
	height = 600;
	width = 800;
	var str = "scrollbars=yes, height=" + height + ",innerHeight=" + height;
	 str += ",width=" + width + ",innerWidth=" + width;
	 if (window.screen) {
	   var ah = screen.availHeight - 30;
	   var aw = screen.availWidth - 10;
	
	   var xc = (aw - width) / 2;
	   var yc = (ah - height) / 2;
	
	   str += ",left=" + xc + ",screenX=" + xc;
	   str += ",top=" + yc + ",screenY=" + yc;
	 }
	 
	wnd = window.open("", "photo", str);
	wnd.document.open();

	wnd.document.write("<html><head><title>" + title + "</title></head><body style=\"background-color: #6B8C9B;\">");
	
	wnd.document.write("<table cellspacing='0' cellpaddin='0' border='0' width='100%' height='100%'>");
	wnd.document.write("<tr><td align='center' valign='middle'>");
	wnd.document.write("<img src='" + url +"' border='0' style='border: solid #ffffff 1px;'>");
	wnd.document.write("</tr></td></table>");
	
	wnd.document.write("</body></html>");

	wnd.document.close(); 
	wnd.focus();

}


function showLeftPopup(text){
	document.getElementById('popup_left').style.display = 'none';
	document.getElementById('popup_right').style.display = 'block';
	document.getElementById('popup_text').innerHTML = text;
	showPopup('btn_prev', -365, -8);
}

function showRightPopup(text){
	document.getElementById('popup_right').style.display = 'none';
	document.getElementById('popup_left').style.display = 'block';
	document.getElementById('popup_text').innerHTML = text;
	showPopup('btn_prev', 122, -8);
}
