/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
	
	Table of Contents
	-----------------
	Configuration
	
	Functions
	- getPageScroll()
	- getPageSize()
	- pause()
	- showOverlayBox()
	- hideOverlayBox()
	- initOverlayBox()
	- addLoadEvent()
	
	Function Calls
	- addLoadEvent(initOverlayBox)

*/


//
// Configuration
//

// If you would like to use a custom loading image or close button reference them in the next two lines.
var loadingImage = 'images/loading.gif';
var closeButton = 'images/close.gif';



//=======================================================================================================================
// Overlay global variables
var dsCurrentAssetInfo; //Info of the asset being displayed. (dsInfo class object)

//=======================================================================================================================
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//=======================================================================================================================
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//=======================================================================================================================
//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
//
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}


//=======================================================================================================================
//
// showOverlayBox()
// Ajax to get file info, preloads images.
// Pleaces new image in overlay then centers and displays.
//
var OverlayLastCall = ''
var tObj

function showOverlayBox(objLink)
{

  tObj = objLink

  OverlayLastCall = Math.round(Math.random()* 10000)

  strUrl  = "ajax/home_overlay.php";
  strUrl += "?unid=" + OverlayLastCall ;                     // To avoid incorrect callback interpretation
  strUrl += "&func=getDetails"
  strUrl += "&assetid=" + escape(objLink.dsID) ;
  
  ajaxag(strUrl, showOverlayBoxCB);

}

var ShowPrevNextLinks = false;

