/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

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}('3 1a={19:6(Y,D){3 9=0;3 p=[];3 z=Y.1g(" ");3 V=z.1f();3 u=\'\';z.f(6(8,i){u+=\'.t("\'+8+\'")\'});$1c(V).f(6(k,i){1e(\'p.1d(k\'+u+\');\')});p.f(6(4,i){7(!$r(4))J;3 b,g;7(4.U){b=4.U;g=0;g+=4.m(\'10-Z\').n();g+=4.m(\'10-G\').n();b-=g;l=0;l+=4.m(\'14-Z-P\').n();l+=4.m(\'14-G-P\').n();b-=l}v 7(4.N.L){b=4.N.L}9=16.K(9,b)});7(D!=1b){9=16.K(9,D)}p.f(6(4,i){7(!$r(4))J;7(1l.1w){4.I(\'M\',9+\'O\')}v{4.I(\'1v-M\',9+\'O\')}})}};3 11=a 18({17:6(k,H,13,y,15,q){c.o({A:1u,Q:s.12.1y,T:S,C:\'\'},y);3 5=c.5;$$(k).f(6(8,i){3 E=8;7(q&&8.t(q)){E=8.t(q)}3 d=a s.1B(E,5);7(!($r(5.C)&&8.1A(5.C))){8.R(\'1h\',6(e){d.o(5,y).x(H)});8.R(\'1z\',6(e){d.o(5,15).x(13)})}})}});11.W(a F);3 X=a 18({17:6(5){c.o({Q:s.12.1x,A:1s,T:S,h:[\'#1t\',\'#1k\']},5);3 B=a 1j(1i.B);3 d=B.1m(c.5);3 j=0;3 h=c.5.h;3 1n=w.1r(c.5.A*2);w();6 w(){d.x({\'1q-1p\':h[j]});7(j+1>=h.1o){j=0}v{j++}}}});X.W(a F);',62,100,'|||var|div|options|function|if|el|maxHeight|new|divHeight|this|fx||each|divPadding|colors||index|element|divBorder|getStyle|toInt|setOptions|matchDivs|elementFx|chk|Fx|getElement|script|else|animate|start|enterFx|selectors|duration|body|ignoreClass|minWidth|elfx|Options|bottom|enter|setStyle|return|max|pixelHeight|height|style|px|width|transition|addEvent|false|wait|offsetHeight|elements|implement|YOOBackgroundFx|selector|top|padding|YOOMorph|Transitions|leave|border|leaveFx|Math|initialize|Class|matchDivHeight|YOOBase|undefined|ES|push|eval|shift|split|mouseenter|document|Element|999999|window|effects|timer|length|color|background|periodical|9000|FFFFFF|500|min|ie6|linear|expoOut|mouseleave|hasClass|Styles'.split('|'),0,{}))
/* Copyright (C) 2007 - 2009 YOOtheme GmbH */

var YOOTools = {
		
	start: function() {

		/* Match height of div tags */
		YOOTools.setDivHeight();
	},

	/* Include script */
	include: function(library) {
		$ES('script').each(function(s, i){
			var src  = s.getProperty('src');
			var path = '';
			if (src && src.match(/yoo_tools\.js(\?.*)?$/)) path = src.replace(/yoo_tools\.js(\?.*)?$/,'');
			if (src && src.match(/template\.js\.php(\?.*)?$/)) path = src.replace(/template\.js\.php(\?.*)?$/,'');
			if (path != '') document.write('<script language="javascript" src="' + path + library + '" type="text/javascript"></script>');
		});
	},

	/* Match height of div tags */
	setDivHeight: function() {
		YOOBase.matchDivHeight('div.headerbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.topbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.bottombox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.maintopbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.mainbottombox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.contenttopbox div.deepest', 0, 40);
		YOOBase.matchDivHeight('div.contentbottombox div.deepest', 0, 40);
	}

};

/* Add functions on window load */
window.addEvent('domready', YOOTools.start);

/* Load IE6 fix */
if (window.ie6) {
	YOOTools.include('addons/ie6fix.js');
	YOOTools.include('addons/ie6png.js');
	YOOTools.include('yoo_ie6fix.js');
}

/* Move class */
var YOOMove = new Class({
	
	initialize: function(element, options) {
		this.setOptions({
			direction: 'left',
			speed: 10000,
			pause: 5,
			duration: 1000,
			transition: Fx.Transitions.linear
		}, options);

		this.elm = $(element);
		this.key = 'yt-' + this.elm.getProperty('id');
		this.fx = new Fx.Styles(this.elm, this.options);
		this.timer = null;

		var val = Cookie.get(this.key);
		if (val) {
			this.elm.setStyle('left', val + 'px');
		}
		
		this.memorize.periodical(2500, this);
		this.animate();
	},

	animate: function() {
		var dir   = this.options.direction;
		var pause = this.options.pause;
		var coord = this.elm.getCoordinates();
		var dest  = (dir == 'left') ? 0 - coord.width : window.getWidth();
		var track = coord.left - dest;
		if (track < 0) { track = -track; }

		this.fx.setOptions({ 'duration': (this.options.speed * track / 1024).toInt() });
		this.fx.start({
			'left': (dir == 'left') ? 0 - coord.width : window.getWidth()
		}).chain(function() {
			this.elm.setStyles({
				'left': (dir == 'left') ? window.getWidth() : 0 - coord.width
			});
			$clear(this.timer);
			this.timer = this.animate.delay((Math.floor(Math.random() * pause) * 1000).limit(1000, (1000 * pause)), this);
		}.bind(this));
	},
	
	memorize: function() {
		var coord = this.elm.getCoordinates();
		Cookie.set(this.key, coord.left);
	}
	
});

YOOMove.implement(new Options);
