

jQuery(document).ready(function() {
	jQuery('#login').hide();
	jQuery('<p id="close">(Close)</p>').insertAfter('#login #alw_loginForm');
});
setupPictures = function(size) {
  jQuery('img.imagefield-field_pictures').each(function() {
      var width = Math.round(this.width / size);
      var height = Math.round(this.height / size);

      jQuery(this).attr("width", width);
      jQuery(this).attr("height", height);
      
      jQuery(this).addClass('thumbnail');
      
      jQuery(this).parent().find('.description').hide();
  });
  
  jQuery('img.imagefield-field_picture').each(function() {
      var width = Math.round(jQuery(this).attr("width") / size);
      var height = Math.round(jQuery(this).attr("height") / size);

      jQuery(this).attr("width", width);
      jQuery(this).attr("height", height);

      jQuery(this).addClass('thumbnail');
      
      jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').hide();
  });

  jQuery('img.imagefield-field_pictures, img.imagefield-field_picture').click(function() {


      if (jQuery(this).hasClass('thumbnail')) {
				var width = jQuery(this).attr("width") * size;
		    var height = jQuery(this).attr("height") * size;

          jQuery(this).attr("width", width);
          jQuery(this).attr("height", height);
          
          jQuery(this).parent().css('width', width);
          
          jQuery(this).removeClass('thumbnail');
          
          jQuery(this).next('.description').show();
          jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').show();
      } else {
				var width = Math.round(jQuery(this).attr("width") / size);
	      var height = Math.round(jQuery(this).attr("height") / size);
          jQuery(this).attr("width", width);
          jQuery(this).attr("height", height);
          
          jQuery(this).parent().css('width', width);
          
          jQuery(this).addClass('thumbnail');
          
          jQuery(this).next('.description').hide();
          jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').hide();
      }
  });
  jQuery('img.imagefield-field_pictures-annualportfolio').each(function() {
      var width = Math.round(this.width / size);
      var height = Math.round(this.height / size);

      jQuery(this).attr("width", width);
      jQuery(this).attr("height", height);
      
      jQuery(this).addClass('thumbnail');
      
      jQuery(this).parent().find('.description p').hide();
      jQuery(this).parent().find('.description p:first').show();
  });
  
  jQuery('img.imagefield-field_picture-annualportfolio').each(function() {
      var width = Math.round(jQuery(this).attr("width") / size);
      var height = Math.round(jQuery(this).attr("height") / size);

      jQuery(this).attr("width", width);
      jQuery(this).attr("height", height);

      jQuery(this).addClass('thumbnail');
      
      jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').hide();
  });

  jQuery('img.imagefield-field_pictures-annualportfolio, img.imagefield-field_picture-annualportfolio').click(function() {


      if (jQuery(this).hasClass('thumbnail')) {
				var width = jQuery(this).attr("width") * size;
		    var height = jQuery(this).attr("height") * size;

          jQuery(this).attr("width", width);
          jQuery(this).attr("height", height);
          
          jQuery(this).parent().css('width', width);
          
          jQuery(this).removeClass('thumbnail');
          
          jQuery(this).parent().find('.description p').show();
          jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').show();
      } else {
				var width = Math.round(jQuery(this).attr("width") / size);
	      var height = Math.round(jQuery(this).attr("height") / size);
          jQuery(this).attr("width", width);
          jQuery(this).attr("height", height);
          
          jQuery(this).parent().css('width', width);
          
          jQuery(this).addClass('thumbnail');
          
          jQuery(this).parent().find('.description p').hide();
        jQuery(this).parent().find('.description p:first').show();
          jQuery(this).parent().parent().parent().find('div.views-field-body, div.views-field-field-html-value').hide();
      }
  });

};

setupBoardMembers = function() {
	jQuery('#directors p').hide();
	jQuery('.member').click(function() {
		jQuery(this).next('p').slideToggle();
		return false;
	});
};
setupCursor = function() {
    var curi = 1;
    var cursor = jQuery('#cursor');
    var cleartime;
    
    cursorAni = function() {
      curi = curi < 22 ? curi + 1 : 1;
      cursor.css('background-position', '0 ' + curi * 198 + 'px');
    };

    jQuery("html").mousemove(function(e) {
        cursor.css({
            top: (e.pageY+3),
            left: (e.pageX - (262 / 2))
        });
    });

    jQuery("a, img").hover(function() {
        cursorAni();
    }, function() {
        cursorAni();
    });
};

jQuery(window).load(function(){
	jQuery('.page-id-735 img').removeClass('imagefield-field_pictures');
	jQuery('.page-id-798 #content_pictures div:first-child img').removeClass('imagefield-field_pictures');
	jQuery('.page-id-798 #content_pictures div:first-child img').click(function(){
		window.location = "http://artistsspace.org/2010-annual-edition-portfolio-2/";
	})
	setupPictures(2);
	setupBoardMembers();
	setupCursor();
	
	jQuery('.datelink').live('click', function(event) {
		event.preventDefault();
		jQuery('.datebox').hide();
		jQuery('.selected').removeClass('selected');
		jQuery(this).addClass('selected');
		jQuery(this.hash).show();
	});
	jQuery('.page-template-page-contentbookshop-php #column_2 div').hide();
	
	jQuery('#menu-item-590 a').click(function(event){
		event.preventDefault();
		jQuery('#login').insertAfter('#menu-item-562 ul');
		jQuery('#login').show();
	});
	jQuery('#close').click(function(event){
		jQuery('#login').hide();
	})
    
	jQuery('.page-template-page-contentbookshop-php #main_content p a').live('click', function(event) {
		event.preventDefault();
		jQuery('.page-template-page-contentbookshop-php #column_2 div').hide();
		jQuery('.selected').removeClass('selected');
		jQuery(this).addClass('selected');
		jQuery(this.hash).show();
	});
    
    var random = Math.round(Math.random()*16)
    jQuery('.page-template-page-contentbookshop-php #main_content p a').eq(random).click();
    
	jQuery('.page-template-exhibitions-past-php #datebox h4:first-child a').click();
    jQuery('.page-template-exhibitions-future-php #datebox h4:first-child a').click();
	jQuery('.page-template-programs-past-php #datebox h4:first-child a').click();
    jQuery('.page-template-programs-future-php #datebox h4:first-child a').click();
	
});