function showOverlayBoxCB()
{

  var MainPicPath = "";


 if (xmlData.readyState==4)
  { if (xmlData.status==200)
    {

      objLink = tObj

	//Check if have to show prev/next links
	if(objLink.origin && (objLink.origin=="search")){
		CurrentDisplayingPage = objLink.parentNode.parentNode.pageNr; 
		CurrentDisplayingRes = objLink.parentNode.parentNode.resNr;
		ShowPrevNextLinks = true;
		MakeNextPrevVisible();
	}
	else{
		ShowPrevNextLinks = false;
		MakeNextPrevInvisible();
	}
		
	
      ResultArray = xmlData.responseText.split("\n")

      if(ResultArray[0]==OverlayLastCall)  //Check ajax response is correct
      {


        var objThumbs = document.getElementById('divThumbs')
        EmptyDiv(objThumbs)

        var objKW = document.getElementById('overlayboxKeyWords')
        EmptyDiv(objKW)

	var StrInfo = "";
	var StrFiles = "";
	var StrLongDesc = "";
	var StrShortDesc = "";
	var PreviewFile = "";
	var OverlayThumbProportion = 0.75;
	
	ZoomPath ="";
	
        for(i=1, imax=ResultArray.length;i<imax;i++)
        {
          ResultItem = ResultArray[i].split("|")

          //Add Files to be displayed
          if(ResultItem[0]=="OL_PIC")
          {
            imgTemp = document.createElement("img");
            imgTemp.src = "/userfiles/thumbs/" + ResultItem[2];
            imgTemp.dsPicFileName = "/userfiles/pictures/" + ResultItem[1];
	    
            imgTemp.onclick = showPic;  

            if (imgTemp.width != 0) {
              imgTemp.width = OverlayThumbProportion * imgTemp.width;
              imgTemp.height = OverlayThumbProportion * imgTemp.height;
            } else { // Firefox, while loading the image, has a width of 0. Change size in Onload
              imgTemp.onload = function() {
                this.width = OverlayThumbProportion * this.width; // At this point, changing only this resizes it proportionally
              };
            }

            objThumbs.appendChild(imgTemp);

          }


          //Main picture path
          if(ResultItem[0]=="OL_MAIN_PIC")
          { MainPicPath = ResultItem[1]; }


          if(ResultItem[0]=="OL_KW")
          { 
					 	//objKW.innerHTML = "<h3>Keywords: </h3> " + ResultItem[1] ;
					 	var KeywordsH3 = document.createElement("h3");
					 	var spanKeyword;
					 	
					 	KeywordsH3.innerHTML = "Keywords:";
					 	objKW.appendChild(KeywordsH3);
					 	
					 	$arKeywords = ResultItem[1].split(" ");
					 	for (k = 0; k<$arKeywords.length; k++) {
					 	  spanKeyword = document.createElement("span");
					 	  spanKeyword.onclick = function() { return ShowKeywordResults(this); };
					 	  spanKeyword.Keyword = $arKeywords[k];
					 	  spanKeyword.appendChild(document.createTextNode($arKeywords[k]));
					 	  objKW.appendChild(spanKeyword);
					 	 	objKW.appendChild(document.createTextNode(" "));
					 	}
					
					}
          
          if(ResultItem[0]=="OL_FILE")
		        //FileName	       //FileType                //Filesize
          { StrFiles += "<li>" + ResultItem[1] + " - " + ResultItem[2] + " - " + ResultItem[3] + "</li>"; }

          if(ResultItem[0]=="OL_INFO")
          { StrInfo += ResultItem[1] + ": " + ResultItem[2] + "<br>"; }
	  
      	  if(ResultItem[0]=="OL_OWNER")
      	  { 
					 	document.getElementById('lblAuthor').innerHTML = "by " + ResultItem[1]; 
					 	// Daniel Magliola: 2007-04-20: Set the ScreenName property for the H2@lblAuthor, to be able to search by uploader
					 	document.getElementById('lblAuthor').ScreenName = ResultItem[1];
					}

      	  if(ResultItem[0]=="OL_TITLE")
      	  { document.getElementById('lblTitle').innerHTML = ResultItem[1];  }

      	  if(ResultItem[0]=="OL_SHORT_DESC")
      	  { StrShortDesc = ResultItem[1]; }

      	  if(ResultItem[0]=="OL_LONG_DESC")
      	  { if (ResultItem[1] != "") { StrLongDesc = "<h3>Notes:</h3> " + ResultItem[1]; }}

      	  if(ResultItem[0]=="OL_PREVIEW_FILE")
      	  { PreviewFile = ResultItem[1]; }

      	  if(ResultItem[0]=="OL_ZOOM")
      	  { ZoomPath = ResultItem[1]; }

        }

	document.getElementById('textGeneralData').innerHTML = StrInfo;
	document.getElementById('txtLongDesc').innerHTML = StrLongDesc;
	document.getElementById('txtShortDesc').innerHTML = StrShortDesc;
	
	if(StrFiles != "")
	{
	  document.getElementById('txtFiles').style.display = "block";
	  document.getElementById('txtFiles').innerHTML = "<h3>Files:</h3> <ul>" + StrFiles + "</ul>" ;
	}
	else
	{ document.getElementById('txtFiles').style.display = "none";}

	document.getElementById('assetIcon').src = "/images/searchresult_type_" + tObj.dsType + ".gif";

	document.getElementById('overlayboxImage').style.display = 'block';
	document.getElementById('ZoomerFlashContainer').style.display = 'none';
	document.getElementById('PlayerFlashContainer').style.display = 'none';


	//Players
	if(PreviewFile!="")
	{
/*    if (tObj.dsType == "VI") {

  	  imgTemp = document.createElement("img")
            imgTemp.src = "images/overlay_movie_thumb.gif"
            imgTemp.dsPreviewFile = PreviewFile;
            imgTemp.dsType = tObj.dsType;

            imgTemp.onclick = showPreview;
            objThumbs.appendChild(imgTemp)
    }*/
    showPreviewFile(PreviewFile, "userfiles/pictures/" + MainPicPath, tObj.dsType);
    
	  //ShowPlayer
	  //AddImageToShowPlayer
	}
	
	if(ZoomPath!="") {
    document.getElementById('aDetailsZoom').style.display = "block";
    document.getElementById('aDetailsCloseZoom').style.display = "none";
	} else 	{
    document.getElementById('aDetailsZoom').style.display = "none";
    document.getElementById('aDetailsCloseZoom').style.display = "none";
  }



	// prep objects
      	var objOverlay = document.getElementById('overlaybg');
      	var objOverlayBox = document.getElementById('overlaybox');
      	var objCaption = document.getElementById('overlayboxCaption');
      	var objImage = document.getElementById('overlayboxImage');
      	var objLoadingImage = document.getElementById('loadingImage');
      	

      	var arrayPageSize = getPageSize();
      	var arrayPageScroll = getPageScroll();

      	// center loadingImage if it exists

      	if (objLoadingImage) {
      		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
      		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
      		objLoadingImage.style.display = 'block';
      	}

      	// set height of Overlay to take up whole page and show
      	objOverlay.style.width = (arrayPageSize[0] + 'px');
//      	objOverlay.style.height = ((arrayPageSize[1]) + 'px');

      	objOverlay.style.display = 'block';

      	// preload image
      	imgPreload = new Image();

      	/* Set info attributes */
        imgPreload.dsPicFileName = "userfiles/pictures/" + MainPicPath;


        /****************************************************************************/
        /*  The (img).onload function takes place when the image has been completely downloaded
            This should be modified, not to be displayed until ALL the information has been retrieved.
            "ALL the information" means the fields that are going to be queried to the database.
        */
      	imgPreload.onload=function()
        {

          if (!isSafari()) {
        		objImage.src = this.dsPicFileName;  // when arrived here, the image is already on caché
          } else {
            // for some reason, Safari reports this.src and this.dsPicFileName to be undefined.
            // This, however, works well.
            objImage.src = "userfiles/pictures/" + MainPicPath 
          }

      		// center overlaybox and make sure that the top and left values are not negative
      		// and the image placed outside the viewport
      		var overlayboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - imgPreload.height) / 2) - 60 ;
      		var overlayboxLeft = ((arrayPageSize[0] - 20 - imgPreload.width) / 2);

      		objOverlayBox.style.top = (overlayboxTop < 40) ? "40px" : overlayboxTop + "px"; //@@@@ Correct positioning
      		objOverlayBox.style.left = (overlayboxLeft < 0) ? "0px" : overlayboxLeft - 140 + "px";


      		//objoverlayboxDetails.style.width = imgPreload.width + 'px';


      		// A small pause between the image loading and displaying is required with IE,
      		// this prevents the previous image displaying for a short burst causing flicker.
      		if (navigator.appVersion.indexOf("MSIE")!=-1){
      			pause(250);
      		}

          /* Hides loading image */
      		if (objLoadingImage)
          {
             objLoadingImage.style.display = 'none';
          }

      		// Hide select boxes as they will 'peek' through the image in IE
      		// except select is detailsligthboxselect.
      		selects = document.getElementsByTagName("select");
              for (i = 0; i != selects.length; i++) {
                      selects[i].style.visibility = "hidden";

              }


          //DM: When you layer a div on top of something with overflow: auto, weird things happen to display
          //       and to the mouse cursor in the zooming tool. So we remove the overflow: auto when showing the div,
          //       and add it back when hiding it.
          FixWeirdOverflowProblem(true);
          
      		objOverlayBox.style.display = 'block';

      		// After image is loaded, update the overlay height as the new image might have
      		// increased the overall page height.
      		arrayPageSize = getPageSize();
      		objOverlay.style.height = (arrayPageSize[1] + 'px');

      		return false;
      	}

        //Store info for add to shopping cart and lightbox
        dsCurrentAssetInfo = new dsInfoClass(objLink.dsID, objLink.dsType, objLink.title, objLink.src, objLink.dsPicFileName, objLink.dsShortDesc, objLink.dsLongDesc);
        document.getElementById('aDetailsAddToSC').dsInfo = dsCurrentAssetInfo;

      	imgPreload.src =  imgPreload.dsPicFileName;


        // If an administrator is logged on, allow him to edit the asset.
        if (document.getElementById('AdminEditAssetLink')) {
          document.getElementById('AdminEditAssetLink').href = 'assetedit.php?assetID=' + objLink.dsID;
        }
        
        /****************************************************************************/

				// Show in Zoom mode as default
				if(ZoomPath!="") {
					aDetailsZoom_click();
				}
				
      }



    }
  }
}


