// no conflict
// jQuery.noConflict();

/**
 *	custom IE Cleartype fixes
 */

$.fn.fadeIn = function(speed, callback) {
     return this.animate({
          opacity: 'show' }, speed, function() {
               if ($.browser.msie)
                    this.style.removeAttribute('filter');
               if (typeof callback == 'function')
                    callback();
     });
};

$.fn.fadeOut = function(speed, callback) {
     return this.animate({
           opacity: 'hide' }, speed, function() {
               if ($.browser.msie)
                    this.style.removeAttribute('filter');
               if (typeof callback == 'function') callback();
     });
};

$.fn.fadeTo = function(speed,to,callback) {
     return this.animate({opacity: to }, speed, function() {
          if (to == 1 && $.browser.msie)
               this.style.removeAttribute('filter');
          if (typeof callback == 'function') callback();
     });
}; 

/**
 *	checks if link is external 
 *	usage: a:external (only if element has href attr)
 */

$.extend($.expr[':'], {		
	external: function(a,i,m) {
		if(!a.href) {return false;}
		return a.hostname && a.hostname !== window.location.hostname;
	}
});

/**
 *	custom selector which determines if 
 *	images not resides in slideshow
 */

$.extend($.expr[':'], {			
	inSlideshow: function(e) {
		return $(e).parents("#slideshow").size();
	}
});


/**
 *	document load functions 
 */
$(document).ready(function() {
    
    $('html').css({overflowY: 'scroll'});

    // Gallery
    if ($('#thumbs').length) {

        $().slideshow();

        $('.image > div > a').each(function(i, elt) {
            var href = $(elt).attr('href');
            var url = href.match(/&(amp;)?file=([^&]+)&/).pop().replace(/%2(F|f)/g,'/');
            $(elt).attr('href', url);
            $(elt).attr('rel','superbox[gallery][my]');
        });

        $.superbox();
    }
});

