var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var image_source;
var baseImageDir;
var altTag;
var joinAltTag;
var comments;

function displayphoto(imagedir, img_src, wdth, hght, hText, alt, cmts)
{
  if(hght == null)
    hght = 500;
  
  if(wdth == null)
    wdth = 750;
      
  baseImageDir = imagedir;
  image_source = img_src;
  altTag = alt;
  joinAltTag = altTag.replace(/ /g, "_");
  comments = cmts;

	if(navigator.appVersion.indexOf("MSIE 6.0") > 0)
  {
    window.open("/scripts/ie6image.html?" + baseImageDir + "_" + image_source + "_" + joinAltTag, "" , "width=" + (wdth + 40) + ",height=" + (hght + 40) + ",scrollbars=no,toolbar=no,location=no,menubar=no,status=no,");
    
  }
  else
  {

    if(hText == null)
      hText = "";

  	myHeight = document.getElementById('IEInnerHeightHack').clientHeight;
  
  	var bg = document.createElement("div");
  
	  bg.style.position = "fixed";
  	  bg.style.height = "100%";
	  bg.style.width = "100%";

  	bg.id = "bg";
  	bg.style.left = "0px";
  	bg.style.top = "0px";
  	bg.style.zindex=100;
  	bg.style.background = "black";
  	
  	if (is_ie)
  	{
  		bg.style.filter = 'alpha(opacity=50)';
  	}
  	else
  	{
  		bg.style.opacity = 0.5;
  	}
  	
  	document.body.appendChild(bg);
  	
  	var x = ((document.body.clientWidth/2) < (wdth / 2))?(0):((document.body.clientWidth/2)-(wdth / 2));
  	var y = ((myHeight / 2) < (hght / 2) ?(0) : ((myHeight/2) - (hght / 2) - 50));
  	
  	var container = document.createElement("div");
  	container.style.position = "fixed";
  	container.style.left = x + "px";
  	container.style.top = y + "px";
  	container.style.width = wdth + "px";
  	container.style.height = (hght + 125) + "px";
  	container.style.border = "1px solid black";
  	container.style.background = "#dddddd";
  	container.style.textAlign = "right";
  	container.style.zIndex = "3";
  	container.id = "previewContainer";
  	container.innerHTML = '<div style="text-align:left;float:left;padding-left:5px;padding-top:3px;font-family:\'trebuchet ms\';font-size:13px;">' + hText + '</div>';
  	
  	var closeButton = document.createElement("button");
  	closeButton.innerHTML = "Close";
  	closeButton.style.height = "25px";
  	closeButton.onclick = function()
  	{
  		closeView();
  	}
  	container.appendChild(closeButton);
  	
  	var photo = document.createElement("iframe");
  	photo.style.width = wdth + "px";
  	photo.style.height = hght + "px";
  	photo.style.border = "1px solid black";
  	photo.style.padding = "0px";
  	photo.scrolling="no";
  	photo.src = "/scripts/image.html";
  	container.appendChild(photo);
  	
  	var commentDiv = document.createElement("div");
  	commentDiv.style.width = wdth - 20 + "px";
  	commentDiv.style.height = "100px";
  	commentDiv.style.border = "0px";
  	commentDiv.style.padding = "0px";
  	commentDiv.style.textAlign = "left";
  	commentDiv.style.marginLeft = "10px";
  	commentDiv.style.marginRight = "10px";
  	commentDiv.innerHTML = "<p>" + comments + "</p>";
  	container.appendChild(commentDiv);
  	
  	document.body.appendChild(container);
  }
}

function closeView()
{
	var container = document.getElementById('previewContainer');
	document.body.removeChild(container);
	
	var bg = document.getElementById('bg');
	document.body.removeChild(bg);
}