/**
 * jQuery.LocalScroll
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 6/3/2008
 *
 * @projectDescription Animated scrolling navigation, using anchors.
 * http://flesler.blogspot.com/2007/10/jquerylocalscroll-10.html
 */

/**
 * Copyright (c) 2006/2007 Sam Collett (http://www.texotela.co.uk)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */

/**
 *  jquery.popupt
 *  (c) 2008 Semooh (http://semooh.jp/)
 *
 *  Dual licensed under the MIT (MIT-LICENSE.txt)
 *  and GPL (GPL-LICENSE.txt) licenses.
 *
 **/
(function($){ var URI = location.href.replace(/#.*/,''); var $localScroll = $.localScroll = function( settings ){ $('body').localScroll( settings );}; $localScroll.defaults = { duration:1000, axis:'y', event:'click', stop:true
}; $localScroll.hash = function( settings ){ settings = $.extend( {}, $localScroll.defaults, settings ); settings.hash = false; if( location.hash )
setTimeout(function(){ scroll( 0, location, settings );}, 0 );}; var $scrollTo = $.scrollTo = function( target, duration, settings ){ $scrollTo.window().scrollTo( target, duration, settings );}; $scrollTo.defaults = { axis:'y', duration:1
}; $scrollTo.window = function(){ return $( $.browser.safari ? 'body' : 'html' );}; $.fn.extend({ localScroll: function( settings ){ settings = $.extend( {}, $localScroll.defaults, settings ); return ( settings.persistent || settings.lazy )
? this.bind( settings.event, function( e ){ var a = $([e.target, e.target.parentNode]).filter(filter)[0]; a && scroll( e, a, settings );})
: this.find('a,area')
.filter( filter ).bind( settings.event, function(e){ scroll( e, this, settings );}).end()
.end(); function filter(){ return !!this.href && !!this.hash && this.href.replace(this.hash,'') == URI && (!settings.filter || $(this).is( settings.filter ));};}, scrollTo: function( target, duration, settings ){ if( typeof duration == 'object' ){ settings = duration; duration = 0;}
settings = $.extend( {}, $scrollTo.defaults, settings ); duration = duration || settings.speed || settings.duration; settings.queue = settings.queue && settings.axis.length > 1; if( settings.queue )
duration /= 2; settings.offset = both( settings.offset ); settings.over = both( settings.over ); return this.each(function(){ var elem = this, $elem = $(elem), t = target, toff, attr = {}, win = $elem.is('html,body'); switch( typeof t ){ case 'number':
case 'string':
if( /^([+-]=)?\d+(px)?$/.test(t) ){ t = both( t ); break;}
t = $(t,this); case 'object':
if( t.is || t.style )
toff = (t = $(t)).offset();}
$.each( settings.axis.split(''), function( i, axis ){ var Pos = axis == 'x' ? 'Left' : 'Top', pos = Pos.toLowerCase(), key = 'scroll' + Pos, act = elem[key], Dim = axis == 'x' ? 'Width' : 'Height', dim = Dim.toLowerCase(); if( toff ){ attr[key] = toff[pos] + ( win ? 0 : act - $elem.offset()[pos] ); if( settings.margin ){ attr[key] -= parseInt(t.css('margin'+Pos)) || 0; attr[key] -= parseInt(t.css('border'+Pos+'Width')) || 0;}
attr[key] += settings.offset[pos] || 0; if( settings.over[pos] )
attr[key] += t[dim]() * settings.over[pos];}else
attr[key] = t[pos]; if( /^\d+$/.test(attr[key]) )
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max(Dim) ); if( !i && settings.queue ){ if( act != attr[key] )
animate( settings.onAfterFirst ); delete attr[key];}
}); animate( settings.onAfter ); function animate( callback ){ $elem.animate( attr, duration, settings.easing, callback && function(){ callback.call(this, target);});}; function max( Dim ){ var el = win ? $.browser.opera ? document.body : document.documentElement : elem; return el['scroll'+Dim] - el['client'+Dim];};});}, jQIR: function(format, path, onload){ if(!document.images) return this; path = path || ""; this.each( function()
{ var img = $("<img>"), el = jQuery(this); var file; var re = /(?:{src\:)(\S+)(?:})/i; var m = this.className.match(re); if(m)
{ file = path + m[1];}
else
{ file = path + this.id + "." + format;}
jQuery(img).attr( { src: file, alt: el.text()
}).load(typeof onload == "function" ? onload : function(){} ); var a = el.find("a"); var toAppend = a.length ? a.empty().append(img) : img; el.empty().append(toAppend);}
)
return this;}, imghover: function(opt){ return this.each(function() { opt = $.extend({ prefix: '', suffix: '_on', src: '', btnOnly: true, fade: false, fadeSpeed: 400
}, opt || {}); var node = $(this); if(!node.is('img')&&!node.is(':image')){ var sel = 'img,:image'; if (opt.btnOnly) sel = 'a '+sel; node.find(sel).imghover(opt); return;}
var orgImg = node.attr('src'); var hoverImg; if(opt.src){ hoverImg = opt.src;}else{ hoverImg = orgImg; if(opt.prefix){ var pos = hoverImg.lastIndexOf('/'); if(pos>0){ hoverImg = hoverImg.substr(0,pos-1)+opt.prefix+hoverImg.substr(pos-1);}else{ hoverImg = opt.prefix+hoverImg;}
}
if(opt.suffix){ var pos = hoverImg.lastIndexOf('.'); if(pos>0){ hoverImg = hoverImg.substr(0,pos)+opt.suffix+hoverImg.substr(pos);}else{ hoverImg = hoverImg+opt.suffix;}
}
}
if(opt.fade){ var offset = node.offset(); var hover = node.clone(true); hover.attr('src', hoverImg); hover.css({ position: 'absolute', left: offset.left, top: offset.top, zIndex: 100
}).hide().insertAfter(node); node.mouseover( function(){ var offset=node.offset(); hover.css({left: offset.left, top: offset.top}); hover.fadeIn(opt.fadeSpeed); node.fadeOut(opt.fadeSpeed,function(){node.show()});} ); hover.mouseout( function(){ node.fadeIn(opt.fadeSpeed); hover.fadeOut(opt.fadeSpeed);} );}else{ node.hover( function(){node.attr('src', hoverImg)}, function(){node.attr('src', orgImg)} );}
});}
}); function scroll( e, link, settings ){ var id = link.hash.slice(1), elem = document.getElementById(id) || document.getElementsByName(id)[0]; if ( elem ){ e && e.preventDefault(); var $target = $( settings.target || $.scrollTo.window() ); if( settings.lock && $target.is(':animated') || settings.onBefore && settings.onBefore.call(link, e, elem, $target) === false ) return; if( settings.stop )
$target.queue('fx',[]).stop(); $target
.scrollTo( elem, settings )
.trigger('notify.serialScroll',[elem]); if( settings.hash )
$target.queue(function(){ location = link.hash; $(this).dequeue();});}
}; function both( val ){ return typeof val == 'object' ? val : { top:val, left:val };};})(jQuery);

