function videopop(url,w,h) {
  newwindow=window.open(url,'name','location=0,menubar=0,status=0,scrollbars=0,height='+h+',width='+w);
  if (window.focus) {newwindow.focus()}
  return false;
}

$(function(){
 
if (Modernizr.input.placeholder) {
} else {
  $('label.placeholder').css('display','block');
}


$('#homeslideshow,.smallslides, .articleslides').cycle({ 

    speed: 2000, 
    timeout: 4500, 
    pager:  '#counter',
    pause:   0 
});

$('#exhibitionslides').cycle({ 
    speed:  'slow', 
    timeout: 2500, 
    pager:  '#exhibitionpager', 
    pagerAnchorBuilder: function(idx, slide) { 
         if($.browser.msie&&$.browser.version<9)  {
          return '<a href="#"><img src="' + slide.firstChild.src + '"  height="50" /></a>'; 
        }else{
          return '<a href="#"><img src="' + slide.firstElementChild.src + '"  height="50" /></a>'; 
        }
    } 
});


$('ul.artists li a').hover(function(){
  
var index = $('ul.artists li').index( $(this).parent());

$('.artistImages ul li#photo-'+index).hide().fadeIn(250);

},
function(){
  $('.artistImages ul li').fadeOut(50);
}
);

  // GALLERIA
  
  var galleriaPlugin;
  // prepare content for Galleria
  var $galleria = $('body').append('<div id="galleria"></div>').children('#galleria').hide();
  
  $('ul.artworks a').each(function(index){
    var $this = $(this);
    $this.click(function() {
      if(!galleriaPlugin){
        galleriaPlugin = $galleria.galleria({
          'initialTransition':'none',
          'transition':'fade',
          'imageCrop':false,
          'imageMargin':'100',

          'maxScaleRatio':1,

          'carouselFollow':true,
          'idleMode':true,
          'show':index,
          '_hideDock':false,
          'showCounter':false,

          'extend': function(options){
            galleriaPlugin = this;

            galleriaPlugin.addElement('x');
            galleriaPlugin.appendChild('image-nav','x');

            $('.galleria-x').html('<a href="#" id="galleria-x">&times;</a>')
            $('.galleria-x').click(function(){             
                //galleriaPlugin.exitFullscreen();
                //galleriaPlugin.$('container').hide();
                window.location.reload(true);
                return false;
            });
            
            galleriaPlugin.attachKeyboard({
              escape:function(){               
                //galleriaPlugin.exitFullscreen();
                //galleriaPlugin.$('container').hide();
                window.location.reload(true);
                //$galleria.fadeOut();
              }
            });
          }
        });
      } else {
     
        galleriaPlugin.enterFullscreen().show(index).refreshImage();
        galleriaPlugin.$('container').fadeIn(500);
        $('#galleria').fadeIn(500);
        
      }
      $galleria.fadeIn();
      return false;
    });
    $galleria.append($(this).clone());
  })

});