//=======================================================================================================================
// DoingPrevNext indicates whether the user pressed prev/next in the detail overlay.
// If true, the semi-transparent grey background is not hidden
function hideOverlayBox(DoingPrevNext)
{
	// get objects
	objOverlay = document.getElementById('overlaybg');
	objOverlayBox = document.getElementById('overlaybox');

  //DM: When you layer a div on top of something with overflow: auto, weird things happen to display
  //       and to the mouse cursor in the zooming tool. So we remove the overflow: auto when showing the div,
  //       and add it back when hiding it.
  FixWeirdOverflowProblem(false);


	// hide overlaybox and overlay
	if (!DoingPrevNext) {
  	objOverlay.style.display = 'none';
  }
  
	objOverlayBox.style.display = 'none';

	// make select boxes visible
  if (!DoingPrevNext) {
  	selects = document.getElementsByTagName("select");
      for (i = 0; i != selects.length; i++) {
  		selects[i].style.visibility = "visible";
  	}
  }

  //clear data fields

  HideDetailsAddToLB();


}

//=======================================================================================================================
//DM: When you layer a div on top of something with overflow: auto, weird things happen to display
//       and to the mouse cursor in the zooming tool. So we remove the overflow: auto when showing the div,
//       and add it back when hiding it.
//
//  If showing == true, removes overflow: auto. If false, sets it back.
function FixWeirdOverflowProblem(showing) {

	objLightboxContainer = document.getElementById('lightboxcontainer');
	objSCContainer = document.getElementById('shoppingcartcontainer');

  if (showing) {
    //LB
    objLightboxContainer.style.overflow = 'hidden';
    objLightboxContainer.style.overflowY = 'hidden';

    objSCContainer.style.overflow = 'hidden';

  } else {

    //LB
    objLightboxContainer.style.overflow = 'hidden';
    objLightboxContainer.style.overflowY = 'scroll';

    try {
      objLightboxContainer.style.overflow = '-moz-scrollbars-vertical';
    }catch(err) { }

    objSCContainer.style.overflow = 'auto';

  }

}

