/* ================================================================ 
This copyright notice must be untouched at all times.
Copyright (c) 2009 Stu Nicholls - stunicholls.com - all rights reserved.
=================================================================== */
$(document).ready(function() {
    current = 19;
    button = 1;
    images = 19;
    width = 444;

    $('#p19').animate({ "left": "0px" }, 400, "swing");
    $('#loading').css("display", "none");

    $("#previous").click(function() {
        button = current;
        current++
        if (current == (images + 1)){ 
			current = 1
		}
        animateRight(current, button)
    });

    $("#next").click(function() {
        button = current;
        current--
        if (current == 0) { 
			current = images 
		}
        animateLeft(current, button)
    });

    function animateLeft(current, button) {
        $('#p' + current).css("left", width + "px");
        $('#p' + current).animate({ "left": "0px" }, 400, "swing");
        $('#p' + button).animate({ "left": -width + "px" }, 400, "swing");
    }

    function animateRight(current, button) {
        $('#p' + current).css("left", -width + "px");
        $('#p' + current).animate({ "left": "0px" }, 400, "swing");
        $('#p' + button).animate({ "left": width + "px" }, 400, "swing");
    }

});
