$(document).ready(function(){ 
  //AttachTweetWidget();
	CreateToolTip();
  AttachFacyBox();
  ActivateLocalScroll();
});

function AttachTweetWidget()
{
	var data = $(".tweet").attr('id').split('-'); 
	var querystring = data[0]; 
	var tweet_count = data[1];

	if(data[2]) { 
		var userstring = data[2]; 
		var users = userstring.split('|');
	} 
	
	if ($(".tweet")) { 
		$(".tweet").tweet({ 
			avatar_size: 32, 
			count: tweet_count, 
			query: querystring, 
			username: users,
			loading_text: "loading tweets..." 
		}); 
	}
}

function CreateToolTip()
{
	$('.popups > div').each(function(){
		var popUpText = $(this).find('div')[0].innerHTML;
		$(this).children("h2").qtip({
		   content: popUpText,
		   style: { 
		      background: "#1a1917",
		      color: "#ffffff",
		      tip:  "bottomMiddle",
		      border: {
			width: 3,
			radius: 8,
			color: "#1a1917"
		      },
		      width: {min:350}
		   },
		   position: { 
			corner: {
			    target: 'topLeft',
			    tooltip: 'bottomLeft',
			    color: '#1a1917'
			 } 
		   }
		})
	});
}

function ActivateLocalScroll()
{
  $.localScroll();
}

function AttachFacyBox()
{
  $('a[rel*=facybox-modal]').each(function(index) {
      $(this).click(function() {
        var urlToLoad = $(this).attr("url");
        $.facybox({ ajax: urlToLoad });
      });
  });
}