//=======================================================================================================================
//
// initOverlayBox()
// The function inserts html markup at the top of the page which will be used as a
// container for the overlay pattern and the inline image.
//
function initOverlayBox()
{
	
	var objBody = document.getElementsByTagName("body").item(0);

  var objOverlay = document.getElementById('overlaybg')
	objOverlay.onclick = function () {hideOverlayBox(); return false;}
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

  /*********************************************************************************************************/
  /*  If there is a "loading" image to display, when its "src" attibute is set to something (not to an empty
      string), an anchor containing the loading image and the loadingimage are created.
      These objects are not created if there is no "loading" image to display.
      
      The objective of this code is to preload de "loading" image.
      The "loading" image is the one displayed during the retrievment of the content that will be shown finally.
      There's an anchor created, which is going to contain the "loading" image, in order to capture the onclick event.
      Capturing the click event this way, gives you the "changüí" of having the mousepointer set to a hand when the
      mouse is over the image.
      By preloading the image, it's ensured that displaying it will be instantaneous.

  */
	// preload and create loader image
	var imgPreloader = new Image();
	
	// if loader image found, create link to hide overlaybox and create loadingimage
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideOverlayBox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

		return false;
	}

  /* if lading image is a path, the */
	imgPreloader.src = loadingImage;
  /*********************************************************************************************************/


  var objOverlayBox = document.getElementById("overlaybox")
  objOverlayBox.style.position = 'absolute';
  objOverlayBox.style.display = 'none';
  objOverlayBox.style.zIndex = '100';


  

//  var objCaption = document.getElementById('overlayboxCaption')
// 	objCaption.style.display = 'none';



}


//-------------------------------------------------------------------------------------------------------------------
// Adds item to shopping cart
function aDetailsAddToSC_click()
{
  DisableSplashMode();
  hideOverlayBox();
  ShoppingCartDrop(document.getElementById('aDetailsAddToSC').dsInfo); 
}


//-------------------------------------------------------------------------------------------------------------------
// Display box to select to which lb asset should be added
function aDetailsAddToLB_click(e)
{
  if(LoggedOrAssumed)
  {
    //Positioning

  	var posx = 0;
  	var posy = 0;
  	if (!e) var e = window.event;
  	if (e.pageX || e.pageY)
  	{
  		posx = e.pageX;
  		posy = e.pageY;
  	}
  	else if (e.clientX || e.clientY)
  	{
  		posx = e.clientX + document.body.scrollLeft;
  		posy = e.clientY + document.body.scrollTop;
  	}
  	// posx and posy contain the mouse position relative to the document

    document.getElementById('overlayLBSelect').style.top = posy  - 20 + 'px';
    document.getElementById('overlayLBSelect').style.left = posx - 50 + 'px' ;

    ShowDetailsAddToLB();

    }
  else
  { alert('You must Log In to use the Lightbox.'); }
}

