//initialise Facebox elements
 $(document).ready(function() {
   $('a[rel*=facebox]').facebox()
 })


 $('a[rel*=fbox]').click(function(e){

   jQuery.facebox({ ajax: '/net-visionary/gallery/?id='+e.id });
   return false

 });


 $('a[rel*=fboxfull]').click(function(e){
   var val = e.id;
   val = val.substring(1);
   jQuery.facebox({ ajax: '/net-visionary/gallery/?id='+e.id });
   return false

 });

 $('a[rel*=mgal]').click(function(e){

   var source = e.attr('href');
   var mid = e.id
   var mtitle = e.title ;
   $('#mainimg').html('<a href="/net-visionary/gallery/?fbox='+mid+'" rel="facebox" title="view large version" id="'+mid+'"><img src="'+source+'" alt="'+mtitle+'" /></a>');
   $('#enlargecontainer').html('<a href="/net-visionary/gallery/?fbox='+mid+'" rel="facebox" title="view large version" id="z'+mid+'" >Enlarge</a>');
   $('#mainimgtext').html('<strong>'+mtitle+'</strong>');
   return false;
 });


 function showMedium(nId) {
   var source = aImages[nId]['medium'];
   var mid = 'm' + nId
   var mid = mid.substring(1);
   var mtitle = aImages[nId]['title'] ;
   var msummary = aImages[nId]['summary'] ;

   $('#mainimg').html('<a href="/net-visionary/gallery/?fbox='+mid+'" onclick="forcefacebox(this);return false;" rel="facebox" title="view large version" id="'+mid+'"><img src="'+source+'" alt="'+mtitle+'" /></a>');
   $('#enlargecontainer').html('<a href="/net-visionary/gallery/?fbox='+mid+'" rel="facebox"  onclick="forcefacebox(this);return false;" title="view large version" >Enlarge</a>');
   $('#mainimgtext').html('<h3>'+mtitle+'</h3>'+'<p>'+msummary+'</p>');
   return false;
 }


 function forcefacebox(e) {
   $.facebox({ajax:e.href});
   return false;
 }
