/**
 * Portfolio wrapper object
 * Controls height and z-index of the portfolio Flash movie
 */
var portfolio = {
	onTop: false,
	toggle: function() {
		if (jQuery('#flashOverlay').css('z-index') < 100) {
			jQuery('#flashOverlay').css('z-index', 100);
		} else {
			setTimeout("jQuery('#flashOverlay').css('z-index', 1);", 1000);
		}
	},
	sendSwfToBack: function() {
		if (portfolio.onTop) {
			portfolio.toggle();
			portfolio.onTop = false;
		}
	},
	sendSwfToFront: function() {
		if (!portfolio.onTop) {
			portfolio.toggle();
			portfolio.onTop = true;
		}
	},
	setHeight: function(height) {
		jQuery('#flashcontent').css('height', height);
	},
	setContentHeight: function(height) {
		jQuery('#tx_tfeportfolio_controller').css(
			'height',
			(height - jQuery('#footer').height() + 40) + 'px'
		);
		jQuery('#flashcontent').css('height', jQuery(document).height());
	},
	init: function() {
		jQuery('body').prepend('<div id="flashOverlay"><div id="flashcontent"></div></div>');
	},
	trackPage: function(pageId) {
		try {
			pageTracker._trackPageview(pageId);
		} catch (err) {
			
		}
	}
};
// Attach old functions to new portfolio object
setHeight = portfolio.setHeight;
setContentHeight = portfolio.setContentHeight;
sendSwfToFront = portfolio.sendSwfToFront;
sendSwfToBack = portfolio.sendSwfToBack;
trackPage = portfolio.trackPage;

jQuery(function() {
	portfolio.init();
});