//-------------------------------------------------------------------------------------------------------------------
// Ajax to add asset to lb
var ovLBNum; //LB id, global for callback
function aDetailsAddToLBOK_click()
{

// get lightboxid to add to

  var ovLBSelect = document.getElementById('detailsligthboxselect')

  for(i=0,imax=ovLBSelect.childNodes.length;i<imax;i++)
  {
    if(ovLBSelect.childNodes[i].selected)
    { ovLBNum=ovLBSelect.childNodes[i].dslbNum;  }
  }


    strUrl  = "ajax/home_lightbox.php";
    strUrl += "?unid=" + Math.round(Math.random()* 10000) ;       /* Hard way to avoid caching */
    strUrl += "&func=lbAddItem" ;                                    /* Call to lbContent */
    strUrl += "&lbnum=" + escape(ovLBNum) ;               /* lbID */
    strUrl += "&assetId=" + escape(dsCurrentAssetInfo.dsID) ;               /* AssetId */

    ajaxag(strUrl, aDetailsAddToLBOK_clickCB);


}

function aDetailsAddToLBOK_clickCB() //Callback
{
 if (xmlData.readyState==4)
  { if (xmlData.status==200)
    {

      if(xmlData.responseText == "LB_ADD_ITEM_OK")  // Case OK
      {
        if(CurrentLightBoxId==ovLBNum)
        {  
	
		// Remove the "drop media here" legend
	        if(document.getElementById('lightboxcontainer').childNodes.length == 1)
        	{
	          if(document.getElementById('lightboxcontainer').childNodes[0].IsLegend)
        	  {
	            EmptyDiv(document.getElementById('lightboxcontainer'));
        	  }
	        }

		AddAssetToLb(dsCurrentAssetInfo.dsID, dsCurrentAssetInfo.dsType, dsCurrentAssetInfo.title, dsCurrentAssetInfo.src, dsCurrentAssetInfo.dsPicFileName, dsCurrentAssetInfo.dsShortDesc, dsCurrentAssetInfo.dsLongDesc, '10'  ); 

	}
        hideOverlayBox();
      }

      if(xmlData.responseText == "LB_ADD_ITEM_DUPLICATE")  // Case asset already is on lb.
      {
        alert("You already have that media in the specified Lightbox");
      }

    }
  }
}





//-------------------------------------------------------------------------------------------------------------------
// Hide lb selection box
function aDetailsAddToLBCancel_click()
{
  HideDetailsAddToLB()
}


//-------------------------------------------------------------------------------------------------------------------
function ShowDetailsAddToLB()
{
  document.getElementById('overlayLBSelect').style.zIndex = '350';
  document.getElementById('overlayLBSelect').style.visibility = "visible";
  document.getElementById('detailsligthboxselect').style.visibility = "visible";
}

//-------------------------------------------------------------------------------------------------------------------
function HideDetailsAddToLB()
{
  document.getElementById('overlayLBSelect').style.visibility = "hidden";
  document.getElementById('detailsligthboxselect').style.visibility = "hidden";
}

function showPic()
{
  document.getElementById('overlayboxImage').style.display = 'block';
  document.getElementById('PlayerFlashContainer').style.display = 'none'; 
  document.getElementById('ZoomerFlashContainer').style.display = 'none';

  EmptyDiv(document.getElementById('ZoomerFlashContainer')); // Stop flash if playing.
  document.getElementById('overlayboxImage').src = this.dsPicFileName;
  
  document.getElementById('PlayerFlashContainer').style.display = 'none';
  document.getElementById('overlayboxImage').style.display = 'block';

}


function showPreview() {
  showPreviewFile(this.dsPreviewFile, "", this.dsType);
}

