
function onAfter(curr, next, opts) {
    var index = opts.currSlide;
	var num = index + 1;
    $('#prev')[index == 0 ? 'hide' : 'show']();
    $('#next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}
$(document).ready(function(){
	
	// Remove "home" menu item
	$("nav#top li:first").remove();


	// Place the big logo
	var placeLogo = function(){
		$("header#logo").css("paddingTop",(($(window).height())/2-100)+"px");
	};
	placeLogo();
	$(window).resize(function(){
		placeLogo();
	});
	
	// Supersized
	if($("body").is(".frontpage")){
	$.fn.supersized.options = {  
				startwidth: 1280,  
				startheight: 890,
				vertical_center: 0,
				slideshow: 0,
				navigation: 0,
				transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
				pause_hover: 0,
				slide_counter: 0,
				slide_captions: 0,
				slide_interval: 3000  
			};
	$('body.frontpage #supersize').supersized();
	}
         
	
	// WORK LIST FADE ON HOVER
	$("ul.image-grid li a").live('mouseover mouseout', function(event) {
  		if (event.type == 'mouseover') {
    		$(this).stop().animate({color:"#ff0000"}, 'fast').find("img").stop().animate({opacity:1}, 'fast');
  		} else {
    		$(this).stop().animate({color:"#a7a7a7"}, 'fast').find("img").stop().animate({opacity:0.9}, 'fast');
  		}
	});
	
	
	// POPULATE SLIDE MENU
/*	$("#pictures div").each(function(i,el){
		$("#img_links").append($('<li></li>').append($('<a href="#">'+ (i+1) +'</a>').click(function(){gotoslide(i+1);return false}).append("<span></span>")))
	}); */
	// set active button
	// $("#img_links a:first").addClass("active").find("span").animate({opacity:0.6}, 400);

	
	
	// Arrows functions
	$("body.work a.arrows")
	.hover(function(){
		$(this).stop().animate({opacity:1}, 300);
	},
	function(){
		$(this).stop().animate({opacity:0}, 300);
	});
	/*.click(function(){
		if($(this).attr("id")=="prev"){
			prevslide();
		} else {
			nextslide();
		}
	})*/
	
	// Browser fixes
	$("nav#work-sort ul li:last-child a").css("borderRight","none");
	$("section#office_press ul li:nth-child(4n)").css("paddingRight","0px");
	$("p").attr("align","");
	
	if($("#slides").is("div")){
	$('#slides').cycle({
    fx:     'scrollHorz',
    prev:   '#prev',
    next:   '#next',
    after:   onAfter,
    timeout: 0,
	pager: '#img_links'
	});
	}
});
