
// Simple JavaScript Templating
// John Resig - http://ejohn.org/ - MIT Licensed
(function(){var cache={};this.tmpl=function tmpl(str,data){var fn=!/\W/.test(str)?cache[str]=cache[str]||tmpl(document.getElementById(str).innerHTML):new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};"+"with(obj){p.push('"+
str.replace(/[\r\t\n]/g," ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'")
+"');}return p.join('');");return data?fn(data):fn;};})();

/*
 * 	Easy Slider 1.5 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 *	markup example for $("#slider").easySlider();
 *	
 * 	<div id="slider">
 *		<ul>
 *			<li><img src="images/01.jpg" alt="" /></li>
 *			<li><img src="images/02.jpg" alt="" /></li>
 *			<li><img src="images/03.jpg" alt="" /></li>
 *			<li><img src="images/04.jpg" alt="" /></li>
 *			<li><img src="images/05.jpg" alt="" /></li>
 *		</ul>
 *	</div>
 *
 */

(function($){$.fn.easySlider=function(options){var defaults={prevId:'prevBtn',prevText:'',nextId:'nextBtn',nextText:'',controlsShow:true,controlsBefore:'',controlsAfter:'',controlsFade:true,firstId:'firstBtn',firstText:'First',firstShow:false,lastId:'lastBtn',lastText:'Last',lastShow:false,vertical:false,speed:800,auto:false,pause:2000,continuous:false};var options=$.extend(defaults,options);this.each(function(){var obj=$(this);var s=$("li",obj).length;var w=$("li",obj).width();var h=$("li",obj).height();obj.width(w);obj.height(h);obj.css("overflow","hidden");var ts=s-1;var t=0;$("ul",obj).css('width',s*w);if(!options.vertical)$("li",obj).css('float','left');if(options.controlsShow){var html=options.controlsBefore;if(options.firstShow)html+='<span id="'+options.firstId+'"><a href=\"javascript:void(0);\">'+options.firstText+'</a></span>';html+=' <span id="'+options.prevId+'"><a href=\"javascript:void(0);\">'+options.prevText+'</a></span>';html+=' <span id="'+options.nextId+'"><a href=\"javascript:void(0);\">'+options.nextText+'</a></span>';if(options.lastShow)html+=' <span id="'+options.lastId+'"><a href=\"javascript:void(0);\">'+options.lastText+'</a></span>';html+=options.controlsAfter;$(obj).after(html);};$("a","#"+options.nextId).click(function(){animate("next",true);});$("a","#"+options.prevId).click(function(){animate("prev",true);});$("a","#"+options.firstId).click(function(){animate("first",true);});$("a","#"+options.lastId).click(function(){animate("last",true);});function animate(dir,clicked){var ot=t;switch(dir){case"next":t=(ot>=ts)?(options.continuous?0:ts):t+1;break;case"prev":t=(t<=0)?(options.continuous?ts:0):t-1;break;case"first":t=0;break;case"last":t=ts;break;default:break;};var diff=Math.abs(ot-t);var speed=diff*options.speed;if(!options.vertical){p=(t*w*-1);$("ul",obj).animate({marginLeft:p},speed);}else{p=(t*h*-1);$("ul",obj).animate({marginTop:p},speed);};if(!options.continuous&&options.controlsFade){if(t==ts){$("a","#"+options.nextId).hide();$("a","#"+options.lastId).hide();}else{$("a","#"+options.nextId).show();$("a","#"+options.lastId).show();};if(t==0){$("a","#"+options.prevId).hide();$("a","#"+options.firstId).hide();}else{$("a","#"+options.prevId).show();$("a","#"+options.firstId).show();};};if(clicked)clearTimeout(timeout);if(options.auto&&dir=="next"&&!clicked){;timeout=setTimeout(function(){animate("next",false);},diff*options.speed+options.pause);};};var timeout;if(options.auto){;timeout=setTimeout(function(){animate("next",false);},options.pause);};if(!options.continuous&&options.controlsFade){$("a","#"+options.prevId).hide();$("a","#"+options.firstId).hide();};});};})(jQuery);

