$(document).ready(function() {

	// check if homepage
	if ($('.is_home').length > 0) {

		$('#cnr_ctt_left').css('top','-60px');

		var flashvars = {};
		var params = {
			menu: 'false',
			wmode: 'transparent'
		};
		var attributes = {};

		swfobject.embedSWF("/beyondmatters/wp-content/themes/beyondmatters/swf/beyond_matters.swf", "ctt_flash_beyond_matters", "240", "1000", "9.0.0","expressInstall.swf", flashvars, params, attributes);
	}

	// remove first styling h2 element if IE6
	if ($.browser.msie) {
		$('#cnr_ctt_main div.post:first-child h2').css({ 'padding' : '0 0 0 50px', 'background' : 'none'});
	}

	// open links to downloadable files or other sites in a new window
	Array.prototype.f_contains = function(s) {
		for (var i = 0; i < this.length; i++) {
			if (this[i] == s) return true;
		}
		return false;
	}

	// known extensions for downloadable files
	var exts = ['png', 'jpg', 'jpeg', 'gif', 'pdf', 'doc', 'xls', 'ppt', 'zip', 'gz', 'mpg', 'mpeg', 'mov', 'mp4', 'avi', 'wmv', 'mp3', 'wav', 'swf', 'bmp', 'tif', 'tiff', 'svg'];

	var links = document.getElementsByTagName('a');

	for (var i = 0; i < links.length; i++) {
		var link  = links[i];

		// find extension
		var split_slash = link.href.split('/');
		var split_ext   = split_slash[split_slash.length - 1].split('.');
		var ext = split_ext[split_ext.length - 1];

		// check if extension indicates a downloadable file
		if (split_ext.length > 1) {
			if (exts.f_contains(ext)) {
				links[i].target = '_blank';
			}
		}

		// look for links to other sites
		if (link.href.substring(0, 7) == 'http://') {
			if (link.href.substring(7, 7 + window.location.hostname.length) != window.location.hostname) {
				links[i].target = '_blank';
			}
		}
	}
});

