/* POL KLEIN Portfolio, Custom Javascript */

//----------------------------------------------------------------------------
// Global Variables: 
//----------------------------------------------------------------------------
current_project = 0;  /* !!! reset in each project HTML page !!! */
click_view_top = "110px";

//----------------------------------------------------------------------------
// Function: projects_init();
// Description: displays selected project description and image. p=project#
//----------------------------------------------------------------------------
function projects_init(website_marker)
{
	var current_id = "thumb" + current_project;
	var active_thumb = document.getElementById(current_id);
	
	$("#project_title").fadeIn("normal");
	$("#project_description").fadeIn("normal");
	$("#displayed_piece").fadeIn("normal");
	$("#displayed_piece").vAlign();
//	if (website_marker == true) $("#opensite").css("top", click_view_top); 
//    $("#clickmark").css("top", click_view_top); 
    $("#displayed_piece").css("margin-left", "auto");
    $("#displayed_piece").css("margin-right", "auto");
    if (current_project >= 0)
    {
		active_thumb.style.opacity = "1.0";
		active_thumb.style.filter = 'alpha(opacity="100")';  /* for IE */  
	}
};

//----------------------------------------------------------------------------
// Function: project_select(project);
// Description: displays selected project description and image. p=project#
//----------------------------------------------------------------------------
function project_select(project)
{	
	if (project != current_project) 
	{
		/* Hide current info */
		$("#project_title").fadeOut("normal");
		$("#project_description").fadeOut("normal");
		$("#displayed_piece").fadeOut("normal");
		return_value = true;
	}
	current_project = project;
};


//----------------------------------------------------------------------------
// Function: vAlign();
// Description: vertically aligns element inside a fixed height div 
//              jquery function: $("element_id").vAlign();
//              NOTE: Site spcific modification: max top-margin = 70px
//----------------------------------------------------------------------------
/* Simple vAlign function */
(function ($) 
{
	$.fn.vAlign = function() 
	{
		return this.each(function(i){
		var ah = $(this).height();
		/* var ph = $(this).parent().height(); */
		var ph = $("#panel_container").height();   /* site specific */
		var mh = (ph - ah) / 2;
		
		/* Align to upper menu if content is small (this line is site specific) */
		if (mh > 70) mh=70;
		/* Determine location of click to view marker (this line is site specific */
		click_view_top = (80 + mh + ah) + "px";
		
		$(this).css('margin-top', mh);
	});
};
})(jQuery);