var clickFile = "/inc/sounds/select.mp3";
var xOffset = 10; // these 2 variable determine popup's distance from the cursor
var yOffset = 30; // you might want to adjust to get the right result
var animations = true;
var ajax = true;

function doInit()
{
var firstTimeIn=false;
    $(document).ready(function()
    {
        //alert ($(this).find('input firstvisit').text());
        //$(this).find('input animations').text();

        $('#content').hide();
        if(firstTimeIn)
        {
            $('div').not('#left_column, #clients').hide();
            $('body').find('div').slideDown(3000);
            firstTimeIn=false;
        }
        else
        {
            $('#content').fadeIn(2500);
        }

        $("#top_image").mouseup(function(){
            $.sound.play(clickFile);
            $(document).attr('title', 'greergan.com: A Carrot');
//            $('#content').hide();
            $('#content').load('/carrot.html #content div');
//            $('#content').fadeIn(2500);
            return false; 

        });

/*
        $('#client_image').mouseup(function(){
            $.sound.play(clickFile);
        });
*/

/* Image preview stuff
        $('a.preview').hover(function(e){
            this.t = this.title;
            this.title = "";    
            var c = (this.t != "") ? "<br/>" + this.t : "";
            $("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");                                 
            $(".preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").fadeIn("fast");                        
        },
        function(){
            this.title = this.t;    
            $("#preview").remove();
        });    
        $("a.preview").mousemove(function(e){
            $("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
        });
End Image preview stuff */

        $('a').not('.noclick').click(function()
        {
            $.sound.play(clickFile);
/* Ajax loading 
            $(document).attr('title', 'greergan.com: '+this.title);
            $('#content').hide();
 Working            $('#content').load(this.href+' #content div');
            $('#content').fadeIn(2500);
            return false; 
*/
/*
            $.ajax(
            { 
                url: this.href, cache: false, 
                success: function(html)
                {
                    $("#content").replaceWith(jQuery(html).find('#content').links2click().html());
                }
            });

*/
        });
/*
        $("a").hover(function(){
             obj = jQuery(this);
             obj.cluetip(this.title);
             //$('ol.rounded a:eq(4)').cluetip({cluetipClass: 'rounded', dropShadow: false});
        });
*/
    });
}

(function($) 
{
    $.fn.links2click = function()
    {
/*
            $("a").not(".noclick").click(function()
            {
                $.sound.play(clickFile);
                $(document).attr('title', 'greergan.com: '+this.title);
                $('#content').hide();
                $('#content').load(this.href+' #content');
                $('#content').fadeIn(2500);
                return false; 
            });
*/
            $.sound.play(clickFile);
            $(document).attr('title', 'greergan.com: '+this.title);
            $('#content').hide();
            $('#content').load(this.href+' #content');
            $('#content').fadeIn(2500);
            return false;
    };
})(jQuery);
