var $j = jQuery.noConflict();
$j(document).ready(function() {
	
	$j('#ss_form').submit(function(){
	var name = $j('#nimi').val();
	var email = $j('#email').val();
	var reg = /^[a-zA-Z0-9]+[a-zA-Z0-9_.-]+[a-zA-Z0-9_-]+@[a-zA-Z0-9]+[a-zA-Z0-9.-]+[a-zA-Z0-9]+.[a-z]{2,4}$/;
	var error;
	if(name == ''){
		$j("input[name='nimi']").addClass('error');
		error = true;
	};
	if(email == '' || reg.test(email) == false){
		$j("input[name='email']").addClass('error');
		error = true;
	};
	if(error == true) return false;
	else return true;
	});

	
	
	$j('a.fancybox').fancybox(); 
	$j(".youtube_gallery a").click(function() {
	$j.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
	var items = $j('.youtube_gallery_item').length;
	items = items * 135 +"px";
	$j('.youtube_gallery').width(items);
	$j('#rotator').cycle({ 
		fx: 'scrollHorz',
		timeout: 8000,
		speed:  1500,
		startingSlide: 3,
		prev:   '#navigate-left a', 
    	next:   '#navigate-right a',
    	after:   onAfter 
	});
	/*$j('#bar li').click(function(){
		index = $j("#bar li").index(this);
		$j('#rotator').cycle(index); 
		return false;
	});*/
	
});
function onAfter(curr, next, opts) {
    var index = opts.currSlide;
	$j('#bar li').removeClass('current');
	$j('#bar li').eq(index).addClass('current');
}
//Simple validation

