var PAGE_MIN_WIDTH = 760;
var PAGE_MAX_WIDTH = 1100;

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%";
}

var selected_menu_item = null;

function expandAction(section){
	var marker_id = "leftmenu_expander_" + section;
	var submenu_id = "leftmenu_sub_" + section;
	
	if(selected_menu_item != null){
		if(section == selected_menu_item){
			selected_menu_item = null;
			document.getElementById("leftmenu_sub_" + section).style.display = "none";
			document.getElementById("leftmenu_expander_" + section).src = "/resources/images/common/expander_plus.gif";
		}
		else{
			document.getElementById("leftmenu_sub_" + selected_menu_item).style.display = "none";
			document.getElementById("leftmenu_expander_" + selected_menu_item).src = "/resources/images/common/expander_plus.gif";
			
			document.getElementById("leftmenu_sub_" + section).style.display = "block";
			document.getElementById("leftmenu_expander_" + section).src = "/resources/images/common/expander_minus.gif";
			
			selected_menu_item = section;
		}
	}
	else{
		document.getElementById("leftmenu_sub_" + section).style.display = "block";
		document.getElementById("leftmenu_expander_" + section).src = "/resources/images/common/expander_minus.gif";
		
		selected_menu_item = section;
	}
}

function openImage(title, img_url, width, height){
	var str = "scrollbars=yes, height=" + height + ",innerHeight=" + height;
	 str += ",width=" + width + ",innerWidth=" + width;
	 
	 if (window.screen) {
	   var ah = screen.availHeight - 20;
	   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: RGB(220, 220, 209);'>");
	
	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='" + img_url + "'>");
	wnd.document.write("</tr></td></table>");
	
	wnd.document.write("</body></html>");

	wnd.document.close(); 
	wnd.focus();
}

function findElementPos(elemFind)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent )


	return Array(elemX, elemY);
}




