

   // This function returns Internet Explorer's major version number,
   // or 0 for others. It works by finding the "MSIE " string and
   // extracting the version number following the space, up to the decimal
   // point, ignoring the minor version number

function msieversion()
   {
      var ua = window.navigator.userAgent
      var msie = ua.indexOf ( "MSIE " )

      if ( msie > 0 )      // If Internet Explorer, return version number
         return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )));
      else                 // If another browser, return 0
         return 0 ;         

   }

hs.Expander.prototype.onMouseOut = function (sender) {          // close popup when moving mouse outside of it
  if (this.custom.closeIt == 'yes') {
      sender.close();
  }
}



hs.Expander.prototype.onMouseOver = function () {              // shift focus on the popup when positioning cursor over it
  if (this.custom.focusIt == 'yes') { 
      this.focus();
  }
}

hs.Expander.prototype.onBeforeExpand = function (sender, e) {            // before expanding a child popup, close the parent window popup if present
  
 if (this.custom.closeParent == 'yes') {    // close parent window?
    parent.window.hs.close(); 
  
 }
 
}

//hs.Expander.prototype.onInit = function (sender) {

//  if (msieversion() > 0 && msieversion() <= 6)   // for IE browser version
//  {
//   this.outlineType = 'rounded-white';   
//  }
// }

hs.Expander.prototype.onAfterExpand = function (sender, e) {            // displaying an overlay name at the top of the popup when event is triggered
  
// this function will display product code in the expander
// overlay IF displayName is turned on for that expander 
 
   

 if (this.custom.displayName == 'yes' || this.custom.displayName == 'photogallery') {      // display name in overlay of image?
 
  
   // assign the offset based on browser type (other browsers have problems handling padding)
   // ***FPV 2/9/2011 -- removed padding: 10px from the highslide-overlay css definition in hslide.css and embedded below in overlay
   
 	if (msieversion() > 0 && msieversion() <= 10)   // for IE browser version
  	{
    	var offsetOverlay = 0;
 	}
 	 else
 	{
   	 var offsetOverlay = 30;    //  all other browsers, double the padding set below to create the offset
	 }
 
 
 	if (this.custom.displayName == 'yes')  {  // set the opacity for the overlay, with photogallery images being darker.
 	   var opacityOverlay = .8 ;
 	} else {
   	   var opacityOverlay = .9 ;
 	}

   // create a new DOM element
   var divOverlay = document.createElement('div');

   // add a class name to allow CSS styling
   divOverlay.className = "highslide-overlay";

   // use the thumbnail's alt attribute as inner HTML; center in the overlay
   divOverlay.innerHTML = '<p style="margin-top: auto; margin-bottom: auto;">' + sender.thumb.alt + '</p>' ;

   // optional: set full width based on the image size minus the CSS padding
   divOverlay.style.width = (sender.x.span - offsetOverlay) +'px';
   divOverlay.style.padding = '15px';
     
   
   // attatch it to this hs.Expander instance and add some options
   sender.createOverlay( { overlayId: divOverlay, position: "bottom left", 
      hideOnMouseOut: true, opacity: opacityOverlay } );
  }
 
}

hs.Expander.prototype.onBeforeExpand = function (sender, e) {

   // create a new DOM element
   var divClose = document.createElement('div');
   
   // add a class name to allow CSS styling
   divClose.className = "highslide-overlayClose";
   
   if (this.custom.displayName == 'yes' || this.custom.displayName == 'photogallery') { 
      var closeImg = '<img src="highslide/graphics/close.png" style="position: absolute; top: -35; right: -35; border:0;text-decoration:none;"></a>';     
   } else {
      var closeImg = '<img src="highslide/graphics/close.png" style="position: absolute; top: -25; right: -25; border:0;text-decoration:none;"></a>';     
   }   
   
   // use the thumbnail's alt attribute as inner HTML
   divClose.innerHTML = '<a href="#" onclick="return hs.close(this);">' + closeImg ;
		 ;

   // attatch it to this hs.Expander instance and add some options
   sender.createOverlay( { overlayId: divClose, position: "top right", 
      hideOnMouseOut: false, opacity: 1,  width: '100%' } );
}


////////////// iframe popup handler 

function iframePopup(anchr, pos, wdth, close, disp, foc ) {
	if (wdth == null) wdth = 800;
	if (foc == null) foc = "yes";
	hs.htmlExpand(anchr, { objectType: 'iframe', width: wdth, preserveContent: 'false',   contentId: 'iframe-content' }, { closeParent: close, displayName: disp, focusIt: foc }  );       
	return false;   
}


///////////////  ajax popup handler


function ajaxPopup(anchr, pos, wdth, close, disp, foc ) {
        if (wdth == null) wdth = 650;
        if (foc == null) foc = "yes";
		hs.htmlExpand(anchr, {objectType: 'ajax', width: wdth, align: pos, contentId: 'ajax-content' }, { closeParent: close, displayName: disp, focusIt: foc }  );       
		return false;   
}

