$(document).ready(function() {
	$('#accordion').easyAccordion();
	$('#magcarousel').jcarousel({
		scroll:1,
		visible:1,
		itemVisibleInCallback: function(car, li, index, state) {
			$("#magnum").html("num." + $(li).children("a").children("img").attr("title"));
		}
	});
	
	
	if ($.fn.lightBox) {
		$(".gallery-icon a").lightBox();
	};
	
	// fb share icon click
	$("a[class='fb-share']").click(function() {
		var url = $(this).attr("href");
		var title = $(this).attr("rel");
		
		if (url == undefined) url = window.location.href;
		if (url == "") url = window.location.href;


		window.open('http://www.facebook.com/share.php?u=' + url + '&t='+encodeURIComponent(title), 'share', 'toolbar=0,status=0,width=626,height=436');
	
		return false;
	});
	
	// twitter share icon click
	$("a[class='tw-share']").click(function() {
		var url = $(this).attr("href");
		var title = $(this).attr("rel");
		
		if (url == undefined) url = window.location.href;
		if (url == "") url = window.location.href;
		
		var o = this;
		
		if ( url.substring(0, 14) == "http://bit.ly/") {
			window.open('http://twitter.com/home?status=' + url + ' : ' + encodeURIComponent(title) , 'share');				
		}
		else {
			$(this).bitly({url:url, onFinish:function() {
				window.open('http://twitter.com/home?status=' + $(o).attr("href") + ' : ' + encodeURIComponent(title) , 'share');
			}});
		}
		
		
		return false;
	}); 
	
	
});