function showPreviewFile(Path, PathImage, AssetType)
{

  if (AssetType == "FL") {
    var so = new SWFObject(Path, "MovieFlash", "400", "400", "7");
  } else {
    if (AssetType == "VI") {
      var so = new SWFObject("movieplayer.swf", "MovieFlash", "400", "400", "7");
      so.addParam("wmode", "transparent");
      so.addVariable("file", Path );
    } else {
      var so = new SWFObject("mp3player.swf", "MovieFlash", "400", "400", "7");
      so.addParam("wmode", "transparent");
      so.addVariable("file", Path );
      so.addVariable("imagen", PathImage );
      so.addVariable("ruido", "/noise.mp3" );
    }
  }



  so.write("PlayerFlashContainer");
  document.getElementById('PlayerFlashContainer').style.display = 'block';
  document.getElementById('overlayboxImage').style.display = 'none';

}


var ZoomPath = "";
var ZoomInstance = 0;
function aDetailsZoom_click(e)
{

  ZoomInstance += 1;

  if(ZoomPath!="")
  {
    document.getElementById('overlayboxImage').style.display = 'none';

    FlashViewer = new SWFObject("zoomifyViewer.swf?zoomifyImagePath=/userfiles/zoompictures/" + ZoomPath + "&zoomifyNavWindow=0", "ZoomerFlash"  + ZoomInstance,  "400", "400", "7");
    FlashViewer.addParam("wmode", "transparent");
    FlashViewer.addParam("menu", "false");

    //DM: Removed these variables because it doesn't work in IE 6 (because of a bug in IE6)
    //      Instead of passing variables through FlashVars, i'm sending them directly in the path to the .swf object
  //  FlashViewer.addVariable("zoomifyImagePath", "/userfiles/zoompictures/" + ZoomPath);
  //  FlashViewer.addVariable("zoomifyNavWindow", "0");

    // DM: IE6 is doing something VERY weird with this code, where new params appear, and one of them is breaking the code.
    // I'm using the same code that swfobject uses to detect IE, and if it's found, i'll output the code myself.
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
      FlashViewer.write("ZoomerFlashContainer");
    } else {
      document.getElementById('ZoomerFlashContainer').innerHTML = '<OBJECT id=ZoomerFlash height=400 width=400 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000> <PARAM NAME="Movie" VALUE="zoomifyViewer.swf?zoomifyImagePath=/userfiles/zoompictures/' + ZoomPath + '&amp;zoomifyNavWindow=0"> <PARAM NAME="wmode" VALUE="transparent"> <PARAM NAME="Menu" VALUE="0"> <PARAM NAME="DeviceFont" VALUE="0"> </OBJECT>';
    }
    document.getElementById('ZoomerFlashContainer').style.display = 'block';

		// Now that we're zooming as a default, we don't show the "close zoom" element anymore
    //document.getElementById('aDetailsCloseZoom').style.display = 'block';
    document.getElementById('aDetailsZoom').style.display = 'none';


		document.getElementById('spanZoomExplanation').style.display = 'block';
  }
}

function aDetailsCloseZoom_click()
{
EmptyDiv(document.getElementById('ZoomerFlashContainer'));
document.getElementById('ZoomerFlashContainer').style.display = 'none';
document.getElementById('overlayboxImage').style.display = 'block';

document.getElementById('aDetailsCloseZoom').style.display = 'none';
document.getElementById('aDetailsZoom').style.display = 'block';

}

// Daniel Magliola: 2007-04-20: Allow searching by uploader.
// On index.php the h2#lblAuthor was modified to have  onclick="return ShowUserAssets(this);"
// Also, on setting the innerHTML of lblAuthor, we also create the ScreenName property and set it to it.
function ShowUserAssets(ClickedObj) {
	hideOverlayBox();
	document.getElementById('searchtext').value = "user: " + ClickedObj.ScreenName;
	btnSearch_Click();
}

// Daniel Magliola: 2007-04-20: Allow searching by clicking on a keyword.
// On index.php the h2#lblAuthor was modified to have  onclick="return ShowUserAssets(this);"
// Also, on setting the innerHTML of lblAuthor, we also create the ScreenName property and set it to it.
function ShowKeywordResults(ClickedObj) {
	hideOverlayBox();
	document.getElementById('searchtext').value = ClickedObj.Keyword;
	btnSearch_Click();
}
