$.fn.delay = function(time, callback){
    // Empty function:
    jQuery.fx.step.delay = function(){};
    // Return meaningless animation, (will be added to queue)
    return this.animate({delay:1}, time, callback);
}


jQuery(document).ready(function(){

	$('#advance').supersleight();

   // Show after page is ready
	$(".slide_desc").show();

	// make sure we show the pointer cursor on every slide.
	$("#advance").css({"cursor" : "pointer"});


	// Home Page Tour
	$('#slides').cycle({ 
	    fx:     'scrollHorz', 
	    timeout: 0,
	    before:  onBefore,
	    after:   onAfter,
	    next:   '#advance', 
	    prev:   '#prev_slide' 	     
	 });


	function onBefore() { 
	    $(".click_highlite", this).hide(); 
	} 

	
	function onAfter(curr, next, opts) {   
	    // Hide and show the next/prev links at appropriate times.
	    var index = opts.currSlide;
	    $('#prev_slide')[index == 0 ? 'hide' : 'show']();
	    $('#next_slide')[index == 0 ? 'show' : 'hide']();
	    //$('#next_slide')[index == opts.slideCount - 1 ? 'hide' : 'show']();
	   
	   //Fade the click highlite
	   //$(".click_highlite", this).show().animate({opacity: '+=0'}, 6000).fadeOut(1000);
		$(".click_highlite", this).delay(2400, function(){
		    $(this).show();
		});
		if ($(this).is(".ending")) {
				$("#last_button").show()	
		}
		else {
			$("#last_button").hide()	
		}		 	
		// If its the last slide we want to show the contact button
		if ($(this).is(".last")) {
				$("a#contact_btn").show()
				
				var val = $("a#contact_btn").attr("href");
				
			    $("a#contact_btn").click(function () { 
			      location.href=val; 
			    });
					
				$('#slides').cycle('stop');
		}
		else {
			$("a#contact_btn").hide()	
		} 			 
	}


 
});