	// Apply the Highslide settings
	hs.graphicsDir = 'highslide/graphics/';
	hs.outlineType = 'rounded-white';
	hs.showCredits = false;
	hs.fadeInOut = true;
	
	// Close button
	hs.registerOverlay({
		html: '<div class="closebutton" onclick="return hs.close(this)" title="Close"></div>',
		position: 'top right',
		slideshowGroup: 'single-image',
		fade: 2 // fading the semi-transparent overlay looks bad in IE
		useOnHtml: true
	});
	
	// Add the slideshow controller
	hs.addSlideshow({
		slideshowGroup: ['group1', 'group2'],
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: false,
		overlayOptions: {
			className: 'controls-in-heading',
			opacity: '0.75',
			position: 'top right',
			offsetX: 1,
			offsetY: -3,
			hideOnMouseOut: false
		}
	});
	
// create a shorthand function so we don't need to put all this in the opener's onclick
function openYouTube(opener) {
   var returnValue;
   var bURL=opener.toString();
         
   // Safari Mobile doesn't have Flash, so we just let the device use the built-in
   // YouTube viewer.
	if (/(iPhone|iPod|iPad)/.test(navigator.userAgent)) {
		opener.href = opener.href.replace('/v/', '/watch?v=');
		returnValue = true;		
	}
 
   else{
      
      var myURL=opener.toString(); 
      var myflashvars="";
      var VID = myURL.substring(29,36);
      var ID = myURL.substring(37);
      var parm = "id=" + ID + "&vid=" + VID + "&autoplay=1";
      
      if(myURL.match(/youtube\.com/)){myURL=opener.href.replace("watch?", "").replace("=", "/")}
	  
      if(myURL.match(/video\.yahoo\.com/)){
             myURL="http://d.yimg.com/static.video.yahoo.com/yep/YV_YEP.swf";
	     myflashvars={ id: '&id=' + ID + '&vid=' + VID + '&autoplay=1'};
	     //hs.swfOptions.flashvars.id = parm;
      }
      
      returnValue = hs.htmlExpand(opener, {
         objectType: 'swf',
         headingEval: 'this.a.title',
         objectWidth: 425, //480
         objectHeight: 355, //385
         width: 425,
         wrapperClassName: 'draggable-header no-footer',
         allowSizeReduction: false,
         // always use this with flash, else the movie will be stopped on close:
         preserveContent: false,
         swfOptions: {
            params: {
               allowfullscreen: true,
               allowscriptaccess:"always",
               type:"application/x-shockwave-flash",
               wmode:"opaque",
               menu:true,
               bgcolor:"#ffffff"
               //src: myURL
            },
            flashvars:myflashvars
         },
         maincontentText: 'You need to upgrade your Flash player',
         src: myURL
      });
      return returnValue;
   }
};
 
hs.onSetClickEvent = function ( sender, e ) {
// set the onclick for the element
if (e.type == 'image') {e.element.onclick = function () {
	return hs.expand(this, {slideshowGroup: this.parentNode.className, headingEval: 'this.a.title', captionEval: 'this.thumb.alt', align: 'center', transitions: ['expand', 'crossfade']});
	}
}
else if (e.type == 'swf') {e.element.onclick = function (){
	return openYouTube(this);
	}
}
// return false to prevent the onclick being set once again
return false;
};