( function( $ ) { $.scrollFollow = function ( box, options )
{ box = $( box ); var position = box.css( 'position' ); function ani()
{ box.queue( [ ] ); var viewportHeight = parseInt( $( window ).height() ); var pageScroll = parseInt( $( document ).scrollTop() ); var parentTop = parseInt( box.cont.offset().top ); var parentHeight = parseInt( box.cont.attr( 'offsetHeight' ) ); var boxHeight = parseInt( box.attr( 'offsetHeight' ) + ( parseInt( box.css( 'marginTop' ) ) || 0 ) + ( parseInt( box.css( 'marginBottom' ) ) || 0 ) ); var aniTop; if ( isActive )
{ if ( options.relativeTo == 'top' )
{ if ( box.initialOffsetTop >= ( pageScroll + options.offset ) )
{ aniTop = box.initialTop;}
else
{ aniTop = Math.min( ( Math.max( ( -parentTop ), ( pageScroll - box.initialOffsetTop + box.initialTop ) ) + options.offset ), ( parentHeight - boxHeight - box.paddingAdjustment ) );}
}
else if ( options.relativeTo == 'bottom' )
{ if ( ( box.initialOffsetTop + boxHeight ) >= ( pageScroll + options.offset + viewportHeight ) )
{ aniTop = box.initialTop;}
else
{ aniTop = Math.min( ( pageScroll + viewportHeight - boxHeight - options.offset ), ( parentHeight - boxHeight ) );}
}
if ( ( new Date().getTime() - box.lastScroll ) >= ( options.delay - 20 ) )
{ box.animate( { top: aniTop
}, options.speed, options.easing );}
}
}; var isActive = true; if ( $.cookie != undefined )
{ if( $.cookie( 'scrollFollowSetting' + box.attr( 'id' ) ) == 'false' )
{ var isActive = false; $( '#' + options.killSwitch ).text( options.offText )
.toggle( function ()
{ isActive = true; $( this ).text( options.onText ); $.cookie( 'scrollFollowSetting' + box.attr( 'id' ), true, { expires: 365, path: '/'} ); ani();}, function ()
{ isActive = false; $( this ).text( options.offText ); box.animate( { top: box.initialTop
}, options.speed, options.easing ); $.cookie( 'scrollFollowSetting' + box.attr( 'id' ), false, { expires: 365, path: '/'} );} );}
else
{ $( '#' + options.killSwitch ).text( options.onText )
.toggle( function ()
{ isActive = false; $( this ).text( options.offText ); box.animate( { top: box.initialTop
}, 0 ); $.cookie( 'scrollFollowSetting' + box.attr( 'id' ), false, { expires: 365, path: '/'} );}, function ()
{ isActive = true; $( this ).text( options.onText ); $.cookie( 'scrollFollowSetting' + box.attr( 'id' ), true, { expires: 365, path: '/'} ); ani();} );}
}
if ( options.container == '')
{ box.cont = box.parent();}
else
{ box.cont = $( '#' + options.container );}
box.initialOffsetTop = parseInt( box.offset().top ); box.initialTop = parseInt( box.css( 'top' ) ) || 0; if ( box.css( 'position' ) == 'relative' )
{ box.paddingAdjustment = parseInt( box.cont.css( 'paddingTop' ) ) + parseInt( box.cont.css( 'paddingBottom' ) );}
else
{ box.paddingAdjustment = 0;}
$( window ).scroll( function ()
{ $.fn.scrollFollow.interval = setTimeout( function(){ ani();} , options.delay ); box.lastScroll = new Date().getTime();} ); $( window ).resize( function ()
{ $.fn.scrollFollow.interval = setTimeout( function(){ ani();} , options.delay ); box.lastScroll = new Date().getTime();} ); box.lastScroll = 0; ani();}; $.fn.scrollFollow = function ( options )
{ options = options || {}; options.relativeTo = options.relativeTo || 'top'; options.speed = options.speed || 500; options.offset = options.offset || 0; options.easing = options.easing || 'swing'; options.container = options.container || this.parent().attr( 'id' ); options.killSwitch = options.killSwitch || 'killSwitch'; options.onText = options.onText || 'Turn Slide Off'; options.offText = options.offText || 'Turn Slide On'; options.delay = options.delay || 0; this.each( function()
{ new $.scrollFollow( this, options );} ); return this;};})( jQuery ); 

$(document).ready(function(){
	$.localScroll();
	$(".jqir_png").jQIR("png", "/img/");
	$('#flash').cycle({
		fx:    'fade', 
        speed:  2500 
		}
	);
	$('#topics').cycle({ fx: 'fade' });
});
