jQuery(document).ready(function(){
/*<![CDATA[*/
      
    // Document title
  //  var title = document.title;

    // Simple log
    var log = function(msg) {
        /*if (!$('.log').length) {
            $('<div class="log"></div>').appendTo('body');
        }
        $('.log').append(msg.replace(/^([^:]*):(.*)$/, '<p><b>$1:</b> <span class="$1">$2</span></p>'))
            .attr({scrollTop: $('.log').attr('scrollHeight')})
            .find('p:nth-child(even)').addClass('even');*/
    }
    
    // Default tracker mock
    var pageTracker = {
        _trackPageview: function() {
         //   log('track: ' + arguments[0]);
	//	alert( arguments[0]);
        }
    }

    // Serialization utility
    var serialize = function(obj, re) {
        var result = [];
        $.each(obj, function(i, val) {
            if ((re && re.test(i)) || !re)
                result.push(i + ': ' + (typeof val == 'object' ? val.join 
                    ? '\'' + val.join(', ') + '\'' : serialize(val) : '\'' + val + '\''));
        });
        return '{' + result.join(', ') + '}';
    }
    
    // Init and change handlers
    $.address.init(function(event) {
        
    }).change(function(event) {
  
		$item = $.address.value().split('/')
		if ($item[1] != "") {
		setItem($item[1]) ;
	}
    });
    
/*]]>*/




	$selected = 'none';
	$transparency = 0.4; // Set transparency
		
	$('.portfolio_item').hide(); // hide all items
		$('.portfolio_item').css({"visibility" : "visible"}); // remove css
	$('#portfoliocontainer #column_2 img').fadeTo(0, $transparency); // Set button base transparency
	$('#tool_tips p').hide();// Hide tool tips
	$('.portfolio_thumbs img').attr("title", "");
	$("#portfoliocontainer #column_2 img").bind("mouseenter",function(){ // set rollovers

		$(this).fadeTo(0, 1); 
		$('#tool_tip_'+this.id).show();
	
	 
	//	$('#tool_tip_'+this.id).css("position","absolute");
		$(this).bind('mousemove',function(e){ 
		var xMouse = e.pageX-(($(document).width()-$('.wrap').outerWidth())/2);
	//	$("#log").text("xMouse: " + xMouse + ", e.pageY: " + (($(document).width()-$('.wrap').innerWidth())/2)); 
        
		$('#tool_tip_'+this.id).css("left",xMouse);
		$('#tool_tip_'+this.id).css("top",e.pageY);
		});

	}).bind("mouseleave",function(){
		if ($selected != this.id) {
			$(this).fadeTo(0, $transparency);
				
		}
		$('#tool_tip_'+this.id).hide();
	});

	var $current = '#intro';
	
	$('#portfoliocontainer #column_2 img').click(function() { // Set click 
		$.address.value(this.id);
 		
	});
	
	function setItem(this_fun) {
		$($current).hide();// Hide old 
		$("#"+$selected).fadeTo(0, $transparency); // reset provious button;
		$selected = this_fun; // record selected
		$("#"+this_fun).fadeTo(0, 1); // Set selected button
		$("#portfolio_"+this_fun).show(); // show item based on button selected name
		
		$current = "#portfolio_"+this_fun; // set current
	}
	


});
