//$ = jQuery;
/*!
 * OuterHTML v1.0.0 (Release version)
 *
 * http://www.darlesson.com/
 *
 * Copyright 2010, Darlesson Oliveira
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @requires jQuery v1.4.0 or above
 *
 * Reporting bugs, comments or suggestions: http://darlesson.com/contact/
 * Documentation and other jQuery plug-ins: http://darlesson.com/jquery/
 * Donations are welcome: http://darlesson.com/donate/
 */
 
// Examples and documentation at: http://darlesson.com/jquery/outerhtml/

// jQuery outerHTML
(function($){
		  
	$.fn.extend({
		outerHTML : function( value ){
	
			// Replaces the content
			if( typeof value === "string" ){
				var $this = $(this),
					$parent = $this.parent();
					
				var replaceElements = function(){
					
					// For some reason sometimes images are not replaced properly so we get rid of them first
					var $img = $this.find("img");
					if( $img.length > 0 ){
						$img.remove();
					}
					
					var element;
					$( value ).map(function(){
						element = $(this);
						$this.replaceWith( element );
					})
					
					return element;
					
				}
				
				return replaceElements();
				
			// Returns the value
			}else{
				return $("<div />").append($(this).clone()).html();
			}
	
		}
	});

})(jQuery);






(function($) {

/*
 * Ensures an element's text is cut off at a certain maximum number of lines.
 *
 * The element must have a nonzero width when empty. (Most commonly a block
 * element, such as a <p>, will fit this criterion.) The contained, HTML-free
 * text will be truncated to fit the width along with an "end", e.g., 'É'.
 * Truncation will only occur along whitespace.
 *
 * Assumptions:
 * - The element is empty or contains only a single text node.
 *
 * Guarantees:
 * - The displayed text will never surpass the requested number of lines.
 * - If truncation occurs and the end string fits within the width of the
 *   element, the end string will be displayed.
 * - As many words in the element's text will be displayed as possible.
 *
 * Options:
 *   end: (default 'É') String to append to the end when truncating. May also
 *  					be a DOM node.
 *   always_end: String or DOM node which must always be appended, whether or
 *   			not we truncate. (This may actually cause truncation which
 *   			would otherwise not occur.)
 *	 lines: (default 1) Number of lines of text to display.
 *
 * --
 * Bodacity JavaScript Utilities
 * http://adamhooper.com/bodacity
 * Public Domain (no licensing restrictions)
 */
function Excerpt(elem, options) {
	this.$elem = $(elem);
	this.options = $.extend({
		end: 'É',
		always_end: undefined,
		lines: 1
	}, options);

	this.original_text = this.$elem.text();

	if (typeof(this.options.end) != 'string') {
		// Assume it's a DOM element or jQuery object
		this.$end_node = $(this.options.end);
		this.end_string = this.$end_node.text();
	} else {
		this.end_string = this.options.end;
		this.$end_node = $(document.createTextNode(this.end_string));
	}

	if (this.options.always_end) {
		if (typeof(this.options.always_end) != 'string') {
			this.$always_end_node = $(this.options.always_end);
			this.always_end_string = this.$always_end_node.text();
		} else {
			this.always_end_string = this.options.always_end;
			this.$always_end_node = $(document.createTextNode(this.always_end_string));
		}
	}

	this._attach();
	this.refresh();
}

$.extend(Excerpt.prototype, {
	_attach: function() {
	},

	/*
	 * Resets the element based on its original text, such that it only the
	 * desired number of lines are shown and there is no overflow.
	 */
	refresh: function() {
		if (!this.$elem[0].firstChild) return; // It's already empty

		var wh = this._calculate_desired_width_height();
		var w = wh[0];
		var h = wh[1];

		var s = this.original_text.replace(/\s+/, ' ');

		var spaces = []; // Array of indices to space characters
		spaces.push(0);
		for (var i = 1; i < s.length; i++) {
			if (s.charAt(i) == ' ') {
				spaces.push(i);
			}
		}
		spaces.push(s.length);

		var lbound = 0;
		var rbound = spaces.length - 1;

		var cur = 0;
		var cutoff = 100;
		while (lbound < rbound && cutoff) {
			cur = Math.floor(lbound + (rbound - lbound) / 2);
			if (cur == lbound) cur += 1;

			var sub = this._substring(s, spaces[cur]);
			if (this._is_string_small_enough(sub, w, h)) {
				lbound = cur;
			} else {
				rbound = cur - 1;
			}
			cutoff -= 1;
		}

		this.$elem[0].firstChild.nodeValue = this._substring(s, spaces[lbound], true);
		if (s.length != spaces[lbound]) {
			this.$elem.append(this.$end_node.clone());
		}
		if (this.$always_end_node) {
			this.$elem.append(this.$always_end_node.clone());
		}
	},

	_substring: function(s, length, exclude_end_string) {
		if (length == s.length) return s;
		var substr = s.substr(0, length);
		if (exclude_end_string) {
			return substr;
		} else {
			return substr + this.end_string + (this.always_end_string || '');
		}
	},

	_is_string_small_enough: function(s, w, h) {
		var node = this.$elem[0];

		node.firstChild.nodeValue = s;
		return node.offsetHeight <= h && node.offsetWidth <= w;
	},

	/*
	 * Returns the desired [width, height] in px.
	 *
	 * Modifies this.$elem contents as a side-effect.
	 */
	_calculate_desired_width_height: function() {
		var node = this.$elem[0];

		var s = '&nbsp;';
		for (var i = 0; i < this.options.lines - 1; i++) {
			s += "<br />&nbsp;";
		}

		node.innerHTML = s;

		var w = node.offsetWidth;
		var h = node.offsetHeight;

		node.innerHTML = '&nbsp;'; // anything non-empty

		return [w, h];
	}
});

$.fn.excerpt = function(options) {
	return $(this).each(function() {
		new Excerpt(this, options);
	});
};

})(jQuery);

