/*
 * Compatibility Plugin for jQuery 1.1 (on top of jQuery 1.2)
 * By John Resig
 * Dual licensed under MIT and GPL.
 *
 * For XPath compatibility with 1.1, you should also include the XPath
 * compatability plugin.
 */

(function(jQuery){

	// You should now use .slice() instead of eq/lt/gt
	// And you should use .filter(":contains(text)") instead of .contains()
	jQuery.each( [ "eq", "lt", "gt", "contains" ], function(i,n){
		jQuery.fn[ n ] = function(num,fn) {
			return this.filter( ":" + n + "(" + num + ")", fn );
		};
	});

	// This is no longer necessary in 1.2
	jQuery.fn.evalScripts = function(){};

	// You should now be using $.ajax() instead
	jQuery.fn.loadIfModified = function() {
		var old = jQuery.ajaxSettings.ifModified;
		jQuery.ajaxSettings.ifModified = true;
	
		var ret = jQuery.fn.load.apply( this, arguments );
	
		jQuery.ajaxSettings.ifModified = old;

		return ret;
	};

	// You should now be using $.ajax() instead
	jQuery.getIfModified = function() {
		var old = jQuery.ajaxSettings.ifModified;
		jQuery.ajaxSettings.ifModified = true;
	
		var ret = jQuery.get.apply( jQuery, arguments );
	
		jQuery.ajaxSettings.ifModified = old;

		return ret;
	};

	jQuery.ajaxTimeout = function( timeout ) {
		jQuery.ajaxSettings.timeout = timeout;
	};

})(jQuery);

/***
* 
* $.set_rollovers
*
* Use:
* set_rollovers( @options )
* 
***/

(function($){

jQuery.fn.set_rollovers = function( options ){
   var settings = {
      extension: '_o',
      hover_extension: '_h',
      fade: false,
      menu:{},
      menu_type: 'files'
   };
   if(options){ jQuery.extend(settings, options); };
   
   var path = String(document.location);
   var active = false;
   var longest_match = 0;
   $.each( settings.menu , function( menu_path ){
      if( settings.menu_type == 'files' ){
         if( menu_path.match(/|/) ){
            menu_path_arr = menu_path.split('|');
            for( k=0; k<menu_path_arr.length; k++ ){
               if( path.match( menu_path_arr[k] ) && menu_path_arr[k].length>longest_match ){ active = settings.menu[menu_path_arr[k]]; longest_match = menu_path_arr[k].length; };
            };
         } else {
            if( path.match( menu_path ) && menu_path.length>longest_match ){ active = settings.menu[menu_path]; longest_match = menu_path.length; };
         };
      } else if( settings.menu_type == 'nodes' ){
         if( $(menu_path).length ){ active = settings.menu[menu_path]; };
      };
   });
   
   return this.filter( '[src*='+ settings.extension +'.]' ).each(function(){
      var roll = new Image;
      roll.src = this.src.replace( settings.extension+'.', settings.hover_extension+'.');
      if( this.src.match(/[^\/]+$/)[0] == active){ this.src = this.src.replace( new RegExp(settings.extension+"(\.[a-z]+)$"), settings.hover_extension+"$1"); }
      else{
         this._hsrc = this.src.replace( new RegExp(settings.extension+"(\.[a-z]+)$") , settings.hover_extension+"$1");
         this._src = this.src;
         if( !settings.fade ){
            $(this).mouseover(function(){ this.src = this._hsrc; }).mouseout(function(){ this.src = this._src; });
         } else {
            var img_holder = $(this).wrap('<span style="position:relative; display:block;"></span>').parent();
            img_holder.append('<img src="'+roll.src+'" style="position:absolute; top:0; left:0;" />');
            img_holder.find('> :last-child').hide();
            img_holder.hover(
               function(){ $("> img:last-child", this).fadeIn(settings.fade); },
               function(){ $("> img:last-child", this).fadeOut(settings.fade); }
            );
         };
         if( this.parentNode.nodeName.match(/^a$/i) ){
            $(this).parent().focus(function(){ $(">img", this).trigger("mouseover"); }).blur(function(){ $(">img", this).trigger("mouseout"); });
         }else if( this.parentNode.nodeName.match(/span/i) && this.parentNode.parentNode.nodeName.match(/a/i) ){
            $(this).parents("a").focus(function(){ $("> span > img:last-child", this).fadeIn(settings.fade); }).blur(function(){ $("> span > :last-child", this).fadeOut(settings.fade); });
         };
      };
   });
};

})(jQuery);

/* =========================================================

// jquery.innerfade.js

// Datum: 2007-01-29
// Firma: Medienfreunde Hofmann & Baldes GbR
// Autor: Torsten Baldes
// Mail: t.baldes@medienfreunde.com
// Web: http://medienfreunde.com

// based on the work of Matt Oakes http://portfolio.gizone.co.uk/applications/slideshow/

// ========================================================= */


(function($) {

$.fn.innerfade = function(options) {

	this.each(function(){ 	
		
		var settings = {
			animationtype: 'fade',
			speed: 'normal',
			timeout: 2000,
			type: 'sequence',
			containerheight: 'auto',
			runningclass: 'innerfade'
		};
		
		if(options)
			$.extend(settings, options);
		
		var elements = $(this).children();
	
		if (elements.length > 1) {
		
			$(this).css('position', 'relative');
	
			$(this).css('height', settings.containerheight);
			$(this).addClass(settings.runningclass);
			
			for ( var i = 0; i < elements.length; i++ ) {
				$(elements[i]).css('z-index', String(elements.length-i)).css('position', 'absolute');
				$(elements[i]).hide();
			};
		
			if ( settings.type == 'sequence' ) {
				setTimeout(function(){
					$.innerfade.next(elements, settings, 1, 0);
				}, settings.timeout);
				$(elements[0]).show();
			} else if ( settings.type == 'random' ) {
				setTimeout(function(){
					do { current = Math.floor ( Math.random ( ) * ( elements.length ) ); } while ( current == 0 )
					$.innerfade.next(elements, settings, current, 0);
				}, settings.timeout);
				$(elements[0]).show();
			}	else {
				alert('type must either be \'sequence\' or \'random\'');
			}
			
		}
		
	});
};


$.innerfade = function() {}
$.innerfade.next = function (elements, settings, current, last) {

	if ( settings.animationtype == 'slide' ) {
		$(elements[last]).slideUp(settings.speed, $(elements[current]).slideDown(settings.speed));
	} else if ( settings.animationtype == 'fade' ) {
		$(elements[last]).fadeOut(settings.speed);
		$(elements[current]).fadeIn(settings.speed);
	} else {
		alert('animationtype must either be \'slide\' or \'fade\'');
	};
	
	if ( settings.type == 'sequence' ) {
		if ( ( current + 1 ) < elements.length ) {
			current = current + 1;
			last = current - 1;
		} else {
			current = 0;
			last = elements.length - 1;
		};
	}	else if ( settings.type == 'random' ) {
		last = current;
		while (	current == last ) {
			current = Math.floor ( Math.random ( ) * ( elements.length ) );
		};
	}	else {
		alert('type must either be \'sequence\' or \'random\'');
	};
	setTimeout((function(){$.innerfade.next(elements, settings, current, last);}), settings.timeout);
};
})(jQuery);




