// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
function centerPortfolioNav() {
	var items = $$('#portfolio-nav ul li');
	var w = 0;
	for (var i=0; i < items.length; i++) {
		w += items[i].getWidth();
	}
	$$('#portfolio-nav ul')[0].setStyle({width: w + 'px', margin: '0px auto'});
}

function doSwfs() {
	if ($('flash-header'))
		swfobject.embedSWF("/flash/" + header, "flash-header", "800", "260", "8", null, {}, {wmode: 'transparent'});
}

function doSlider() {
	if ($('shifter-frame')) {
		Slider = new ContentSlider('shifter-strip', 'shifter-slide', {forwardButton: 'forward-button', unitWidth: 386});
	}
}

function buildThumbnailBoxes() {
	$$('.forge-inserted-thumbnail').each(function(thumb) {
		
		//get the margin and float info for applying to the div and then remove it from the image
		var image = Element.down(thumb)
		var style = Element.readAttribute(image, 'style');
		image.removeAttribute('style');
		
		//create a new div, insert it after the image, then insert the image into the div
		var div = new Element('div', { 'class': "forge-inserted-thumbnail", style: style });
		Element.insert(thumb, {after: div});
		Element.insert(div, thumb);
		
		//create and insert the "click to enlarge" text
		var link = thumb.cloneNode(false);
		link.setStyle({display: 'block'});
		Element.insert(link, "Click to Enlarge");
		Element.insert(thumb, { after: link });
		
	});
	
	//run fancyzoom again so that the inserted links work
	setupZoom();
}
	
jQuery(function() {
	doSwfs();
	doSlider();
	setupZoom();
	buildThumbnailBoxes();
	if ($('portfolio-nav')) { centerPortfolioNav(); }

  Cufon.replace('h1');
  Cufon.replace('h2');
  Cufon.replace('h3');
	Cufon.replace('span.footer');
  Cufon.replace('.caption');
  Cufon.replace('#product-menu a');
  Cufon.replace('.tagline');
});