/*
 * Float Label written by Marc Grabanski
 * m@marcgrabanski.com
 */
(function ($) {
 $.fn.floatLabel = function(){
 	return $(this).each(function(){
 	  var label = $(this).parent().find('label');
 	  label.show();

 		if ($(this).val() != '') 
 			label.hide();

 		$(this)
   		.focus(function(){
   			label.hide();
   		})
   		.blur(function(){
   			if ($(this).val() == '')
   				label.show();
   		});
 	})
 }
})(jQuery);

/*
 * BusinessCard2 Tooltip written by Marc Grabanski
 * m@marcgrabanski.com
 */
(function ($) {
  $.fn.bc2tooltip = function(){
    var tooltip = $('<div id="bc2-tooltip" />').prependTo('.user_bottom');
    $('<div id="bc2-tooltip-top" />').append('<div id="bc2-tooltip-tip" />').appendTo(tooltip);
    $('<div id="bc2-tooltip-middle" />').append('<div id="bc2-tooltip-content" />').appendTo(tooltip);
    $('<div id="bc2-tooltip-bottom" />').appendTo(tooltip);
    var uOffset = $('.user_bottom').offset();
    return $(this).each(function(){
      var content = $(this).find('div');
      $(this).find('img:first')
        .hover(function(e){
          tipTop = $(this).offset().top - uOffset.top + 30;
          $("#bc2-tooltip-content").html( content.html() );
          tooltip.show().css('top', tipTop );
          
          tipLeft = $(this).offset().left - uOffset.left - 30;
          $("#bc2-tooltip-tip").css('left', tipLeft).show();
        },function(e) {
          tooltip.hide();
        });
    });
  }
  
  $(function(){
    $(".bc2-tooltip").bc2tooltip();
  });
  
  $.fn.clearForm = function() {
    return this.each(function() {
   var type = this.type, tag = this.tagName.toLowerCase();
   if (tag == 'form')
     return $(':input',this).clearForm();
   if (type == 'text' || type == 'password' || tag == 'textarea')
     this.value = '';
   else if (type == 'checkbox' || type == 'radio')
     this.checked = false;
   else if (tag == 'select')
     this.selectedIndex = -1;
    });
  };
})(jQuery);

/*
 * clearingInput: a jQuery plugin
 *
 * clearingInput is a simple jQuery plugin that provides example/label text
 * inside text inputs that automatically clears when the input is focused.
 * Common uses are for a hint/example, or as a label when space is limited.
 *
 * For usage and examples, visit:
 * http://github.com/alexrabarts/jquery-clearinginput
 *
 * Licensed under the MIT:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Copyright (c) 2008 Stateless Systems (http://statelesssystems.com)
 *
 * @author   Alex Rabarts (alexrabarts -at- gmail -dawt- com)
 * @requires jQuery v1.2 or later
 * @version  0.1.2
 */

(function ($) {
  
  $.extend($.fn, {
    clearingInput: function (options) {
      var defaults = {blurClass: 'blur'};

      options = $.extend(defaults, options);

      return this.each(function () {
        var input = $(this).addClass(options.blurClass);
        var form  = input.parents('form:first');
        var label, text;

        text = options.text || textFromLabel() || input.val();

        if (text) {
          input.val(text);

          input.blur(function () {
            if (input.val() === '') {
              input.addClass(options.blurClass).val(text);
            }
          }).focus(function () {
            if (input.val() === text) {
              input.val('');
            }
            input.removeClass(options.blurClass);
          });

          form.submit(function() {
            if (input.hasClass(options.blurClass)) {
              input.val('');
            }
          });

          input.blur();
        }

        function textFromLabel() {
          label = form.find('label[for=' + input.attr('id') + ']');
          // Position label off screen and use it for the input text
          return label ? label.css({position: 'absolute', left: '-9999px'}).text() : '';
        }
      });
    }
  });
})(jQuery);

// jGrowl http://www.stanlemon.net/projects/jgrowl.html

