var config = // config object
{
	fadeOutTo : 0.2, // opacity to fade out to
	fadeInTo : 1, // opacity to fade in to
	portfolioHref : "details.php?iid=", // href prefix for onclick event
	portfolioClass : ".card", // class given to each portfolio image
	indClassPrefix : "ind", // prefix of the classes added to each portfolio for jQuery effects
	disabledClass : "portfolioNoHover", // class to assign to disable the hover effect for each portfolio
	tooltipOpt : { track: true, delay: 0, showURL: false, showBody: " - " } // options for the tooltip object
}

/*********************************************
 * Function: 	showPortfolio() extends jQuery 
 * Desc: 		fades in the portfolio image and adds 
 *				the necessary events
 *********************************************/
$.fn.showPortfolio = function()
{
	// fade element in
	//this.fadeTo("normal", config.fadeInTo);
	this.show("slow");
	
	// reinstate hover, tooltip, and href
	//this.children("a").attr("href", config.portfolioHref + this.children("a").attr("iid"));
	//this.children("a").tooltip(config.tooltipOpt);
	//this.children("a").removeClass(config.disabledClass);
}


/*********************************************
 * Function: 	hidePortfolio() extends jQuery 
 * Desc: 		fades out the portfolio image and strips 
 *				all mouse over/click events
 *********************************************/
$.fn.hidePortfolio = function()
{
	// fade element out
	//this.fadeTo("normal", config.fadeOutTo);
	this.hide("slow");
	
	// remove href value, tooltip, and add a class to destory hover effect
	//this.children("a").removeAttr("href");
	//this.children("a").tooltip(null);
	//this.children("a").addClass(config.disabledClass);
}


/*********************************************
 * Function: 	portfolioDetails() extends jQuery 
 * Desc: 		displays the modal window with company details
 *********************************************/
$.fn.portfolioDetails = function(url)
{
	// conditional added as shortcut for if the portfolio is disabled
	if(!this.hasClass(config.disabledClass))
	{
		// only show window if the element is active
		$.showAkModal(url,'',720,390);
	}
	return false;
}


/*********************************************
 * Function: 	selectIndustry()
 * Desc: 		changes the industry type to display, triggering 
 *				the fadeIn/fadeOut sequence
 *********************************************/
function selectIndustry(indId)
{
	if(indId == 0)
	{
		// show them all
		$(config.portfolioClass).each(function(){
			$(this).showPortfolio();
		});
	}
	else
	{
		// show only the cards with the specified industry class
		$(config.portfolioClass).each(function(){
			if($(this).hasClass(config.indClassPrefix+indId))
			{
				// show valid portfolio pieces
				$(this).showPortfolio();
			}
			else
			{
				// hide the portfolio image (does not contain the industry class specified)
				$(this).hidePortfolio();
			}
		});
	}	
}


/*********************************************
 * Function: 	jQuery.ready()  (shortened to '$()')
 * Desc: 		triggered on page load finish
 *********************************************/
$(function(){
	// assign combobox class to industries dropdown
	$('#industries').combobox({
		comboboxContainerClass: "comboboxContainer",
		comboboxValueContainerClass: "comboboxValueContainer",
		comboboxValueContentClass: "comboboxValueContent",
		comboboxDropDownClass: "comboboxDropDownContainer",
		comboboxDropDownButtonClass: "comboboxDropDownButton",
		comboboxDropDownItemClass: "comboboxItem",
		comboboxDropDownItemHoverClass: "comboboxItemHover",
		comboboxDropDownGroupItemHeaderClass: "comboboxGroupItemHeader",
		comboboxDropDownGroupItemContainerClass: "comboboxGroupItemContainer",
		animationType: "slide",
		width: "200px"
	});
	
	// assign onchange event for industries dropdown
	$("#industries").combobox.onChange = function(){
		selectIndustry($("#industries option:selected").val());
	};
	
	// assign tooltip class for each portfolio link
	$('#portfolioContent a').tooltip(config.tooltipOpt);
});