/*
	JQUERY BLINK
*/

(function($)
{
	$.fn.blink = function(options)
	{
		var defaults = { delay:500 };
		var options = $.extend(defaults, options);
		
		return this.each(function()
		{
			var obj = $(this);
			if (obj.attr("timerid") > 0) return;
			var timerid=setInterval(function()
			{
				if($(obj).css("visibility") == "visible")
				{
						$(obj).css('visibility','hidden');
				}
				else
				{
						$(obj).css('visibility','visible');
				}
			}, options.delay);
			obj.attr("timerid", timerid);
		});
	}
	$.fn.unblink = function(options) 
	{
		var defaults = { visible:true };
		var options = $.extend(defaults, options);
		
		return this.each(function() 
		{
			var obj = $(this);
			if (obj.attr("timerid") > 0) 
			{
					clearInterval(obj.attr("timerid"));
					obj.attr("timerid", 0);
					obj.css('visibility', options.visible?'visible':'hidden');
			}
		});
	}
}(jQuery));

/**
	JQUERY TIMERS
**/
jQuery.fn.extend({
	everyTime: function(interval, label, fn, times, belay) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function(interval, label, fn) {
		return this.each(function() {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function(label, fn) {
		return this.each(function() {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.extend({
	timer: {
		guid: 1,
		global: {},
		regex: /^([0-9]+)\s*(.*s)?$/,
		powers: {
			// Yeah this is major overkill...
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function(value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseInt(result[1], 10);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function(element, interval, label, fn, times, belay) {
			var counter = 0;
			
			if (jQuery.isFunction(label)) {
				if (!times) 
					times = fn;
				fn = label;
				label = interval;
			}
			
			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}
			
			times = times || 0;
			belay = belay || false;
			
			if (!element.$timers) 
				element.$timers = {};
			
			if (!element.$timers[label])
				element.$timers[label] = {};
			
			fn.$timerID = fn.$timerID || this.guid++;
			
			var handler = function() {
				if (belay && this.inProgress) 
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};
			
			handler.$timerID = fn.$timerID;
			
			if (!element.$timers[label][fn.$timerID]) 
				element.$timers[label][fn.$timerID] = window.setInterval(handler,interval);
			
			if ( !this.global[label] )
				this.global[label] = [];
			this.global[label].push( element );
			
		},
		remove: function(element, label, fn) {
			var timers = element.$timers, ret;
			
			if ( timers ) {
				
				if (!label) {
					for ( label in timers )
						this.remove(element, label, fn);
				} else if ( timers[label] ) {
					if ( fn ) {
						if ( fn.$timerID ) {
							window.clearInterval(timers[label][fn.$timerID]);
							delete timers[label][fn.$timerID];
						}
					} else {
						for ( var fn in timers[label] ) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}
					
					for ( ret in timers[label] ) break;
					if ( !ret ) {
						ret = null;
						delete timers[label];
					}
				}
				
				for ( ret in timers ) break;
				if ( !ret ) 
					element.$timers = null;
			}
		}
	}
});

if (jQuery.browser.msie) {
	jQuery(window).one("unload", function() {
		var global = jQuery.timer.global;
		for ( var label in global ) {
			var els = global[label], i = els.length;
			while ( --i )
				jQuery.timer.remove(els[i], label);
		}
	});
}

/**
	JQUERY COOKIE
**/
/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


/*!
 * JavaScript Debug - v0.4 - 6/22/2010
 * http://benalman.com/projects/javascript-debug-console-log/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 * 
 * With lots of help from Paul Irish!
 * http://paulirish.com/
 */

// Script: JavaScript Debug: A simple wrapper for console.log
//
// *Version: 0.4, Last Updated: 6/22/2010*
// 
// Tested with Internet Explorer 6-8, Firefox 3-3.6, Safari 3-4, Chrome 3-5, Opera 9.6-10.5
// 
// Home       - http://benalman.com/projects/javascript-debug-console-log/
// GitHub     - http://github.com/cowboy/javascript-debug/
// Source     - http://github.com/cowboy/javascript-debug/raw/master/ba-debug.js
// (Minified) - http://github.com/cowboy/javascript-debug/raw/master/ba-debug.min.js (1.1kb)
// 
// About: License
// 
// Copyright (c) 2010 "Cowboy" Ben Alman,
// Dual licensed under the MIT and GPL licenses.
// http://benalman.com/about/license/
// 
// About: Support and Testing
// 
// Information about what browsers this code has been tested in.
// 
// Browsers Tested - Internet Explorer 6-8, Firefox 3-3.6, Safari 3-4, Chrome
// 3-5, Opera 9.6-10.5
// 
// About: Examples
// 
// These working examples, complete with fully commented code, illustrate a few
// ways in which this plugin can be used.
// 
// Examples - http://benalman.com/code/projects/javascript-debug/examples/debug/
// 
// About: Revision History
// 
// 0.4 - (6/22/2010) Added missing passthrough methods: exception,
//       groupCollapsed, table
// 0.3 - (6/8/2009) Initial release
// 
// Topic: Pass-through console methods
// 
// assert, clear, count, dir, dirxml, exception, group, groupCollapsed,
// groupEnd, profile, profileEnd, table, time, timeEnd, trace
// 
// These console methods are passed through (but only if both the console and
// the method exists), so use them without fear of reprisal. Note that these
// methods will not be passed through if the logging level is set to 0 via
// <debug.setLevel>.

window.debug = (function(){
  var window = this,
    
    // Some convenient shortcuts.
    aps = Array.prototype.slice,
    con = window.console,
    
    // Public object to be returned.
    that = {},
    
    callback_func,
    callback_force,
    
    // Default logging level, show everything.
    log_level = 9,
    
    // Logging methods, in "priority order". Not all console implementations
    // will utilize these, but they will be used in the callback passed to
    // setCallback.
    log_methods = [ 'error', 'warn', 'info', 'debug', 'log' ],
    
    // Pass these methods through to the console if they exist, otherwise just
    // fail gracefully. These methods are provided for convenience.
    pass_methods = 'assert clear count dir dirxml exception group groupCollapsed groupEnd profile profileEnd table time timeEnd trace'.split(' '),
    idx = pass_methods.length,
    
    // Logs are stored here so that they can be recalled as necessary.
    logs = [];
  
  while ( --idx >= 0 ) {
    (function( method ){
      
      // Generate pass-through methods. These methods will be called, if they
      // exist, as long as the logging level is non-zero.
      that[ method ] = function() {
        log_level !== 0 && con && con[ method ]
          && con[ method ].apply( con, arguments );
      }
      
    })( pass_methods[idx] );
  }
  
  idx = log_methods.length;
  while ( --idx >= 0 ) {
    (function( idx, level ){
      
      // Method: debug.log
      // 
      // Call the console.log method if available. Adds an entry into the logs
      // array for a callback specified via <debug.setCallback>.
      // 
      // Usage:
      // 
      //  debug.log( object [, object, ...] );                               - -
      // 
      // Arguments:
      // 
      //  object - (Object) Any valid JavaScript object.
      
      // Method: debug.debug
      // 
      // Call the console.debug method if available, otherwise call console.log.
      // Adds an entry into the logs array for a callback specified via
      // <debug.setCallback>.
      // 
      // Usage:
      // 
      //  debug.debug( object [, object, ...] );                             - -
      // 
      // Arguments:
      // 
      //  object - (Object) Any valid JavaScript object.
      
      // Method: debug.info
      // 
      // Call the console.info method if available, otherwise call console.log.
      // Adds an entry into the logs array for a callback specified via
      // <debug.setCallback>.
      // 
      // Usage:
      // 
      //  debug.info( object [, object, ...] );                              - -
      // 
      // Arguments:
      // 
      //  object - (Object) Any valid JavaScript object.
      
      // Method: debug.warn
      // 
      // Call the console.warn method if available, otherwise call console.log.
      // Adds an entry into the logs array for a callback specified via
      // <debug.setCallback>.
      // 
      // Usage:
      // 
      //  debug.warn( object [, object, ...] );                              - -
      // 
      // Arguments:
      // 
      //  object - (Object) Any valid JavaScript object.
      
      // Method: debug.error
      // 
      // Call the console.error method if available, otherwise call console.log.
      // Adds an entry into the logs array for a callback specified via
      // <debug.setCallback>.
      // 
      // Usage:
      // 
      //  debug.error( object [, object, ...] );                             - -
      // 
      // Arguments:
      // 
      //  object - (Object) Any valid JavaScript object.
      
      that[ level ] = function() {
        var args = aps.call( arguments ),
          log_arr = [ level ].concat( args );
        
        logs.push( log_arr );
        exec_callback( log_arr );
        
        if ( !con || !is_level( idx ) ) { return; }
        
        con.firebug ? con[ level ].apply( window, args )
          : con[ level ] ? con[ level ]( args )
          : con.log( args );
      };
      
    })( idx, log_methods[idx] );
  }
  
  // Execute the callback function if set.
  function exec_callback( args ) {
    if ( callback_func && (callback_force || !con || !con.log) ) {
      callback_func.apply( window, args );
    }
  };
  
  // Method: debug.setLevel
  // 
  // Set a minimum or maximum logging level for the console. Doesn't affect
  // the <debug.setCallback> callback function, but if set to 0 to disable
  // logging, <Pass-through console methods> will be disabled as well.
  // 
  // Usage:
  // 
  //  debug.setLevel( [ level ] )                                            - -
  // 
  // Arguments:
  // 
  //  level - (Number) If 0, disables logging. If negative, shows N lowest
  //    priority levels of log messages. If positive, shows N highest priority
  //    levels of log messages.
  //
  // Priority levels:
  // 
  //   log (1) < debug (2) < info (3) < warn (4) < error (5)
  
  that.setLevel = function( level ) {
    log_level = typeof level === 'number' ? level : 9;
  };
  
  // Determine if the level is visible given the current log_level.
  function is_level( level ) {
    return log_level > 0
      ? log_level > level
      : log_methods.length + log_level <= level;
  };
  
  // Method: debug.setCallback
  // 
  // Set a callback to be used if logging isn't possible due to console.log
  // not existing. If unlogged logs exist when callback is set, they will all
  // be logged immediately unless a limit is specified.
  // 
  // Usage:
  // 
  //  debug.setCallback( callback [, force ] [, limit ] )
  // 
  // Arguments:
  // 
  //  callback - (Function) The aforementioned callback function. The first
  //    argument is the logging level, and all subsequent arguments are those
  //    passed to the initial debug logging method.
  //  force - (Boolean) If false, log to console.log if available, otherwise
  //    callback. If true, log to both console.log and callback.
  //  limit - (Number) If specified, number of lines to limit initial scrollback
  //    to.
  
  that.setCallback = function() {
    var args = aps.call( arguments ),
      max = logs.length,
      i = max;
    
    callback_func = args.shift() || null;
    callback_force = typeof args[0] === 'boolean' ? args.shift() : false;
    
    i -= typeof args[0] === 'number' ? args.shift() : max;
    
    while ( i < max ) {
      exec_callback( logs[i++] );
    }
  };
  
  return that;
})();



/**
	RUTUBE LLP VIDEOWALL
**/

(function($)
{	
	$.fn.rutube = function(options)
	{
		function is_int(value) {
			if((parseFloat(value) == parseInt(value)) && !isNaN(value)) {
				return true;
			} else {
				return false;
			}
		}
		
		$ = jQuery;
		
		var defaults = {
			dev_key: '3492ee206914676eeadfcf61cc50b763',
			per_page: 10,
			url: 'http://rutube.ru/cgi-bin/jsapi.cgi',
			max_video: 1000,
			delay: 150000000
		};
		
		var options = jQuery.extend(defaults, options);
		
		if(!options.max_video || options.max_video <= 0) options.max_video = 13;
		
		options.url += '?';		
		if(options.dev_key) options.url += 'rt_developer_key=' + options.dev_key + '&';
		options.url += 'rt_count='+options.max_video+'&';
		
		window.console && console.log && console.log( options.url );
		
		window.rt_show_movies = function(){};
		
		return this.each(function()
		{
			var obj = jQuery(this);
			
			if(obj.attr("rutubized")) return false;
			
			var x;
			
			x = obj.attr('per_page');
			if(x && is_int(x) && x > 0) options.per_page = x;
			
			x = obj.attr('dev_key');
			if(x && x.length == 32) options.url += 'rt_developer_key=' + x + '&';
			
			// Get rutube script containing tracks + custom js
			jQuery.getScript(options.url, function(script, load_status){
			
				var saved_tracks = tracks;
				
				// Arrange tracks
				tracks = saved_tracks;
				if(tracks.length == 0) return false;
				
				var wrapper = $('<div class="rutube_videowall" />');
				jQuery.map(tracks, function(track, index) {
					
					var title = jQuery('<span />').html(track.title).text()
					.replace("'", "‘").replace('"', "‘").replace("‘", "'");
					
					wrapper
					.hide()
					.append(
						jQuery('<div />')
						.attr({
							class: 'track',
							'num' : index
						})
						.append(
							jQuery('<a />')
							.attr({
								class: 'link',
								href: track.playerLink,
								title : title + ' (' + track.hits + ' vues, ' + track.duration + 'min)',
								rel: 'rutube'
							})
							.append(
								jQuery('<img />')
								.attr({
									class: 'thumbnail',
									src: track.thumbnailMediumLink,
									title : title + ' (' + track.hits + ' vues, ' + track.duration + 'min)',
									alt : title + ' (' + track.hits + ' vues, ' + track.duration + 'min)'
								})
							)
							.append(
								jQuery('<div />')
								.attr({
									class: 'title'
								})
								.html(track.title)
							)
							.append(
								jQuery('<div />')
								.attr({
									class: 'description',
									title: track.description
								})
								.html(track.description)
							)
							.append(
								jQuery('<div />')
								.attr({
									class: 'duration'
								})
								.text(track.duration)
							)
						)
					)
				}); // end fetch/map tracks
				
				wrapper
				.prepend(
					jQuery('<div />')
					.attr({
						class: 'pager'
					})
					.hide()
				); // end add pager
				
				wrapper
				.append(
					jQuery('<div />')
					.attr({
						class: 'videowall_clearfix'
					})
				); // end add clearfix
				
				// Write tracks
				obj.append(wrapper);
				
				// Add effects
				wrapper = obj.find('.rutube_videowall');
				
				wrapper.find(".track > .link").fancybox({
					'width'				: '60%',
					'height'			: '80%',
			        'autoScale'     	: false,
			        'transitionIn'		: 'none',
					'transitionOut'		: 'none',
					'type'				: 'iframe',
					'centerOnScroll'	: true,
					'hideOnOverlayClick': false,
					'showNavArrows'		: false,
					'title'				: jQuery(this).title
				}); // end of fancyboxization
				
				wrapper
				.find('.track')
				.hide()
				;
				
				wrapper
				.delay(500)
				.show()
				;
				
				var pager = wrapper.find('.pager');
				var videos = wrapper.find('.track');
				var per_page = options.per_page;
				var count = tracks.length;
				var page_count = Math.ceil(count/per_page);
				var page_modulo = count % per_page;
				
				for(var i = 0; i < page_count; i++) {
					pager
					.append(
						jQuery('<a />')
						.attr({
							class: 'page',
							href: '#',
							'num': i
						})
						.text((i+1))
						.click(function(){
							
							var a = jQuery(this);
							
							pager.find('.active').removeClass('active');
							
							var x = a.attr('num');
							var gt = (((x)*per_page));
							var lt = per_page;
						
							videos
							.hide()
							.filter(':eq('+gt+'), :gt('+gt+')')
							.filter(':lt('+lt+')')
							.map(function(index, value){ // change page effect
								var video = jQuery(this);
								var icon = video.find('.thumbnail');
							
								icon.hide(); // hide icon
								video.show(); // show its container
								icon.delay(Math.floor(Math.random()*500)).fadeIn(500); // show icon
							})
							;
							
							a.addClass('active');
							
							return false;
							
						})
					)
				}
				
				pager.show();
				pager.find('.page:first').click();
				
				function activate_cycle () {
					pager.everyTime(options.delay, function() {
						var next = pager.find('.page.active').next();
						if(next.length == 0) next = pager.find('.page:first');
						next.click();
					})
				}
				
				function desactivate_cycle () {
					pager.stopTime();
				}
				
				activate_cycle();
				
				wrapper
				.mouseenter(function(){
					var w = jQuery(this);
					desactivate_cycle();
				})
				.mouseleave(function(){
					var w = jQuery(this);
					desactivate_cycle();
					activate_cycle();
				})
				.find('.track')
				.mouseenter(function(){
					jQuery(this)
					.find('.duration, .title')
					.fadeIn(600)
				})
				.mouseleave(function(){
					jQuery(this)
					.find('.duration, .title')
					.hide(200)
				})
				;
				
			}); // end getScript
			
			obj.attr("rutubized", true);
			
		}); // end return
	} // end fn.rutube
}(jQuery));

/** GALLERY **/

(function($)
{	
	$.fn.llp_gallery = function(options)
	{
		var defaults = {
			
		};
		
		var options = $.extend(defaults, options);
	
	} // end fn.llp_gallery
}(jQuery));

/** timthumb **/

(function($)
{	
	$.fn.timthumbize = function(options)
	{
		var defaults = {
			
		};
		
		var options = $.extend(defaults, options);
		
		return this.each(function() {
		
			var obj = $(this);
			
			if(obj.attr('timthumbized')) return false;
			
			var w = obj.attr('width');
			var h = obj.attr('height');
			var i = obj.attr('src');
			
			var tt = "http://www.lelibrepenseur.org/wp-content/themes/aggregate/timthumb.php?";
			
			var params = '';
			
			params += "&w="+w;
			params += "&h="+h;
			params += "&src="+i;
			params += "";
			
			obj.attr('src', tt+params);
			
			obj.attr('timthumbized', true);
			
		});
	
	} // end fn.timthumb
}(jQuery));


jQuery(window).load(function() {
	
	if(jQuery.cookie('intro_vue') != "oui") {
	
		jQuery.fancybox({href:'http://www.lelibrepenseur.org/wp-content/themes/aggregate/swf/intro_v8.swf', overlayOpacity: 0.9, centerOnScroll: true, scrolling: 'no', title: 'Video d\'introduction - Bienvenue'});
		
		jQuery.cookie('intro_vue', 'oui', {expires: 7});
	
	}
	
    //*
    jQuery('#slider')
    .show()
    .nivoSlider({
    	pauseTime: 7000,
    	controlNav: true,
    	keyboardNav: true,
    	//controlNavThumbs: true,
    	pauseOnHover: true,
    	prevText: '',
    	nextText: '',
    	animSpeed: 600,
    	captionOpacity: 0.8,
    	slices: 20,
    	borderRadius: 10
    	, afterLoad: function() { jQuery('#slider_wrapper > .faux_shadow').fadeIn(1000); }
    	, afterChange: function() { jQuery('#slider_wrapper .nivo-caption p').fadeIn(); window.console && console.log && console.log( jQuery('#slider_wrapper .nivo-caption p') );
 }
    })
    //*/
    
    //*
	jQuery('ul.nav').superfish({ 
		pathClass:  'current',
		delay:       200,								// delay on mouseout 
		animation:   {opacity:'show', height:'show'},	// fade-in and slide-down animation 
		speed:       'fast',							// faster animation speed 
		autoArrows:  true,								// disable generation of arrow mark-up 
		dropShadows: false								// disable drop shadows 
	});
	//*/
	
	jQuery('.myvideotag object').each(function() {
    	jQuery(this).append('<param name="wmode" value="opaque" />');
	});
	
	jQuery("a[rel='fancybox']").fancybox();
	jQuery("a[rel='fancybox_rutube']").fancybox({
		'width'				: '60%',
		'height'			: '80%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'centerOnScroll'	: true,
		'hideOnOverlayClick': false,
		'showNavArrows'		: false,
		'title'				: ''
	});
	
	jQuery(".entry p a[href$='jpg'] ").has('img').fancybox();
	jQuery(".entry p a[href$='png'] ").has('img').fancybox();
	jQuery(".entry p a[href$='jpeg'] ").has('img').fancybox();
	
	jQuery("img[rel='timthumb']").timthumbize();
	
	//$('.rutube_widget').rutube();
	
	jQuery('#second-menu').fadeIn(1500);
    
});



