
function bigMahesh(leftValue) {
    $("#mahesh").animate({
        width: 487,
        height: 518,
        left: '420',
        top: '100'
    });
}

function moveAbout() {
    $("#mainthree").animate({
        left: 30,
        top: 190
    });
}

function moveContact() {
    $("#mainfour").animate({
        left: 450,
        top: 40
    });
}

function slideUpGallery() {  //moves gallery
    $("#maintwo").animate({
        top: -1000
    });
}

var $nav;
    
$.fn.animationClick = function(callback, target) {

    var stringTarget = target,
        $target = target ? $(target) : null;
    
    return this.click(function(e) {
        if (!$(this).hasClass("current")) {
            $nav.removeClass("current");
            $(this).addClass("current");
            slideUpGallery();
            callback();
            moveAbout();
            if ($target) $target.fadeIn();
            window.location.hash = stringTarget;
        }
        return false;
    });
}

$(function() {

    var $mahesh = $("#mahesh"),
        $gallery = $("#maintwo"),
        $aboutus = $("#mainthree"),
        $contactus = $("#mainfour"),
    
    	$nav = $(".nav a");

    var origMaheshWidth = 422, // or could test after window.load
    	origMaheshHeight = 449, // or could test after window.load
        origMaheshLeft = $mahesh.position().left,
        origMaheshTop = $mahesh.position().top,
        origGalleryTop = $gallery.position().top,
        origGalleryLeft = $gallery.position().left,
        
        origAboutUsTop = $aboutus.position().top,
        origAboutUsLeft = $aboutus.position().left,
        
        origContactUsTop = $contactus.position().top,
        origContactUsLeft = $contactus.position().left;
    
    $(".about-link").click(function() {
        if (!$(this).hasClass("current")) {
            $(".nav a").removeClass("current");
            $(".nav .about-link").addClass("current");
            slideUpGallery();
            bigMahesh(520);
            moveAbout();
            $contactus.animate({
                left: origContactUsLeft
            });
        }
    });

    $(".home-link").click(function(e) {
        if (!$(this).hasClass("current")) {
            $(".nav a").removeClass("current");
            $(".nav .home-link").addClass("current");
            $mahesh.animate({
                width: origMaheshWidth,
                height: origMaheshHeight,
                left: origMaheshLeft,
                top: origMaheshTop
            });
            $gallery.animate({
                top: origGalleryTop,
                left: origGalleryLeft
            });
            $aboutus.animate({
                left: origAboutUsLeft
            });
            $contactus.animate({
                left: origContactUsLeft
            });
        }
    });
    
    $(".contactus-link").click(function() {
        if (!$(this).hasClass("current")) {
            $(".nav a").removeClass("current");
            $(".nav .contactus-link").addClass("current");
			moveContact();
            slideUpGallery();
            $mahesh.animate({
                width: origMaheshWidth,
                height: origMaheshHeight,
                left: origMaheshLeft,
                top: origMaheshTop
            });
            $aboutus.animate({
                left: origAboutUsLeft
            });
    	}
    });

});

