/*
 * Pause jQuery plugin v0.1
 *
 * Copyright 2010 by Tobia Conforto <tobia.conforto@gmail.com>
 *
 * Based on Pause-resume-animation jQuery plugin by Joe Weitzel
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or(at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 51
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
(function(){var e=jQuery,f="jQuery.pause",d=1,b=e.fn.animate,a={};function c(){return new Date().getTime()}e.fn.animate=function(k,h,j,i){var g=e.speed(h,j,i);g.complete=g.old;return this.each(function(){if(!this[f]){this[f]=d++}var l=e.extend({},g);b.apply(e(this),[k,e.extend({},l)]);a[this[f]]={run:true,prop:k,opt:l,start:c(),done:0}})};e.fn.pause=function(){return this.each(function(){if(!this[f]){this[f]=d++}var g=a[this[f]];if(g&&g.run){g.done+=c()-g.start;if(g.done>g.opt.duration){delete a[this[f]]}else{e(this).stop();g.run=false}}})};e.fn.resume=function(){return this.each(function(){if(!this[f]){this[f]=d++}var g=a[this[f]];if(g&&!g.run){g.opt.duration-=g.done;g.done=0;g.run=true;g.start=c();b.apply(e(this),[g.prop,e.extend({},g.opt)])}})}})();


var site = {
	_self : this,
	_settings : new Settings(),
	init : function(){
		this._tabs();
		this._scroller();
		this._fancybox();
		this._print();
	},
	_tabs : function(){
//		if ($.isFunction($().tabs)){
//			$('.tabs .proper').tabs({
//				create: function(event, ui) {
//					$('.tabs').show();
//				},
//				select: function(event, ui){
//					var url = $.data(ui.tab, 'load.tabs');
//					if (url){
//						location.href = url;
//						return false;
//					}else{
//						return true;
//					}
//				}
//			});
//		}
	},
	_scroller : function(){
		$('.searching_for ul').wrap('<div class="Scontainer">');
		$('.Scontainer').css({
			'position':'relative',
			'overflow':'hidden',
			'width'	: $('.searching_for ul').width(),
			'float':'left' 
		});
		var nodes = $('.searching_for li');
		var width = 0;
		$(nodes).each(function(){
			width = width+$(this).outerWidth();
		});
		$('.searching_for ul').width(width);
		$('.searching_for ul').css('position','relative')
		$('.searching_for ul').css('left','700px')
		var slider = function(width){
			$('.searching_for ul').animate({'left':-width},20000,'linear', function(){
				$('.searching_for ul').css({'left':700});
				slider(width);
			});
		};
		slider(width);
		$('.searching_for ul').hover(function(){
			$(this).pause();
		},function(){
			$(this).resume();
		});
	},
	_fancybox : function fancybox(){
		$('a[rel=lightbox]').fancybox();
	},
	_print : function print(){
		   $('a.print').click(function(e){
			   e.preventDefault();
			   window.print();
		   });
	}
};
$(document).ready(function(){
	site.init();
});
