function change(imgSrc, imgName){
	document.getElementById(imgName).src = imgSrc;
}
function print(){
	document.getElementById('defaultCSS').href = ' /css/print.css';
}

jQuery(document).ready(function(){

  /* clickable boxes */  
  jQuery(".clickable_box").each(function(){
    var linkEl = $(".clickable_box_link", $(this));
    
    if(linkEl.length > 0){
      var link = linkEl.attr("href");
      
      if(linkEl != null && linkEl.length > 0){
        $(this).css({ "cursor": "pointer" });
        $(this).click(function(){
          window.location.href = link;
        })
      }
    }
  });


/*galleria*/

  /* lightbox */
  $('.lightbox').each(function(i, el){
    var el = $(el);    
    // performs image preload
    var imgTitle = el.attr('title');
    var imgSrc = el.attr('href');
    
    var imgTag = $("<img/>").attr({src: imgSrc, title: imgTitle})
                            .css({ position: 'absolute', top: '-6666px', left: '-6666px'})
                            .appendTo('body');    
    
    // attach event handler
    el.click(function(){
      var imgTitle = el.attr('title');
      var imgSrc = el.attr('href');    
      
      $.Overlay.dialog("", {
        width: imgTag.outerWidth(true) + 30,
        height: imgTag.outerHeight(true) + 70,
        minWidth: '500px'
      }, function(dialog){
        dialog.append($("<h1/>").text(imgTitle));
        
        imgTag.clone(true, true).removeAttr('style').appendTo(dialog).wrap('<div style="text-align:center"></div>');
      });    
      return false;
    });
  });

  Galleria.loadTheme('/scripts/galleria.classic.js');
  $('.galleryDialog_js').click(function(e){
    var id = $(this).attr('rel');
    
    $.ajax({
      type: 'get',
      url: '/gallery-dialog-service.aspx',
      data: { GalleryId: id },
      dataType: 'html',
      success: function(data){   
        $.Overlay.dialog(data, {
            width: '800px'
          }, function(dialog){       
          $('.galleryWrapper', dialog).galleria({
              width: 800,
              height: 400,
              // do not upscale
              maxScaleRatio: 1,
              show: 0,
              extend: function(options){ }
          });   
        });
      }
    });
    return false;
  });


});
