function view_jpg(jpg_url, title_str)
{
if (navigator.appName == "Netscape")
     html_src = "<html><title>" + title_str + "</title><script>function PositionPopUp(){window.moveTo((screen.availWidth - window.outerWidth)/2,(screen.availHeight-window.outerHeight)/2)}</script><style>body{margin:0px 0px 0px 0px}</style><body onload = 'PositionPopUp();' onblur='top.close()'><center><img src='"+ jpg_url +"' border=0 name=view_jpg onload='window.resizeTo(document.view_jpg.width+7,document.view_jpg.height+55)' onclick='self.close()'></center></body></html>";
else
     if (getIEVersion() < 7)
          html_src = "<html><title>" + title_str + "</title><script>function PositionPopUp(){window.moveTo((screen.availWidth - window.document.view_jpg.width+7)/2,(screen.availHeight-window.document.view_jpg.height+59)/2)}</script><style>body{margin:0px 0px 0px 0px}</style><body onload = 'PositionPopUp()' onblur='top.close()'><center><img src='"+ jpg_url +"' border=0 name=view_jpg onload='window.resizeTo(document.view_jpg.width+7,document.view_jpg.height+59)' onclick='self.close()'></center></body></html>";
     else
          html_src = "<html><title>" + title_str + "</title><script>function PositionPopUp(){window.moveTo((screen.availWidth - window.document.view_jpg.width+7)/2,(screen.availHeight-window.document.view_jpg.height+81)/2);window.resizeTo(document.view_jpg.width+7,document.view_jpg.height+81);if (document.getElementById('hdn').value == 0) {document.getElementById('hdn').value = 1;}}</script><style>body{margin:0px 0px 0px 0px}</style><body onload = 'PositionPopUp();' onblur='top.close()'><center><img src='"+ jpg_url +"' border=0 name=view_jpg onload='window.resizeTo(document.view_jpg.width+7,document.view_jpg.height+81)' onclick='self.close()'></center><form name = 'theform' ><input id = 'hdn' type = 'hidden' value = '0' /></form></body></html>";
     
var l,t;
l = screen.availWidth/2 ;
t = screen.availHeight/2;
var popup_win=window.open('','','scrollbars=no,location=no,status = 1,toolbar=no,width=1,height=1,top=' + t + ',left=' + l);
//ar popup_win=window.open('','','scrollbars=no,location=no,status = 1,toolbar=no,width=10,height=10,');
popup_win.document.open();
popup_win.document.write(html_src);
popup_win.document.close();
}





var mp;
var popupEnabled;
var thumbnailID;

function ShowWholeImage(str)
{    
     view_jpg(str,"Artwork");    
} 


function getMousePosition(e)
{
	var ns6 = document.getElementById && !document.all ? 1 : 0;
	var clientX = (document.layers || ns6) ? e.clientX : event.clientX;
	var clientY = (document.layers || ns6) ? e.clientY : event.clientY;
	var x = (document.layers || ns6) ? e.pageX : document.body.scrollLeft + event.clientX;
	var y;
	if (document.layers || ns6)
		y = e.pageY;
	else if (document.documentElement && document.documentElement.scrollTop)
		y = document.documentElement.scrollTop + event.clientY;
	else
		y = document.body.scrollTop + event.clientY;
	return {'x': x, 'y': y, 'clientX': clientX, 'clientY': clientY}
}

function getAbsolutePosition(obj)
{
	var ns6 = document.getElementById && !document.all ? 1 : 0;
	var x = 0, y = 0;

	while (obj != null)
	{
		x += obj.offsetLeft - obj.scrollLeft;
		y += obj.offsetTop - obj.scrollTop;
		obj = obj.offsetParent;
	}
	if (document.layers || ns6)
	{
		/* do nothing */
	}
	else  /* IE Fix */
	{
		if (document.documentElement && document.documentElement.scrollLeft)
			x += document.documentElement.scrollLeft;
		if (document.documentElement && document.documentElement.scrollTop)
			y += document.documentElement.scrollTop;
	}

	return {'x' : x, 'y' : y};
}

