/*
$(document).ready(function() {
	$('a.lightbox').lightBox();
});
*/

/* center div based on width of child element img
*/
$(window).load(function() {
	$("div.center").each(function() {		
		var width=0;
		var count=0;
		var margin=5;
		var $div = $(this);
		$div.children("img").each(function() {
			width += $(this).width();
			count++;
		});
		if (count > 1) width += (margin *2) * count;
		$div.css("width", width);
	});
});

/* Link types
*/
$(document).ready(function() {

	var fileTypes = {
		doc: 'doc',
		xls: 'xls',
		pdf: 'pdf',
		ppt: 'ppt'
	};
	
	$('a').each(function() {
	
		var $a = $(this);
		var href = $a.attr('href');
		
		if ((href.match(/^http/)) && (! href.match(document.domain))) {
		
			// make sure link doesn't contain an image
			if (!$a.find(">:first-child").is("img")) {
				// use a special image for external links
				var class_name = 'www';
			}
		
		} else {
			// get the extension from the href
			var hrefArray = href.split('.');
			var extension = hrefArray[hrefArray.length - 1];
			var class_name = fileTypes[extension];
		}
		
		if (class_name) { 
			$a.addClass("download "+ class_name);
		}
	
	});

});

