﻿$(document).ready( function()
{
    jQuery.easing.quart = function (x, t, b, c, d)
	{
        return -c * ((t=t/d-1)*t*t*t - 1) + b;
    };
    
    var j$ = jQuery;
    j$(function()
	{ 
        j$('a[href^=#]').click(function()
		{ 
            var href= this.hash; 
            var $target = j$(href == '#top' ? 'body' : href); 

            if($target.size())
			{
                var top = $target.offset().top;
                j$(j$.browser.safari ? 'body' : 'html').animate({scrollTop:top}, 580, 'quart');
            }
            return false;
        });
    });

    $("#detailphoto a").click( function()
	{
        var changeSrc  = jQuery(this).attr("href");
        var name = jQuery(this).attr("name");

        $("#mainphoto img").attr("src", changeSrc);
        $("#mainphoto img").attr("src", changeSrc);

        $("#gallery a img").attr("src", changeSrc);
        $("#gallery a").attr("href", name);
        $("#gallery2 a img").attr("src", changeSrc);
        $("#gallery2 a").attr("href", name);

        $("#largephoto").css({'background':'url('+name+') no-repeat'}); 

        $("#detailphoto div .thumbnail").attr("class", "normal thumbnail");
        
        var d = $(this).parent().attr("class");
        if(d!="active thumbnail")
		{
            $(this).parent().attr("class","active thumbnail");
        }

        return false;
    });
    
    
    $("#mainphoto").mouseover( function()
	{
        
    });

    var x = 0;
    var y = 0;
    $('#largephoto').mouseover(function(e)
	{
        
        $("#mainphoto img").hide();
    
        $(this).css('cursor', 'move');
        var bx = e.pageX;
        var by = e.pageY;
        
		$().bind('mousemove.move', function(e)
		{
            x = 1.5*(e.pageX - $("#largephoto").position().left);
            if (x < 0) x = 0;
            //if (x > 420) x = 420;
            if (x > 230) x = 230;
            y =1.5*(e.pageY - $("#largephoto").position().top);
            if (y < 0) y = 0;
            //if (y > 420) y = 420;
            if (y > 230) y = 230;
            $('#largephoto').css('backgroundPosition', '-' + (x*1) + 'px -' + (y*1) + 'px');
            return false;
        }).one('mouseout', function()
		{
            $('#largephoto').css('cursor', 'auto');
            $("#mainphoto img").show();
            $().unbind('mousemove.move');
        });
        return false;
    });

});


