galleryPanelInit();

galleryAssignFunctions();


function galleryPanelInit()
{
$("gallery_close").onclick=galleryPanelHide;
$("gallery_title_bar").onmousedown=controllerObjectStartDrag;
$("gallery_title").onmousedown=controllerObjectStartDrag;

$("gallery_title_bar").onmouseout=controllerObjectStopDrag;
$("gallery_title").onmouseout=controllerObjectStopDrag;

$("gallery_title_bar").onmouseup=controllerObjectStopDrag;
$("gallery_title").onmouseup=controllerObjectStopDrag;

$("gallery_title_bar").onmousemove=controllerObjectDrag;
$("gallery_title").onmousemove=controllerObjectDrag;
}


function galleryPanelHide()
{
curtainHide();
$("gallery_panel").style.visibility="hidden";
controllerShowHideSelects(1);
document.body.onselectstart=new Function("return true;");
}


function galleryPanelShow()
{
	if(isMSIE && isMSIE<7)
	{
	controllerFixPNG($("gallery_panel"));
	}
controllerShowHideSelects(0);
$("gallery_panel").style.visibility="visible";
$("gallery_title_bar").style.width=($("gallery_panel").offsetWidth-1)+'px';
$("gallery_close").style.left=($("gallery_panel").offsetWidth-20)+'px';
$("gallery_close").style.top='1px';
controllerCenterPanel($("gallery_panel"));
curtainShow();
document.body.onselectstart=new Function("return false;");
}


function galleryPanelDisplay(e)
{
e = e || window.event;
var obj = e.target || e.srcElement;
var objTitle=obj.title;
$("gallery_title").innerHTML=objTitle;
$("gallery_photo").title=objTitle;
$("gallery_photo").alt=objTitle;
	if(obj.runtimeStyle && obj.runtimeStyle.filter && obj.runtimeStyle.filter>"")
	{
	var f=galleryGetImageSrc(obj.runtimeStyle.filter);
	$("gallery_photo").src=f.replace(/\/thumbnails/, "");
	}
	else
	{
	$("gallery_photo").src=obj.src.replace(/\/thumbnails/, "");
	}
$("gallery_photo").onload=galleryPanelShow;
}


function galleryGetImageSrc(f)
{
var startStr="src='";
var start=f.indexOf(startStr)+startStr.length;
var endStr="',sizingMethod";
var end=f.indexOf(endStr,start);
if(end==-1) end=f.length;
f=f.substring(start, end);
return f;
}


function galleryAssignFunctions()
{
var ret=/\/thumbnails/;
var re0=/\/00000000.gif/;
var objs=document.getElementsByTagName("IMG");
var obj;
	for(var i=0; i<objs.length; i++)
	{
	obj=objs[i];
		if(obj.src.search(ret)!=-1 && obj.src.search(re0)==-1)
		{
		obj.onclick=galleryPanelDisplay;
		obj.style.cursor=isOpera?'pointer':'url("/images/zoomin.cur"), pointer';
		}
		else
		{
			if(obj.runtimeStyle && obj.runtimeStyle.filter && obj.runtimeStyle.filter>"")
			{
			var f=galleryGetImageSrc(obj.runtimeStyle.filter);
				if(f.search(ret)!=-1 && f.search(re0)==-1)
				{
				obj.onclick=galleryPanelDisplay;
				obj.style.cursor='url("/images/zoomin.cur"), pointer';
				}
			}
		}
	}
}
