// JavaScript Document
root='/';
$(document).ready(function(){
	if ($('div#home').length>0){
		$('div#home h1#logo').css('left', $('div#home h1#logo').position().left);
		$('div#home h1#logo').css('top', $('div#home h1#logo').position().top);
		$('div#home h1#logo').hide();
		
		$('div#home h1#logo').fadeIn(2000,function(){
			$(this).delay(1000).animate({'top':100, 'left':70},{ duration: 1200, queue: true, complete:function(){
					$('div#menu, div#content, div#footer').fadeIn(1000, function(){
						/*
						$('div#home div#content').jCarouselLite({
							visible:1,
							circular:true,
							auto: 4000,
							speed: 500	
						});
						*/
						/*
						$('div#home div#content').carousel({
							dispItems:1,
							loop: true,
							effect: 'fade',
							autoSlide: true,
							autoSlideInterval: 5000,
							animSpeed: 1000,
							nextBtn:'',
							prevBtn:''
						});
						*/
						$('div#home div#content ul').cycle('fade');
					});
				}
			});
		});		
	}
	
	$('div#contact form').submit(function(){
		var ok=true;
		$('span.error').hide();
		if (!$.trim($('input[name=name]').val())){
			$('span#name').fadeIn();
			ok=false;
		}
		if (!isMail($('input[name=email]').val())){
			$('span#email').fadeIn();
			ok=false;
		}
		return ok;
	});
	/*
	$('div#exhibitions div#content').jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible:1,
		circular: false,
		speed: 500	
	});	
	*/
	/*
	$('div#exhibitions div#content div.slideshow').carousel({
		nextBtn: '<a class="arrow next">Next</a>',
		prevBtn: '<a class="arrow prev">Previous</a>',
		visible:1,
		circular: false,
		speed: 500	
	});
	*/
	/*
	$('div#exhibitions div.slideshow ul').cycle({ 
    	fx: 'scrollLeft' 
	});
	*/
	$('div#exhibitions div.slideshow ul').cycle({ 
		fx:      'scrollHorz',
		timeout:  0,
		speed: 500,
		prev: 'a.prev',
		next: 'a.next',
		nowrap:1,
		after:function (curr,next,opts){
			var index = opts.currSlide;
			if (index==0){
				$('a.prev').addClass('disabled');
			}else{
				$('a.prev').removeClass('disabled');
				if (index==opts.slideCount - 1 ){				
					$('a.next').addClass('disabled');				
				}else
					$('a.next').removeClass('disabled');
			}
		}		
	});	

	$('div#menu div.items').jScrollPane({showArrows:true});
	/*
	$('div.images').jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible:1,
		circular: false
	});
	
	$('div.menu a').click(function(){
		$('div.menu a').removeClass('selected');
		$(this).addClass('selected');
		$.getJSON(root + 'ajax/getitem.php?id=' + $(this).attr('rel'),function(json){
			var $container=$('div.items div.container'), ul, img;

			$container.fadeOut(500, function(){
				$('div#image').addClass('loading');
				$container.children('div.images').remove();
				$container.prepend('<div class="images">');
				$container.children('div.images').append('<ul>');
				ul=$container.find('ul');
				$(json.images).each(function(i,e){
					ul.append('<li><div class="wrapper"><img src="' + e + '" /></div></li>');
				});

				$container.children('div.info').find('h1').text(json.title);
				$container.children('div.info').find('h2:eq(0)').text(json.description);
				$container.children('div.info').find('h2:eq(1)').text(json.date);
				img=new Image();
				img.onload=function(){
					$('div#image').removeClass('loading');
					$('div#image img').css('marginTop', (img.height/2)*-1);
					$container.fadeIn(500, function(){
						//setTimeout(function(){
							$('div.images').jCarouselLite({
								btnNext: ".next",
								btnPrev: ".prev",
								visible:1,
								circular: false
							});
						//},0);
					});
				}
				img.src=json.images[0];
			});
		});
		return false;
	});
	*/
});
function isMail(email){
     var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
     return emailReg.test(email);
}