function captureMousePos(e)
{

	if (!e) e = event;
	mp = getMousePosition(e);


	if (popupEnabled == 1)
	{
		var thumbnail = document.getElementById(thumbnailID);
		var divpopup = document.getElementById('imgMainImage');
		var thumbPos = getAbsolutePosition(thumbnail);
		var divPos = getAbsolutePosition(divpopup);
/*
var input = document.getElementById('_ctl3_zenpanes_CenterPane__ctl0_listArtist__ctl4_lblFirstName');
if (input != null)
	input.innerHTML = '(' + mp.x + ':' + mp.y + '), (' + thumbPos.x + ':' + thumbPos.y + '), (' + thumbnail.clientWidth + ':' + thumbnail.clientHeight + ')';
*/

		if (((mp.x >= thumbPos.x) && (mp.y >= thumbPos.y) && (mp.x <= (thumbPos.x + thumbnail.clientWidth)) && (mp.y <= (thumbPos.y + thumbnail.clientHeight)))
			|| ((mp.x >= divPos.x) && (mp.y >= divPos.y) && (mp.x <= (divPos.x + divpopup.clientWidth)) && (mp.y <= (divPos.y + divpopup.clientHeight))))
		{
			/* do nothing */
		} 
		else
		{
			HidePopupImage(thumbnailID);
		}
	}

}

function init()
{
	document.onmousemove = captureMousePos;
	popupEnabled = 0;
}

function HidePopupImage(imgThumbnailID)
{

	var divPopUp = document.getElementById('divpopup');

	if ((popupEnabled == 1) && (divPopUp != null))
	{
		var imgThumbnail = document.getElementById(imgThumbnailID);
		var imgMainImage = document.getElementById('imgMainImage');

		imgMainImage.src = '';
		imgMainImage.style.display = 'none';

		divPopUp.style.display = 'none';

		popupEnabled = 0;
	}

}

function DisplayPopupImage(imagePath, imgThumbnailID)
{

	//alert('test');
	var divPopUp = document.getElementById('divpopup');

	if ((popupEnabled == 0) && (divPopUp != null))
	{
		var imgMainImage = document.getElementById('imgMainImage');
		var _left = eval(mp.x - (20 * (screen.width / 1440)));
		var _top = eval(mp.y - (10 * (screen.height / 900)));

		//imgMainImage.src = '/DesktopModules/Lithographic/litho_imageResize.aspx?url=' + imagePath + '&width=320&height=420';
		imgMainImage.src = imagePath;
		imgMainImage.style.display = '';

		with (divPopUp.style)
		{
			width = '322px';
			height = '422px';
			zIndex = 1000;
			display = 'block';
			position = 'absolute';
			left = _left + 'px';
			top = _top + 'px';
		}

		var imgThumbnail = document.getElementById(imgThumbnailID);

		thumbnailID = imgThumbnailID;
		popupEnabled = 1;
	}

}

function DisplayPopupImage2(imagePath, imgThumbnailID, imgHidden)
{

	//alert('test');
	var divPopUp = document.getElementById('divpopup');

	if ((popupEnabled == 0) && (divPopUp != null))
	{
		var imgMainImage = document.getElementById('imgMainImage');
		var imgHidden = document.getElementById(imgHidden);
		var _left = eval(mp.x - (20 * (screen.width / 1440)));
		var _top = eval(mp.y - (10 * (screen.height / 900)));

		//imgMainImage.src = '/DesktopModules/Lithographic/litho_imageResize.aspx?url=' + imagePath + '&width=320&height=420';
		//imgMainImage.src = imagePath;
		imgMainImage.src = imgHidden.src;
		imgMainImage.style.display = '';

		with (divPopUp.style)
		{
			//width = '322px';
			//width = '172px';
			//height = '422px';
			//height = '172px';
			zIndex = 1000;
			display = 'block';
			position = 'absolute';
			left = _left + 'px';
			top = _top + 'px';
		}

		var imgThumbnail = document.getElementById(imgThumbnailID);

		thumbnailID = imgThumbnailID;
		popupEnabled = 1;
	}

}
function DisplayPopupImage3(imagePath, imgThumbnailID, imgHidden)
{

	//alert('test');
	var divPopUp = document.getElementById('divpopup2');

	//if ((popupEnabled == 0) && (divPopUp != null))
	{
		var imgMainImage2 = document.getElementById('imgMainImage2');
		var imgHidden = document.getElementById(imgHidden);
		//var _left = eval(mp.x - (20 * (screen.width / 1440)));
		//var _top = eval(mp.y - (10 * (screen.height / 900)));				
          //var _left = (screen.availWidth - imgHidden.scrollWidth)/2;
		//var _top = (screen.availHeight - imgHidden.scrollHeight)/2;
		//imgMainImage.src = '/DesktopModules/Lithographic/litho_imageResize.aspx?url=' + imagePath + '&width=320&height=420';
		//imgMainImage.src = imagePath;
		imgMainImage2.src = imgHidden.src;  
		imgMainImage2.style.display = '';

		with (divPopUp.style)
		{
			//width = '602px';
			//height = '418px';
			zIndex = 1000;
			display = 'block';
			position = 'absolute';
			left = 0 + 'px';
			top = 0 + 'px';
			/*
			left = _left + 'px';
			top = _top + 'px';
			*/
		}

		var imgThumbnail = document.getElementById(imgThumbnailID);

		thumbnailID = imgThumbnailID;
		popupEnabled = 1;
	}

}

