/**
 * Twit
 *  jQuery Plugin to Display Twitter Tweets on a Blog.
 *  https://code.google.com/p/jquery-twit/
 *
 * Copyright (c) 2009 Yusuke Horie
 *
 * Released under the MIT License:
 * https://www.opensource.org/licenses/mit-license.php
 *
 * Since  : 0.1.0 - 08/26/2009
 * Version: 0.1.0 - 08/26/2009
 */
(function(jQuery){var _i=0;jQuery.fn.twit=function(user,options){if(typeof user!='string')return this;var opts=jQuery.extend({},jQuery.fn.twit.defaults,options),c=jQuery.isFunction(opts.callback)?opts.callback:_callback,url='',params={};opts.user=user;url='https://twitter.com/statuses/user_timeline/'+opts.user+'.json';params.count=opts.count;return this.each(function(i,e){var $e=$(e);if(!$e.hasClass('twit'))$e.addClass('twit');jQuery.ajax({url:url,data:params,dataType:'jsonp',success:function(o){c.apply(this,[(o.results)?o.results:o,e,opts])}})})};jQuery.fn.twit.defaults={user:null,callback:null,icon:true,username:true,text:true,count:200,limit:7,label:'Twitter',title:''};var _callback=function(o,e,opts){var $this=$(e);if(!o||o.length==0||$this.length==0)return false;$this.data('_inc',1);_i++;var username=o[0].user.screen_name,icon=o[0].user.profile_image_url;var h='<div class="twitHeader">'+' <span class="twitLabel">'+opts.label+'</span>&nbsp;&nbsp;'+' <span class="twitTitle">'+opts.title+'</span>'+'</div>';if(opts.icon||opts.username){h+='<div class="twitUser">';if(opts.icon)h+=' <a href="https://twitter.com/'+username+'/">'+'  <img src="'+icon+'" alt="'+username+'" title="'+username+'" style="vertical-align:middle;" />'+' </a>&nbsp;&nbsp;';if(opts.username)h+='<a href="https://twitter.com/'+username+'/">'+username+'</a>';h+='</div>'}h+='<ul class="twitBody" id="twitList'+_i+'">'+_build(o,$this,opts)+'</ul>';$this.html(h);$('#twitList'+_i+' a.twitEntryShow').live('click.twitEntryShow'+_i,function(event){event.preventDefault();var $t=$(this);$t.parent().fadeOut(400,function(){var i=$this.data('_inc');i++;$this.data('_inc',i);if($t.hasClass('twitEntryAll')){$t.die('click.twitEntryShow'+_i);var start=(i*opts.limit)-opts.limit;$(this).after(_build(o,$this,opts,start,o.length)).remove()}else{$(this).after(_build(o,$this,opts)).remove()}})})};var _build=function(o,$t,opts,s,e){var h='',inc=$t.data('_inc'),start=s||(inc*opts.limit)-opts.limit,end=e||((o.length>start+opts.limit)?start+opts.limit:o.length);for(var i=start;i<end;i++){var t=o[i],username=t.user.screen_name,icon=t.user.profile_image_url;h+='<li class="twitEntry">';if(opts.text){var text=t.text.replace(/(https?:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/,function(u){var shortUrl=(u.length>30)?u.substr(0,30)+'...':u;return'<a href="'+u+'">'+shortUrl+'</a>'}).replace(/@([a-zA-Z_]+)/g,'@<a href="https://twitter.com/$1">$1</a>').replace(/(?:^|\s)#([^\s\.\+:!]+)/g,function(a,u){return' <a href="https://twitter.com/search?q='+encodeURIComponent(u)+'">#'+u+'</a>'});h+=' <span>'+text+'</span>'}h+='</li>'}if(o.length>end){h+='<li class="twitNavi">'+'<a href="#" class="twitEntryShow">more</a> &nbsp;/&nbsp;';if(o.length>opts.limit)h+='<a href="#" class="twitEntryShow twitEntryAll">all</a>';h+='</li>'}return h}})(jQuery);



/**
 * SimpleFlame Content rotator
 * Version 1.0
 *
 * Available effects:
 *  - if UI effects have been added: 'blind', 'bounce', 'clip', 'drop', 'explode', 'fold', 'highlight', 'puff', 'pulsate', 'scale', 'shake', 'size', 'slide', 'transfer'
 *  - basic effects from $: fadeIn, fadeOut, show, hide, slideUp, slideDown
 * 
 * Settings:
 *  - item : selector for rotator item ( default : 'li' )
 *  - activeClass : active item indicator ( default : 'active' )
 *  - duration : duration cycle in miliseconds ( default : 5000 )
 *  - autorotate : bool ( default: true )
 *  - effectIn : effect triggered on showing new item  (default: fadeIn)
 *  - optionsIn : additional options used in show transitio (default: { })
 *  - speedIn' : effectIn speed	( default : normal )
 *  - effectOut' : effect triggered on hiding old item ( default : fadeOut )
 *  - optionsOut' : additional options used in hide transition ( default : {} )
 *  - speedOut' : effectOut speed ( default : normal )
 *  - random : bool - should items be randomized on page load ( default : false )
 */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(6($){6 11(g){4 i=g.Z;8(i===0){S w}1m(--i){4 j=1e.1k(1e.H()*(i+1));4 1i=g[i];4 1g=g[j];g[i]=1g;g[j]=1i}}4 9=6(V,h){2.3={\'d\':\'L\',\'c\':\'O\',\'12\':1y,\'p\':m,\'q\':\'1t\',\'1d\':{},\'D\':\'W\',\'u\':\'1s\',\'15\':{},\'I\':\'W\',\'H\':w};$.1r(2.3,h);2.$b=$(V);2.Y()};9.l.Y=6(){2.$b.s(\'z-7\');2.$A=$(\'<1v 17="z-1w" />\');2.$b.1z(2.$A);2.$A.C(2.$b);2.$v=$(\'<1q 17="z-v" />\');2.$A.C(2.$v);2.$7=2.$b.1x(2.3.d);8(2.3.H===m){2.$7=2.$7.1A();11(2.$7);2.$b.C(2.$7)}2.$e=2.$7.B(2.$7.1p(\'.\'+2.3.c));8(2.$e<0){2.$e=0}4 5=2;2.$7.s(\'z-d\').16(6(B,d){4 t=$(\'<L><a 1n="#">\'+1o(B+1,10)+\'</a></L>\');5.$v.C(t);t.1f(\'a\').F(\'d\',d).1G(\'1S\',{5:5},5.t)});2.x(2.$e,m);8(2.3.p){2.p()}};9.l.t=6(J){J.1U();4 5=J.F.5;5.T();5.$U=m;4 n=5.$7.B($(2).F(\'d\'));5.x(n)};9.l.x=6(n){4 18=1B[1]||w;4 c=2.3.c;4 k=2.$7.Q(2.$e);4 f=2.$7.Q(n);4 N=6(){k.R(c)};4 E=6(){f.s(c).1j(\'1h\',10)};4 M=[\'1Q\',\'1V\',\'1X\',\'1Y\',\'1W\',\'1R\',\'1O\',\'1P\',\'1F\',\'1E\',\'1C\',\'1D\',\'1H\',\'1I\'];8(18===m){k.R(c).K();f.s(c).G()}o{8($.19(2.3.u,M)>-1){k.K(2.3.u,2.3.15,2.3.I,N)}o 8($.1a(k[2.3.u])){k[2.3.u](2.3.I,N)}o{1c"1b K 14"}f.1j(\'1h\',1L);8($.19(2.3.q,M)>-1){f.G(2.3.q,2.3.1d,2.3.D,E)}o 8($.1a(f[2.3.q])){f[2.3.q](2.3.D,E)}o{1c"1b G 14"}}2.$v.1f(\'a\').R(\'O\').Q(n).s(\'O\');2.$e=n};9.l.p=6(){2.$U=w;4 5=2;2.$b.1K(6(){5.T()});2.$b.1J(6(){5.P()});2.P()};9.l.P=6(){8(2.$U===m){S}4 5=2;2.$X=13.1N(6(){4 y=5.$e+1;8(y===5.$7.Z){y=0}5.x(y)},2.3.12)};9.l.T=6(){8(2.3.p){13.1T(2.$X)}};$.1l.9=6(h){h=h||{};S 2.16(6(){4 r=1u 9(2,h)})}})(1M);',62,123,'||this|settings|var|self|function|items|if|sfRotator||container|activeClass|item|current|newItem|myArray|options|||oldItem|prototype|true|position|else|autorotate|effectIn||addClass|trigger|effectOut|controls|false|activate|next|sf|wrapper|index|append|speedIn|onShow|data|show|random|speedOut|event|hide|li|effects|onHide|active|startAutorotate|eq|removeClass|return|stopAutorotate|rotationTerminated|el|normal|rotationInterval|build|length||fisherYates|duration|window|transition|optionsOut|each|class|instant|inArray|isFunction|Unsupported|throw|optionsIn|Math|find|tempj|zIndex|tempi|css|floor|fn|while|href|parseInt|filter|ul|extend|fadeOut|fadeIn|new|div|rotator|children|5000|before|detach|arguments|shake|size|scale|pulsate|bind|slide|transfer|mouseleave|mouseenter|100|jQuery|setInterval|highlight|puff|blind|fold|click|clearInterval|preventDefault|bounce|explode|clip|drop'.split('|'),0,{}));

/*!
 * (v) Compact labels plugin
 * Takes one option: labelOpacity [default: true] set to false to disable label opacity change on empty input focus
 */
(function($){$.fn.compactize=function(options){var defaults={labelOpacity:true};options=$.extend(defaults,options);return this.each(function(){var label=$(this),input=$('#'+label.attr('for'));input.focus(function(){if(options.labelOpacity){if(input.val()===''){label.css('opacity','0.5');}}else{label.hide();}});if(options.labelOpacity){input.keydown(function(){label.hide();label.css('opacity',1);});} input.blur(function(){if(input.val()===''){label.show();} if(options.labelOpacity){label.css('opacity',1);}});window.setTimeout(function(){if(input.val()===''){label.show();}},50);});};})(jQuery);

/*!
 * (v) hrefID jQuery extention
 * returns a valid #hash string from link href attribute in Internet Explorer
 */
(function($){$.fn.extend({hrefId:function(){return $(this).attr('href').substr($(this).attr('href').indexOf('#'));}});})(jQuery);

/*!
 * Scripts
 *
 */
jQuery(function($) {
// Rotator support
	$('#rotator-a li').not('li:first-child').hide();
	$('#rotator-a').sfRotator();

	var Engine = {
		utils : {
			links : function(){
				$('a[rel*=external]').click(function(e){
					e.preventDefault();
					window.open($(this).attr('href'));
				});
			},
			mails : function(){
				$('a[href^=mailto:]').each(function(){
					var mail = $(this).attr('href').replace('mailto:','');
					var replaced = mail.replace('/at/','@');
					$(this).attr('href','mailto:'+replaced);
					if($(this).text() == mail) {
						$(this).text(replaced);
					}
				});
			}
		},
		ui : {
			forms : function(){
				$('.search-form label, .newsletter-form label').compactize();
			}
		},
		
		tweaks : {
				tweets : function(){
					// check for div
					if ($('#tweets').size() === 0) { return;}
					
						$('#tweets').twit('simpleflame', {
						  limit: 5,
						  icon: false
						});
					} // tweets	
					
					
		}// tweaks
	};

	Engine.utils.links();
	Engine.utils.mails();
	Engine.ui.forms();
	
	Engine.tweaks.tweets();
	
});