(function($){$.jGrowl=function(m,o){if($('#jGrowl').size()==0)
$('<div id="jGrowl"></div>').addClass($.jGrowl.defaults.position).appendTo('body');$('#jGrowl').jGrowl(m,o);};$.fn.jGrowl=function(m,o){if($.isFunction(this.each)){var args=arguments;return this.each(function(){var self=this;if($(this).data('jGrowl.instance')==undefined){$(this).data('jGrowl.instance',$.extend(new $.fn.jGrowl(),{notifications:[],element:null,interval:null}));$(this).data('jGrowl.instance').startup(this);}
if($.isFunction($(this).data('jGrowl.instance')[m])){$(this).data('jGrowl.instance')[m].apply($(this).data('jGrowl.instance'),$.makeArray(args).slice(1));}else{$(this).data('jGrowl.instance').create(m,o);}});};};$.extend($.fn.jGrowl.prototype,{defaults:{pool:0,header:'',group:'',sticky:false,position:'bottom-right',glue:'after',theme:'default',corners:'10px',check:250,life:3000,speed:'normal',easing:'swing',closer:true,closeTemplate:'&times;',closerTemplate:'<div>[ close all ]</div>',log:function(e,m,o){},beforeOpen:function(e,m,o){},open:function(e,m,o){},beforeClose:function(e,m,o){},close:function(e,m,o){},animateOpen:{opacity:'show'},animateClose:{opacity:'hide'}},notifications:[],element:null,interval:null,create:function(message,o){var o=$.extend({},this.defaults,o);this.notifications.push({message:message,options:o});o.log.apply(this.element,[this.element,message,o]);},render:function(notification){var self=this;var message=notification.message;var o=notification.options;var notification=$('<div class="jGrowl-notification ui-state-highlight ui-corner-all'+
((o.group!=undefined&&o.group!='')?' '+o.group:'')+'">'+'<div class="close">'+o.closeTemplate+'</div>'+'<div class="header">'+o.header+'</div>'+'<div class="jGrowl-message">'+message+'</div></div>').data("jGrowl",o).addClass(o.theme).children('div.close').bind("click.jGrowl",function(){$(this).parent().trigger('jGrowl.close');}).parent();$(notification).bind("mouseover.jGrowl",function(){$('div.jGrowl-notification',self.element).data("jGrowl.pause",true);}).bind("mouseout.jGrowl",function(){$('div.jGrowl-notification',self.element).data("jGrowl.pause",false);}).bind('jGrowl.beforeOpen',function(){if(o.beforeOpen.apply(notification,[notification,message,o,self.element])!=false){$(this).trigger('jGrowl.open');}}).bind('jGrowl.open',function(){if(o.open.apply(notification,[notification,message,o,self.element])!=false){if(o.glue=='after'){$('div.jGrowl-notification:last',self.element).after(notification);}else{$('div.jGrowl-notification:first',self.element).before(notification);}
$(this).animate(o.animateOpen,o.speed,o.easing,function(){if($.browser.msie&&(parseInt($(this).css('opacity'),10)===1||parseInt($(this).css('opacity'),10)===0))
this.style.removeAttribute('filter');$(this).data("jGrowl").created=new Date();});}}).bind('jGrowl.beforeClose',function(){if(o.beforeClose.apply(notification,[notification,message,o,self.element])!=false)
$(this).trigger('jGrowl.close');}).bind('jGrowl.close',function(){$(this).data('jGrowl.pause',true);$(this).animate(o.animateClose,o.speed,o.easing,function(){$(this).remove();var close=o.close.apply(notification,[notification,message,o,self.element]);if($.isFunction(close))
close.apply(notification,[notification,message,o,self.element]);});}).trigger('jGrowl.beforeOpen');if($.fn.corner!=undefined)$(notification).corner(o.corners);if($('div.jGrowl-notification:parent',self.element).size()>1&&$('div.jGrowl-closer',self.element).size()==0&&this.defaults.closer!=false){$(this.defaults.closerTemplate).addClass('jGrowl-closer ui-state-highlight ui-corner-all').addClass(this.defaults.theme).appendTo(self.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.jGrowl",function(){$(this).siblings().children('div.close').trigger("click.jGrowl");if($.isFunction(self.defaults.closer)){self.defaults.closer.apply($(this).parent()[0],[$(this).parent()[0]]);}});};},update:function(){$(this.element).find('div.jGrowl-notification:parent').each(function(){if($(this).data("jGrowl")!=undefined&&$(this).data("jGrowl").created!=undefined&&($(this).data("jGrowl").created.getTime()+$(this).data("jGrowl").life)<(new Date()).getTime()&&$(this).data("jGrowl").sticky!=true&&($(this).data("jGrowl.pause")==undefined||$(this).data("jGrowl.pause")!=true)){$(this).trigger('jGrowl.beforeClose');}});if(this.notifications.length>0&&(this.defaults.pool==0||$(this.element).find('div.jGrowl-notification:parent').size()<this.defaults.pool))
this.render(this.notifications.shift());if($(this.element).find('div.jGrowl-notification:parent').size()<2){$(this.element).find('div.jGrowl-closer').animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,function(){$(this).remove();});}},startup:function(e){this.element=$(e).addClass('jGrowl').append('<div class="jGrowl-notification"></div>');this.interval=setInterval(function(){$(e).data('jGrowl.instance').update();},this.defaults.check);if($.browser.msie&&parseInt($.browser.version)<7&&!window["XMLHttpRequest"]){$(this.element).addClass('ie6');}},shutdown:function(){$(this.element).removeClass('jGrowl').find('div.jGrowl-notification').remove();clearInterval(this.interval);},close:function(){$(this.element).find('div.jGrowl-notification').each(function(){$(this).trigger('jGrowl.beforeClose');});}});$.jGrowl.defaults=$.fn.jGrowl.prototype.defaults;})(jQuery);

/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
function makeTall(){   /*$('ul', this).css('display', 'block');*/ $('ul', this).slideDown('fast');  $('.user_nav-btn', this).addClass('active');  $('.user_nav-btn', this).removeClass('user_nav-btn'); $('.user_nav-foc', this).addClass('active-foc');  $('.user_nav-foc', this).removeClass('user_nav-foc'); }
function makeShort(){  /*$('ul', this).css('display', 'none');*/ $('ul', this).slideUp('fast'); $('.active', this).addClass('user_nav-btn'); $('.active', this).removeClass('active');  $('.active-foc', this).addClass('user_nav-foc'); $('.active-foc', this).removeClass('active-foc');  }	

(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);


/*
 * BusinessCard2 HTML Card written by Kurt Menne
 */
function onBefore() { $('#slide-title').html(""); $('#slide-description').hide();  } 
function onAfter() { $('#slide-title').html("").append(this.alt); $('#slide-desc_copy').html("").append(this.title); }

// Pause the cycle
 $('#pause').click(function() { $('#slideshow').cycle('pause'); $(this).hide(); $('#play').show(); return false; });
 // Resume the cycle
 $('#play').click(function() { $('#slideshow').cycle('resume', true); $(this).hide(); $('#pause').show(); return false; });

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
 }


