
/******************************************************************************/
/*********************************** EASING ***********************************/
/******************************************************************************/

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 *
 * Open source under the BSD License.
 *
 * Copyright 2008 George McGinley Smith
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 *
 * Neither the name of the author nor the names of contributors may be used to endorse
 * or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
$.easing.jswing = $.easing.swing;

$.extend( $.easing, {
	def: "easeOutQuad",
	swing: function ( x, t, b, c, d ) {
		return $.easing[ $.easing.def ]( x, t, b, c, d );
	},
	easeInQuad: function ( x, t, b, c, d ) {
		return c * ( t /= d ) * t + b;
	},
	easeOutQuad: function ( x, t, b, c, d ) {
		return -c * ( t /= d ) * ( t - 2 ) + b;
	},
	easeInOutQuad: function ( x, t, b, c, d ) {
		if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t + b;
		return -c / 2 * ( ( --t ) * ( t-2 ) - 1) + b;
	},
	easeInCubic: function ( x, t, b, c, d ) {
		return c * ( t /= d ) * t * t + b;
	},
	easeOutCubic: function ( x, t, b, c, d ) {
		return c * ( ( t = t / d - 1 ) * t * t + 1 ) + b;
	},
	easeInOutCubic: function ( x, t, b, c, d ) {
		if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t * t + b;
		return c / 2 * ( ( t -= 2 ) * t * t + 2) + b;
	},
	easeInQuart: function ( x, t, b, c, d ) {
		return c * ( t /= d ) * t * t * t + b;
	},
	easeOutQuart: function ( x, t, b, c, d ) {
		return -c * ( ( t = t / d - 1 ) * t * t * t - 1) + b;
	},
	easeInOutQuart: function ( x, t, b, c, d ) {
		if ( (t /= d / 2 ) < 1 ) return c / 2 * t * t * t * t + b;
		return -c / 2 * ( ( t -= 2 ) * t * t * t - 2) + b;
	},
	easeInQuint: function ( x, t, b, c, d ) {
		return c * ( t /= d ) * t * t * t * t + b;
	},
	easeOutQuint: function ( x, t, b, c, d ) {
		return c * ( ( t = t / d - 1 ) * t * t * t * t + 1) + b;
	},
	easeInOutQuint: function ( x, t, b, c, d ) {
		if ( ( t /= d / 2 ) < 1 ) return c / 2 * t * t  * t * t * t + b;
		return c / 2 * ( ( t -= 2 ) * t * t * t * t + 2) + b;
	},
	easeInSine: function ( x, t, b, c, d ) {
		return -c * Math.cos( t / d * ( Math.PI / 2 ) ) + c + b;
	},
	easeOutSine: function ( x, t, b, c, d ) {
		return c * Math.sin( t / d * ( Math.PI /2 ) ) + b;
	},
	easeInOutSine: function ( x, t, b, c, d ) {
		return -c / 2 * ( Math.cos( Math.PI * t / d ) - 1 ) + b;
	},
	easeInExpo: function ( x, t, b, c, d ) {
		return ( t==0 ) ? b : c * Math.pow( 2, 10 * ( t / d - 1) ) + b;
	},
	easeOutExpo: function ( x, t, b, c, d ) {
		return ( t==d ) ? b + c : c * ( -Math.pow( 2, -10 * t / d) + 1) + b;
	},
	easeInOutExpo: function ( x, t, b, c, d ) {
		if ( t==0 ) return b;
		if ( t==d ) return b + c;
		if ( ( t /= d / 2) < 1) return c / 2 * Math.pow( 2, 10 * (t - 1) ) + b;
		return c / 2 * ( -Math.pow( 2, -10 * --t ) + 2 ) + b;
	},
	easeInCirc: function ( x, t, b, c, d ) {
		return -c * ( Math.sqrt( 1 - ( t /= d ) * t ) - 1 ) + b;
	},
	easeOutCirc: function ( x, t, b, c, d ) {
		return c * Math.sqrt( 1 - ( t = t / d - 1 ) * t ) + b;
	},
	easeInOutCirc: function ( x, t, b, c, d ) {
		if ( ( t /= d / 2) < 1 ) return -c / 2 * ( Math.sqrt( 1 - t * t ) - 1 ) + b;
		return c / 2 * ( Math.sqrt( 1 - ( t -= 2 ) * t ) + 1 ) + b;
	},
	easeInElastic: function ( x, t, b, c, d ) {
		var s = 1.70158,
			p = d * 0.3,
			a = c;
		if ( t == 0 ) return b;
		if ( ( t /= d ) == 1 ) return b+c;
		if ( a < Math.abs( c ) ) {
			a = c;
			s = p / 4;
		} else {
			s = p / ( 2 * Math.PI ) * Math.asin( c / a );
		}
		return - ( a * Math.pow( 2, 10 * ( t -= 1 ) ) * Math.sin( ( t * d - s) * ( 2 * Math.PI ) / p ) ) + b;
	},
	easeOutElastic: function ( x, t, b, c, d ) {
		var s = 1.70158,
			p = d * 0.3,
			a = c;
		if ( t == 0 ) return b;
		if ( ( t /= d ) == 1 ) return b+c;
		if ( a < Math.abs( c ) ) {
			a = c;
			s = p / 4;
		} else {
			s = p / ( 2 * Math.PI ) * Math.asin( c / a );
		}
		return a * Math.pow( 2, -10 * t ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) + c + b;
	},
	easeInOutElastic: function ( x, t, b, c, d ) {
		var s = 1.70158,
			p = d * ( 0.3 * 1.5 ),
			a = c;
		if ( t == 0 ) return b;
		if ( ( t /= d / 2 ) == 2 ) return b+c;
		if ( a < Math.abs( c ) ) {
			a = c;
			s = p / 4;
		} else {
			s = p / ( 2 * Math.PI ) * Math.asin( c / a );
		}
		if ( t < 1 ) return -.5 * ( a * Math.pow( 2, 10 * ( t -= 1 ) ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) ) + b;
		return a * Math.pow( 2, -10 * ( t -= 1 ) ) * Math.sin( ( t * d - s ) * ( 2 * Math.PI ) / p ) *.5 + c + b;
	},
	easeInBack: function ( x, t, b, c, d, s ) {
		if ( s == undefined ) s = 1.70158;
		return c * ( t /= d ) * t * ( ( s+1 ) * t - s ) + b;
	},
	easeOutBack: function ( x, t, b, c, d, s ) {
		if ( s == undefined ) s = 1.70158;
		return c * ( ( t = t / d - 1 ) * t * ( ( s + 1 ) * t + s) + 1) + b;
	},
	easeInOutBack: function ( x, t, b, c, d, s ) {
		if ( s == undefined ) s = 1.70158;
		if ( ( t /= d / 2 ) < 1 ) return c / 2 * ( t * t * ( ( ( s *= 1.525 ) + 1 ) * t - s ) ) + b;
		return c / 2 * ( ( t -= 2 ) * t * ( ( ( s *= 1.525 ) + 1 ) * t + s) + 2) + b;
	},
	easeInBounce: function ( x, t, b, c, d ) {
		return c - $.easing.easeOutBounce( x, d - t, 0, c, d ) + b;
	},
	easeOutBounce: function ( x, t, b, c, d ) {
		if ( ( t /= d ) < ( 1 / 2.75 ) ) {
			return c * ( 7.5625 * t * t ) + b;
		} else if ( t < ( 2 / 2.75 ) ) {
			return c * ( 7.5625 * ( t -= ( 1.5 / 2.75 ) ) * t + .75 ) + b;
		} else if ( t < ( 2.5 / 2.75 ) ) {
			return c * ( 7.5625 * ( t -= ( 2.25/ 2.75 ) ) * t + .9375 ) + b;
		} else {
			return c * ( 7.5625 * ( t -= ( 2.625 / 2.75 ) ) * t + .984375 ) + b;
		}
	},
	easeInOutBounce: function ( x, t, b, c, d ) {
		if ( t < d / 2 ) return $.easing.easeInBounce( x, t * 2, 0, c, d ) * .5 + b;
		return $.easing.easeOutBounce( x, t * 2 - d, 0, c, d ) * .5 + c * .5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 *
 * Open source under the BSD License.
 *
 * Copyright 2001 Robert Penner
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this list of
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list
 * of conditions and the following disclaimer in the documentation and/or other materials
 * provided with the distribution.
 *
 * Neither the name of the author nor the names of contributors may be used to endorse
 * or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 * OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

/**
 * jQuery Masonry v2.1.0
 * A dynamic layout plugin for jQuery
 * The flip-side of CSS Floats
 * http://masonry.desandro.com
 *
 * Licensed under the MIT license.
 * Copyright 2011 David DeSandro
 */
(function(a,b,c){var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()};var f=["position","height"];b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[],this.reloadItems();var d=this.element[0].style;this.originalStyle={};for(var e=0,g=f.length;e<g;e++){var h=f[e];this.originalStyle[h]=d[h]||""}this.element.css({position:"relative"}),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top"),10)},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var i=this;setTimeout(function(){i.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){i.resize()})},_init:function(a){this._getColumns(),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,b){for(var c=0,d=a.length;c<d;c++)this._placeBrick(a[c]);var e={};e.height=Math.max.apply(Math,this.colYs);if(this.options.isFitWidth){var f=0,c=this.cols;while(--c){if(this.colYs[c]!==0)break;f++}e.width=(this.cols-f)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:e});var g=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",h=this.options.animationOptions,i;for(c=0,d=this.styleQueue.length;c<d;c++)i=this.styleQueue[c],i.$el[g](i.style,h);this.styleQueue=[],b&&b.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.isFluid?this.options.columnWidth(b):this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a){var c=b(a),d,e,f,g,h;d=Math.ceil(c.outerWidth(!0)/(this.columnWidth+this.options.gutterWidth)),d=Math.min(d,this.cols);if(d===1)f=this.colYs;else{e=this.cols+1-d,f=[];for(h=0;h<e;h++)g=this.colYs.slice(h,h+d),f[h]=Math.max.apply(Math,g)}var i=Math.min.apply(Math,f),j=0;for(var k=0,l=f.length;k<l;k++)if(f[k]===i){j=k;break}var m={top:i+this.offset.y};m[this.horizontalDirection]=this.columnWidth*j+this.offset.x,this.styleQueue.push({$el:c,style:m});var n=i+c.outerHeight(!0),o=this.cols+1-l;for(k=0;k<o;k++)this.colYs[j+k]=n},resize:function(){var a=this.cols;this._getColumns(),(this.isFluid||this.cols!==a)&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(0);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d=0,e=f.length;d<e;d++){var g=f[d];c[g]=this.originalStyle[g]}this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function h(){--e<=0&&this.src!==f&&(setTimeout(g),d.unbind("load error",h))}function g(){a.call(b,d)}var b=this,d=b.find("img").add(b.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";e||g(),d.bind("load error",h).each(function(){if(this.complete||this.complete===c){var a=this.src;this.src=f,this.src=a}});return b};var g=function(a){this.console&&console.error(a)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d)g("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");else{if(!b.isFunction(d[a])||a.charAt(0)==="_"){g("no such method '"+a+"' for masonry instance");return}d[a].apply(d,c)}})}else this.each(function(){var c=b.data(this,"masonry");c?(c.option(a||{}),c._init()):b.data(this,"masonry",new b.Mason(a,this))});return this}})(window,jQuery);



/*
 Color animation jQuery-plugin
 http://www.bitstorm.org/jquery/color-animation/
 Copyright 2011 Edwin Martin <edwin@bitstorm.org>
 Released under the MIT and GPL licenses.
*/
(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c=
[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c}
d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery);


// initialize lasttrgt variable (we will need this to check if the link was already clicked)
var lasttrgt;

$(document).ready(function(){
	$('html').removeClass('no-js');


	//scroll to top when the page is loaded or refreshed
	$('#container').scrollTop(0);

	$('ul#primary-navigation a, a#logo').click(function(event){
		//get the full url – like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name – home in mysitecom/index.htm#home
		var parts = full_url.split('#');
		var trgt = parts[1];

		//check if the target link was previously a target (this would mean that the link was clicked before)
		if ((trgt == 'container') && ((trgt == lasttrgt) || !lasttrgt)) {
			// clicked home after already on top of page => redirect home
			location.href = '/';
		}

		if (!trgt) 
		{
			return;
		}

		//prevent the default action for the click event
		event.preventDefault();

		if (trgt!==lasttrgt) {
			lasttrgt = trgt;
		}

		//get the top offset of the target anchor
		var target_offset = $('#'+trgt).position();
		var target_top = target_offset.top + parseInt($('#'+trgt).css('margin-bottom')) + $('#container').scrollTop();

		//go to that anchor by setting the element scroll top to anchor top
		$('html,body').animate({scrollTop:target_top}, 750, 'easeOutExpo');
	});

	$('#projects div.block a').hover(function(e) {
		e.stopPropagation();
	});

	//$('#main div.block').wrapAll('<div class="blocks"></div>');
	var bucket = Array();
	$('#main div.block').each(function() {
		if ($(this).hasClass('title')) {
			$(bucket).wrapAll('<div class="blocks"></div>');
			bucket = Array();
		}
		else {
			bucket.push(this);
		}
	});
	
	$('div.blocks').masonry({
	  itemSelector: '.block',
	  columnWidth: 270
	});

	var h2_green = $('#main h2.h2_green');
	var h2_blue = $('#main h2.h2_blue');
	var h2_brown = $('#main h2.h2_brown');
	var original_color = h2_green.css('color');
	$('#main div.block.page').hover(function() {
		$('*', this).stop(true, true);
		$('#main h2').stop(true, true);
		if ($(this).hasClass('green')) {
			h2_green.animate({color: $(this).find('a').css('background-color')});
		}
		if ($(this).hasClass('blue')) {
			h2_blue.animate('color', $(this).find('a').css('background-color'));
		}
		if ($(this).hasClass('brown')) {
			h2_brown.animate('color', $(this).find('a').css('background-color'));
		}
		$(this).find('img').animate({opacity: 0.35});
		$(this).find('span.text').fadeIn(1000);
	}, function() {
		$('*', this).stop(true, true);
		$('#main h2').stop(true, true);
		h2_green.animate({color: original_color});
		h2_blue.animate({color: original_color});
		h2_brown.animate({color: original_color});
		$(this).find('span.text').fadeOut();
		$('#main div.block.page img').animate({opacity: 1});
	});

	// news
	var rolled_out = false;
	var slides = $('#main_news').slides({
		play: 7500,
		pause: 2500,
		hoverPause: true,
		slideEasing: 'easeOutExpo',
		slideSpeed: 1000,
		animationStart: function() {
			if (rolled_out) {
				return false;
			}
			return true;
		}
	});
	$('div.slides_container').click(function() {
		//$('#main_news div.rollout').css({width: 0});
		var width = 324;
		
		var main_news = $(this).parent();
		main_news.animate({left: ((rolled_out)? width : 0)}, 750, 'easeOutExpo', function() {
			// by the time the animation is done, rolled_out has already been switched
			if (!rolled_out) {
				main_news.find('div.rollout').css({width: 0});
			} 
		});
		if (!rolled_out) {
			main_news.find('div.rollout').css({width: width});
		} 

		main_news.find('div.item a.read-more').html('READ MORE +');
		if (!rolled_out) {
			main_news.find('div.item:visible a.read-more').html('CLOSE -');
		}
		
		rolled_out = !rolled_out;
	});
	$('#main_news ul.pagination a').click(function() {
		if (rolled_out) {
			$('div.rollout').css({width: 0});
			$('div.slides_container').click();
		}
	});


	$('div.share ul li.fb').click(function(e) {
		e.stopPropagation();
		e.preventDefault();
		var u = encodeURIComponent(location.href);
		var t = encodeURIComponent(document.title);
		window.open('http://www.facebook.com/sharer.php?u='+u+'&t='+t, 'sharer', 'toolbar=0,status=0,width=626,height=436'); 
		return false;
	});
});
