function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function controlPlayer(command) {
	thisMovie("videoPlayer").controlPlayer(command);
}	

$(document).ready(function() {
	$.fn.bindCharacterCounting();		
	$.fn.commentForm();
	$.fn.commentPagination();
	$.fn.thisWeeksPoll();
	$.fn.mediaCommentPagination();
	
	if($.cookie('closedTout')){
		$('.carausel_cta_sm').remove();
	}
	
	// alert box close binding
	$('p.close a').click(function(e) {
		e.preventDefault();
		$.cookie('closedTout', 'true');
		$(this).parent().parent().hide();
	});
	
	// Shorten Share Links
	var twitterUrl = $('p.share a.twitter').attr('href');
	var stumbleUponUrl = $('p.share a.stumbleupon').attr('href');
	var articleTitle = unescape($('p.share a.twitter').attr('rel')).split(':')[0];
	$('p.share a.twitter').attr('href', twitterUrl + articleTitle + ' @OPENForum: ');
	$('p.share a.stumbleupon').attr('href', stumbleUponUrl + location.href);
	$('p.share a.twitter, p.share a.facebook, p.share a.linkedin, p.share a.digg, p.share a.reddit').shortenUrl();
	
	if (window.location.protocol == 'https:') {
		$('a.twitter').remove();
	}
	
	$('a.recommendations').each(function() {
		var $link = $(this);
		$link.oneShotAjax({component: 'thumbs-up'}, function() {
			$link.html(parseInt($link.html(),10) + 1);
			$link.replaceWith('<span class="recommendations">'+$link.html()+'</span>');
		});
	});
	
	// External links in new window
	$('a[href^="http://"]').attr("target", "_blank");
	
	$('div#viewed .ContactCarousel').contactcarousel({ visible: 4, boxPagination: true, pageSize: 4 });

});