/*
 * Custom Add This Button written by Kurt Menne
 */

 <!-- AddThis Button BEGIN -->
var addthis_config = {"data_track_clickback":true};

$(function() { $('.custom_button, .two_column').mouseenter(function() { 
	$('.two_column').fadeIn('fast'); $('.custom_button').addClass('active'); $(this).data('in', true); $('.two_column').data('hidden', false); }).mouseleave(function() { 
		$(this).data('in', false); setTimeout(hideMenu, delay); });
			var delay = 400;
			function hideMenu() {
				if (!$('.custom_button').data('in') && !$('.two_column').data('in') && !$('.two_column').data('hidden')) { 
					$('.two_column').fadeOut('fast'); $('.custom_button').removeClass('active'); $('.two_column').data('hidden', true); }
				}
	});
<!-- AddThis Button END -->

<!-- Card Button START -->
$(function() { $('.card_button, .card_dd_menu').mouseenter(function() {
        $('.card_dd_menu').fadeIn('fast'); $('.card_button').addClass('active');  $(this).data('in', true);  $('.card_dd_menu').data('hidden', false); }).mouseleave(function() {
        $(this).data('in', false);  setTimeout(hideMenu, delay);  });
    var delay = 400;
    function hideMenu() {
        if (!$('.card_button').data('in') && !$('.card_dd_menu').data('in') && !$('.card_dd_menu').data('hidden'))  {
            $('.card_dd_menu').fadeOut('fast');  $('.card_button').removeClass('active'); $('.card_dd_menu').data('hidden', true); }
    	}
});
<!-- Card Button END -->