function CenterExhibitPopup()
{     
         
     var imgMainImage2 = document.getElementById('imgMainImage2');
     var divPopUp = document.getElementById('divpopup2');
     //divPopUp.style.marginTop = "200px";
     divPopUp.style.top = 30;
     divPopUp.style.marginLeft = (screen.availWidth - imgMainImage2.clientWidth)/2;
}

function ReplaceExhibit(str,str2)
{
     var theExhibitImage = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_MainImg");
     theExhibitImage.src = str;     
     var theName = document.getElementById("_ctl3_zenpanes_CenterPane__ctl0_txtExhibitName");          
     theName.value = str2;
    
}



function AdjustLayout()
{
     var divs = document.getElementsByTagName("div");
	var centerPane, leftPane, rightPane, x, leftinnerPane;
	
	for(i=0;i<divs.length; i++)
	{			 
 
	 if(divs[i].className=="mainmenu")
		     divmenu = divs[i];
          if(divs[i].className=="zen-cols-wrapper")
			x = divs[i];
		if (divs[i].className=="zen-col-middle")
			centerPane = divs[i];
		if (divs[i].className=="zen-col-left")
			leftPane = divs[i];
		/*if (divs[i].className=="zen-col-right")
			rightPane = divs[i];*/
	
		if(x!=null && centerPane!=null && leftPane!=null) // && rightPane!=null)
			break;		
	}

	if (leftPane.clientHeight > centerPane.clientHeight)
	{
        	 
		centerPane.style.height = leftPane.clientHeight + "px";	   
	}
	else (leftPane.clientHeight < centerPane.clientHeight)
	{         
	    leftPane.style.height =  centerPane.clientHeight - 19 + "px";	             
	}


     var theApp = navigator.appName;
     
     if(document.all && getIEVersion() < 8 || navigator.appName == "Netscape")//adjust the height of the content pane for IE6 and below
	{
		var divContentPaneLeft = document.getElementById("divContentPaneLeft");
		var divContentPaneRight = document.getElementById("divContentPaneRight");
		
		if (divContentPaneLeft != null)
		{
			if(divContentPaneLeft.clientHeight < leftPane.clientHeight)	
              {
                   		
				divContentPaneLeft.style.height = leftPane.clientHeight  + "px"; //13 is the padding top of the div
			}
		}
		if (divContentPaneRight != null)
		{
			if(divContentPaneRight.clientHeight < leftPane.clientHeight)
		     {     
				divContentPaneRight.style.height = leftPane.clientHeight + "px";
			}
			else if((divContentPaneRight.clientHeight > divContentPaneLeft.clientHeight) && (document.all && getIEVersion() < 7)) 
               {                		  
                    
			     divContentPaneLeft.style.height = divContentPaneRight.clientHeight + "px";
			     leftPane.style.height = centerPane.clientHeight + "px";	     
			}
			  
			
			try
			{
 				document.getElementById("tblImage").style.height = divContentPaneRight.style.height;
			}
 			catch(er)
			{
			
			}
		}
	}
	

     
     var image_banner = document.getElementById("image_banner");	
	
     if (image_banner != null)
	{	
		if (navigator.appName == "Netscape")			
			image_banner.style.marginTop = -13 + "px";
			
		image_banner.style.visibility = "visible";	
		
	}
	
	var image_series = document.getElementById("_ctl3_zenpanes_LeftPane__ctl0_pnlSeriesTitle");	
     if (image_series != null)
	{	
		if (navigator.appName == "Netscape")			
			image_series.style.marginTop = -5 + "px";
			
		image_series.style.visibility = "visible";	
		
	}
	
	var pnlBox = document.getElementById("_ctl3_zenpanes_LeftPane__ctl0_pnlBox");
     var divBox = 	document.getElementById("divBox");
     if (pnlBox != null && divBox !==null)
	{	
		if (navigator.appName == "Netscape")
          {	
               pnlBox.style.marginTop = -5 + "px";
               divBox.style.marginTop = -5 + "px";
			
          }				
		
		pnlBox.style.visibility = "visible";
		   
	}



	var divartist = document.getElementById("divartist");
	var headerheight = 118;
	if (divartist != null)
	{		
		divartist.style.height = leftPane.clientHeight - 74 + "px";
	}

	var footer_line = document.getElementById("tbl_footer_line");	
	
     if (footer_line != null)
	{			
		
		if (navigator.appName != "Netscape")
		{	
			footer_line.style.marginTop = leftPane.clientHeight - footer_line.offsetTop - headerheight - 65 + "px";	
			footer_line.style.visibility = "visible";	
		}
		else
		{
			footer_line.style.marginTop = leftPane.clientHeight - footer_line.offsetTop - headerheight - 72  + "px";	
			footer_line.style.visibility = "visible";		
		}
		
	}


	var footer_image = document.getElementById("footer_image");	
	if (footer_image != null)
	{			
		
		if (navigator.appName != "Netscape")
		{	
			//alert("offset =" + footer_image.offsetTop + " leftpane =" + leftPane.clientHeight);
			footer_image.style.marginTop = leftPane.clientHeight - footer_image.offsetTop  - 23 + "px";	
			footer_image.style.visibility = "visible";	
		}
		else
		{
			footer_image.style.marginTop = leftPane.clientHeight - footer_image.offsetTop  - 56 + "px";	
			footer_image.style.visibility = "visible";		
		}
		
	}

	
	var footer_line_series = document.getElementById("tbl_footer_line_series");
	if (footer_line_series != null)
	{
		if (navigator.appName != "Netscape")
		{
			footer_line_series .style.marginTop = leftPane.clientHeight - footer_line_series.offsetTop - headerheight - 60 - 38 - 5 + "px";		
			footer_line_series .style.visibility = "visible";		
		}
		else
		{
			footer_line_series .style.marginTop = leftPane.clientHeight - footer_line_series.offsetTop - headerheight - 60 - 38 - 13 + 6 + "px";	
			footer_line_series .style.visibility = "visible";			
		}
	}

  
  var menuUL = document.getElementsByTagName('li');
  if (menuUL != null)          
  {           
       
       for(j=0;j<menuUL.length; j++)
       {
		var k =  menuUL[j];   

		  
            if (k.innerHTML == '<a href=\"/DesktopModules/Admin/Logoff.aspx?tabID=0\">Logoff</a>' || k.innerHTML == '<a href=\"/DesktopModules/Admin/Logoff.aspx?tabID=0\">HEADER_LOGOFF</a>')
		     {
		          if (divmenu != null)
		          {
                      divmenu.style.display = 'block';
                     }                              		               
            }                    
	          if (k.innerText == 'Logoff' || k.innerText == 'HEADER_LOGOFF')
		     {
		          if (divmenu != null)
		             {
		               divmenu.style.display = 'block';
                        }   				         
			}
       }
  }  
  
  init();				
}

function getIEVersion()
{
	if(!document.all)
		return 0;
		
	var ua = navigator.userAgent;
	var msie = ua.indexOf("MSIE");
	
	return parseFloat(ua.substring(msie+5, ua.indexOf(";", msie)));
}

window.onload = AdjustLayout; 
