var K = {

	init: function() {

		_this = this;

		_this.startCycle();

		$('.goback').bind('click', function() {
			window.history.back();
			return false;
		});

		$('.print a').bind('click', function() {

			// we add pagebreaks so only 4 pictures pr page will be shown
			$('.model-pictures img').each(function(i) {
				if(i%4 === 3) {
					if($(this).next().attr('class') != 'pagebreak') {
						$(this).after($('<div>&nbsp;</div>')
							.attr('class', 'pagebreak')
							.css({
								'overflow': 'hidden',
								'height': '1px',
								'width': 'auto',
								'page-break-after': 'always',
								'clear': 'both'
							})
						);
					}
				}
			});

			// fire up print window
			window.print();

			// remove pagebreaks again
			$('.model-pictures .pagebreak').remove();

			return false;
		});

	},

	startCycle: function() {

		var model = $('.model-pictures');
		if(model.size() > 0) {
			model.cycle({
				height: 380,
				next: '.model-pictures',
				speed: 400,
				timeout: 3000
			});
		}

		var page = $('.page-pictures');
		if(page.size() > 0) {
			page.cycle({
				height: 380,
				next: '.page-pictures',
				speed: 400,
				timeout: 3000
			});
		}

	},

	stopCycle: function() {
		$('.model-pictures').cycle('destroy');
		$('.page-pictures').cycle('destroy');
	}

};