/*
 * Youtube Chromeless Video Plugin
 * http://www.viget.com/
 *
 * Copyright (c) 2010 Trevor Davis
 * Dual licensed under the MIT and GPL licenses.
 * Uses the same license as jQuery, see:
 * http://jquery.org/license
 *
 * @version 0.2
 */
 
(function($) {  $.fn.ytchromeless = function(options){  var config = {  videoWidth  : '298', videoHeight : '172', videoIdBase : 'ytplayer', params : {  allowScriptAccess: 'always',  wmode: 'transparent' }  };  return this.each(function(i) {  var options    = $.extend(config, options),  $link      = $(this),  url        = $link.attr('href'), videoId    = $link.attr('id') || options.videoIdBase + i,  ytVideoId  = url.substr(31),  $video     = $link.wrap( '<div class="video-player"></div>' ).parent(),  $controls  = $('<div class="video-controls"></div>' ).appendTo( $video ), $toReplace = $('<div class="video"></div>').prependTo( $video ).attr('id', videoId),  $bar,  $indicator,  $loaded,  $mute, $play,  $seek,  player;  $video.bind({  'togglePlay' : function(){ $video.togglePlay(); },  'play'       : function(){ $video.play(); },  'pause'      : function(){ $video.pause(); },  'toggleMute' : function(){ $video.toggleMute(); },  'mute'       : function(){ $video.mute(); },  'unMute'     : function(){ $video.unMute(); },  'seek'       : function(){ $video.seek(); }, 'update' : function(){ $video.update(); }, 'cue' : function(){ player.cueVideoById( ytVideoId ); }  }); $video.togglePlay = function() { if( $play.hasClass('playing') ) {  $video.trigger('pause'); } else { $video.trigger('play'); } return false;  }; $video.play = function() {  player.playVideo();  $play.removeClass('paused').addClass('playing').attr('title','Pause'); };   $video.pause = function() { player.pauseVideo(); $play.removeClass('playing').addClass('paused').attr('title','Play'); };  $video.toggleMute = function() { if( $mute.hasClass('muted') ) { $video.trigger('unMute'); } else { $video.trigger('mute'); }  return false; };  $video.mute = function() { player.mute();  $mute.addClass('muted').attr('title','Un-Mute'); }; $video.unMute = function() {  player.unMute();  $mute.removeClass('muted').attr('title','Mute'); }; $video.seek = function(seekPosition) {  var seekToPosition = Math.round(player.getDuration() * seekPosition);  player.seekTo(seekToPosition, false);   }; $video.update = function() { if( player && player.getDuration ) { if( player.getPlayerState() === 1 ) { $video.play();  } else if ( player.getPlayerState() === 0 ) {  $video.pause(); }   if( player.getVideoBytesLoaded() > -1) { var loadedAmount = ( player.getVideoBytesLoaded() / player.getVideoBytesTotal())  * 100;  $loaded.css( 'width', loadedAmount + '%' );  } if( player.getCurrentTime() > 0 ) {  var videoPosition = ( player.getCurrentTime() / player.getDuration() ) * 100;  $indicator.css( 'left', videoPosition + '%' );  }  } }; onYouTubePlayerReady = function( videoId ) {  var $videoRef = $( document.getElementById( videoId ) ).parent(); setInterval(function(){  $videoRef.trigger('update'); }, 250); $videoRef.trigger('cue');  }; $video.init = function() {  swfobject.embedSWF( 'http://www.youtube.com/apiplayer?&enablejsapi=1&playerapiid=' + videoId, videoId,  options.videoWidth, options.videoHeight,  '8',  null,  null, options.params, { id: videoId }, function(){  player = document.getElementById( videoId );  } ); $video.addControls(); }; $video.addControls = function() { $play = $('<a/>', {  href: '#', 'class': 'play-pause', text: 'Play/Pause',  title: 'Play', click: function() {  $video.trigger('togglePlay'); return false;  }  }).appendTo( $controls );  $mute = $('<a/>', { href: '#',  'class': 'volume', text: 'Volume',  title: 'Mute',  click: function() {  $video.trigger('toggleMute'); return false;  }  }).appendTo( $controls );  $seek = $('<div/>', { 'class': 'status', click: function(e) { var skipTo      = e.pageX - $seek.offset().left, statusWidth = $seek.width(); $video.seek( skipTo); }  }).appendTo( $controls ); $bar  = $('<div class="bar"></div>').appendTo($seek); $loaded = $('<div class="loaded"></div>').appendTo($bar); $indicator = $('<span class="indicator"></span>').appendTo($bar); }; $video.init(); }); }; })(jQuery);


