var active_tab = null;

$(document).ready( function(){

	$("#scroller").scrollable({
		vertical: true,
		size: 1,
		clickable: false
	}).navigator("#tabs");

	var portfolio = $("#p_window").scrollable({
		next: ".nextp",
		prev: ".prevp"
	});

    $("#contact_form").ajaxForm({
        beforeSubmit: function(){
            $("#recaptcha_error").html("");
        },
        success: function(data, status){
            if( data != "success" ){
                $("#recaptcha_error").html("<b>"+data+" Please check your typing and try again.</b>");
            }
            else{
                $("#form_block").hide();
                $("thx_block").show();
            }
        },
        error: function(request, response, error){
            $("#recaptcha_error").html("Error: " + response);
        }
    });

	$('.info_button').toggle(
        function(){
                popup = $(this).parents(".portfolio_thumb").find(".portfolio_copy");
				$(this).attr("active","false");
				$(this).css("background-position","center");
                popup.hide();
        },
		function(){
                popup = $(this).parents(".portfolio_thumb").find(".portfolio_copy");
				$(this).attr("active","true");
				$(this).css("background-position","bottom");
                popup.show();
        }
	);

	$('.info_button').hover(
		function(){
			if( $(this).attr("active") == "true" )
				return;

			$(this).css('background-position',"center left");
        },
        function(){
			if( $(this).attr("active") == "true" )
				return;

            $(this).css('background-position',"top left");
        }
	);

	$(function() {

		// if the function argument is given to overlay,
		// it is assumed to be the onBeforeLoad event listener
		$("a[rel]").overlay({

			mask: '#003',
			effect: 'apple',

			onBeforeLoad: function() {
				var wrap = this.getOverlay().find(".contentWrap");
				wrap.load(this.getTrigger().attr("href"));
			}

		});
	});

});
