jQuery.fn.slideFadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: "toggle", height: "toggle"}, speed, easing, callback);  
}; 

(function($) {
	$.fn.customFadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customFadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

function toggleDiv(divId)
{
	// use Jquery
	$("#" + divId).toggle();
}
function showDiv(divId, type)
{
	document.getElementById(divId).style.display = type;
}
function hideDiv(divId)
{
	document.getElementById(divId).style.display = "none";
}

// news scroller
var ourInterval;
var scrollSpeed = 10;
var scrollAmount = 2;
var itemWidth = 201;
var containerWidth;
var prev;
var next;
function scrollStart(direction, divId)
{
	//if(ourInterval) clearInterval(ourInterval);
	ourInterval = window.setInterval("scrollIt('"+direction+"', '"+divId+"')", scrollSpeed);
}
function scrollEnd()
{
	window.clearInterval(ourInterval);
}
function scrollPosition(divId)
{
	currentPosition = document.getElementById(divId).scrollLeft;
	scrollableWidth = containerWidth - (3 * itemWidth);
	//$("#debug").html("Current: " + currentPosition + " | Total Width: " + scrollableWidth);
	
	prev.removeClass("disabled");
	next.removeClass("disabled");
	if(currentPosition <= 0)
		prev.addClass("disabled");
	else if(currentPosition >= (scrollableWidth))
		next.addClass("disabled");
	
	return currentPosition;
}
function scrollIt(direction, divId)
{		
	currentPosition = scrollPosition(divId);
		
	if(direction == "right")
		newScrollAmount = currentPosition - scrollAmount;
	else
		newScrollAmount = currentPosition + scrollAmount;
	
	document.getElementById(divId).scrollLeft = newScrollAmount;	
}
function innitScroller(divId, elements) 
{
	prev = $("#newsscrollercontrols .prev");
	next = $("#newsscrollercontrols .next")
	containerWidth = itemWidth * elements;
	document.getElementById(divId).style.width = containerWidth + "px";
}
function scrollDirect(no, divId)
{
	no--;
	newScrollAmount = itemWidth * no;
	//alert(itemWidth + "x" + no);
	//alert(newScrollAmount);
	document.getElementById(divId).scrollLeft = newScrollAmount;
	scrollPosition(divId);
}



$(document).ready(function() {
	$('#feed marquee').marquee();
});