/**
 * This jQuery plugin displays pagination links inside the selected elements.
 * @author Gabriel Birke (birke *at* d-scribe *dot* de)
 * @version 2.1
 */
 (function($){
	$.PaginationCalculator = function(maxentries, opts) {
		this.maxentries = maxentries;
		this.opts = opts;
	}
	
	$.extend($.PaginationCalculator.prototype, {
		numPages:function() {
			return Math.ceil(this.maxentries/this.opts.items_per_page);
		},
		getInterval:function(current_page)  {
			var ne_half = Math.floor(this.opts.num_display_entries/2);
			var np = this.numPages();
			var upper_limit = np - this.opts.num_display_entries;
			var start = current_page > ne_half ? Math.max( Math.min(current_page - ne_half, upper_limit), 0 ) : 0;
			var end = current_page > ne_half?Math.min(current_page+ne_half + (this.opts.num_display_entries % 2), np):Math.min(this.opts.num_display_entries, np);
			return {start:start, end:end};
		}
	});
	
	$.PaginationRenderers = {}
	
	$.PaginationRenderers.defaultRenderer = function(maxentries, opts) {
		this.maxentries = maxentries;
		this.opts = opts;
		this.pc = new $.PaginationCalculator(maxentries, opts);
	}
	$.extend($.PaginationRenderers.defaultRenderer.prototype, {
		createLink:function(page_id, current_page, appendopts){
			var lnk, np = this.pc.numPages();
			page_id = page_id<0?0:(page_id<np?page_id:np-1); // Normalize page id to sane value
			appendopts = $.extend({text:page_id+1, classes:""}, appendopts||{});
			if(page_id == current_page){
				lnk = $("<span class='current'>" + appendopts.text + "</span>");
			}
			else
			{
				lnk = $("<a>" + appendopts.text + "</a>")
					.attr('href', this.opts.link_to.replace(/__id__/,page_id));
			}
			if(appendopts.classes){ lnk.addClass(appendopts.classes); }
			lnk.data('page_id', page_id);
			return lnk;
		},
		// Generate a range of numeric links 
		appendRange:function(container, current_page, start, end, opts) {
			var i;
			for(i=start; i<end; i++) {
				this.createLink(i, current_page, opts).appendTo(container);
			}
		},
		getLinks:function(current_page, eventHandler) {
			var begin, end,
				interval = this.pc.getInterval(current_page),
				np = this.pc.numPages(),
				fragment = $("<div class='pagination'></div>");
			
			// Generate "Previous"-Link
			if(this.opts.prev_text && (current_page > 0 || this.opts.prev_show_always)){
				fragment.append(this.createLink(current_page-1, current_page, {text:this.opts.prev_text, classes:"prev"}));
			}
			// Generate starting points
			if (interval.start > 0 && this.opts.num_edge_entries > 0)
			{
				end = Math.min(this.opts.num_edge_entries, interval.start);
				this.appendRange(fragment, current_page, 0, end, {classes:'sp'});
				if(this.opts.num_edge_entries < interval.start && this.opts.ellipse_text)
				{
					jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment);
				}
			}
			// Generate interval links
			this.appendRange(fragment, current_page, interval.start, interval.end);
			// Generate ending points
			if (interval.end < np && this.opts.num_edge_entries > 0)
			{
				if(np-this.opts.num_edge_entries > interval.end && this.opts.ellipse_text)
				{
					jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment);
				}
				begin = Math.max(np-this.opts.num_edge_entries, interval.end);
				this.appendRange(fragment, current_page, begin, np, {classes:'ep'});
				
			}
			// Generate "Next"-Link
			if(this.opts.next_text && (current_page < np-1 || this.opts.next_show_always)){
				fragment.append(this.createLink(current_page+1, current_page, {text:this.opts.next_text, classes:"next"}));
			}
			$('a', fragment).click(eventHandler);
			return fragment;
		}
	});
	
	// Extend jQuery
	$.fn.pagination = function(maxentries, opts){
		
		// Initialize options with default values
		opts = jQuery.extend({
			items_per_page:10,
			num_display_entries:11,
			current_page:0,
			num_edge_entries:1,
			link_to:"#",
			prev_text:"Prev",
			next_text:"Next",
			ellipse_text:"...",
			prev_show_always:true,
			next_show_always:true,
			renderer:"defaultRenderer",
			callback:function(){return false;}
		},opts||{});
		
		var containers = this,
			renderer, links, current_page;
		
		function paginationClickHandler(evt){
			var links, 
				new_current_page = $(evt.target).data('page_id'),
				continuePropagation = selectPage(new_current_page);
			if (!continuePropagation) {
				evt.stopPropagation();
			}
			return continuePropagation;
		}
		
		function selectPage(new_current_page) {
			// update the link display of a all containers
			containers.data('current_page', new_current_page);
			links = renderer.getLinks(new_current_page, paginationClickHandler);
			containers.empty();
			links.appendTo(containers);
			// call the callback and propagate the event if it does not return false
			var continuePropagation = opts.callback(new_current_page, containers);
			return continuePropagation;
		}
		
		// -----------------------------------
		// Initialize containers
		// -----------------------------------
		current_page = opts.current_page;
		containers.data('current_page', current_page);
		// Create a sane value for maxentries and items_per_page
		maxentries = (!maxentries || maxentries < 0)?1:maxentries;
		opts.items_per_page = (!opts.items_per_page || opts.items_per_page < 0)?1:opts.items_per_page;
		
		if(!$.PaginationRenderers[opts.renderer])
		{
			throw new ReferenceError("Pagination renderer '" + opts.renderer + "' was not found in jQuery.PaginationRenderers object.");
		}
		renderer = new $.PaginationRenderers[opts.renderer](maxentries, opts);
		
		// Attach control events to the DOM elements
		var pc = new $.PaginationCalculator(maxentries, opts);
		var np = pc.numPages();
		containers.bind('setPage', {numPages:np}, function(evt, page_id) { 
				if(page_id >= 0 && page_id < evt.data.numPages) {
					selectPage(page_id); return false;
				}
		});
		containers.bind('prevPage', function(evt){
				var current_page = $(this).data('current_page');
				if (current_page > 0) {
					selectPage(current_page - 1);
				}
				return false;
		});
		containers.bind('nextPage', {numPages:np}, function(evt){
				var current_page = $(this).data('current_page');
				if(current_page < evt.data.numPages - 1) {
					selectPage(current_page + 1);
				}
				return false;
		});
		
		// When all initialisation is done, draw the links
		links = renderer.getLinks(current_page, paginationClickHandler);
		containers.empty();
		links.appendTo(containers);
		// call callback function
		opts.callback(current_page, containers);
	} // End of $.fn.pagination block
	
})(jQuery);

