$(function(){
	var image1 = $('<img />').attr('src', '../img/showreel.png');
	
	$('.people a').click(function(){
		var div_to_disp = $(this).attr('href');
		$('#all_together').fadeOut('slow',function(){
			$(div_to_disp).fadeIn('slow');
		});
		return false;
	});
	
	$('.secondary-nav a.a_next').click(function(){
		var next = $($(this).parents('div.wrapper')).index()+1;
		$(this).parents('div.wrapper').fadeOut('slow',function(){
			if($('#center-area div.wrapper:eq('+next+')').length>0){
				$('#center-area div.wrapper:eq('+next+')').fadeIn('slow');
			}
			else{
				$('#center-area div.wrapper:eq(0)').fadeIn('slow');
			}
		});
		return false;
	});
	
	$('.secondary-nav a.a_prev').click(function(){
		var next = $($(this).parents('div.wrapper')).index()-1;
		$(this).parents('div.wrapper').fadeOut('slow',function(){
			if($('#center-area div.wrapper:eq('+next+')').length>0){
				$('#center-area div.wrapper:eq('+next+')').fadeIn('slow');
			}
			else{
				var lastIndex = $(""+($(this).parents('div.wrapper'))+":last").index();
			}
		});
		return false;
	});
	
	$('#gal_list > ul > li > a').click(function(){
		$('#center-area ul li').removeClass('active');
		$(this).parent().addClass('active');
	});
	
	$('.dicon').click(function(){
		var to_vis = $(this).parent().parent().attr("id");
		if($('#'+to_vis+' div.moreInfo').css('display') == 'none')
			$('#'+to_vis+' div.moreInfo').fadeIn('slow');
		else
			$('#'+to_vis+' div.moreInfo').fadeOut('slow');
	});
	
	$('.infoClose').click(function(){
		$(this).parent().fadeOut('slow');
	});
	
	$('.cform').focus(function () {
		if ($(this).val() == $(this).attr("title")) {
			$(this).val("");
		}
	}).blur(function () {
		if ($(this).val() == "") {
			$(this).val($(this).attr("title"));
		}
	});
	
	$('#map-pin-ophio').click(function(){
		if($("#ophiopopup").css('display')=='none'){
			$("#ophiopopup").fadeIn("slow");
		}
		else{
			$(".ophio-map").fadeOut("slow"); 
			$("#ophiopopup").fadeOut("slow");
		}
	});
	
	$('.popupClose').click(function(){
		$(".ophio-map").fadeOut("slow");
		$(this).parent().fadeOut('slow');
	});
	
	$("#viewmap").toggle(function(){
		$(".ophio-map").fadeIn("slow");
	},function() { 
		$(".ophio-map").fadeOut("slow"); 
	});
	
	$('.showreel').click(function(){
		$('#vimeo').html("<iframe src='http://player.vimeo.com/video/17635128?title=0&amp;byline=0&amp;portrait=0' width='500' height='325' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>");
		$("#showreel").fadeIn('slow');
		return false;
	});
	
	$('.rt_sr').click(function(){
		$('#vimeo').html("<iframe src='http://player.vimeo.com/video/17635128?title=0&amp;byline=0&amp;portrait=0' width='500' height='325' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>");
		$("#showreel").fadeIn('slow');
		return false;
	});
	
	$('#showreelClose').click(function(){
		$('#vimeo').html("");
		$('#showreel').fadeOut('fast');
		return false;
	});
	
	$('#gal_nav').localScroll({
		offset:-200
	});
	
	$('.item').mouseover(function() {
		var get_id = $(this).attr('id');
		$('#center-area ul li').removeClass('active');
		$("#gal_nav ."+get_id).addClass('active');
	});
});
