Cufon.set('fontFamily', 'bookman');
Cufon.replace('#calloutboxes header h2');
Cufon.replace('div#calloutboxes section.box section ul li a');
Cufon.replace('#highlightbox article .text header h2 span.red');
Cufon.replace('header#mast nav#mainnav li a', { 
	hover: {
		color: '#A21D20'
	}
});
Cufon.replace('section#newhereContent article *');
Cufon.replace('div#content-area aside nav ul li a', { 
	hover: {
		color: '#A21D20'
	}
});
Cufon.replace('#academics header#courseMast p');
Cufon.replace('#courseOverview aside ul li a');
Cufon.replace('aside#classTeachers header h3');


Cufon.set('fontFamily', 'lato');
Cufon.replace('#calloutboxes h3');
Cufon.replace('div#calloutboxes section.box section ul li time.dtposted');
Cufon.replace('div#calloutboxes section.box section ul li time');
Cufon.replace('section#newhereContent ul li a');
Cufon.replace('section#newhereContent article header h3');
Cufon.replace('#academics .details p.grades');

Cufon.set('fontFamily', 'learning');
Cufon.replace('#highlightbox article .text header h2');

Cufon.set('fontFamily', 'bookman');
Cufon.replace('#highlightbox article .text header h2 span.red');
Cufon.replace('#highlightbox article .text header h2 span.gray');
Cufon.replace('div#content-area aside header h2');
Cufon.replace('div#content-area aside header h2 span');
Cufon.replace('#highlightbox article .text p');
Cufon.replace('div#content-area article h2');
Cufon.replace('div#content-area article h2 span');
Cufon.replace('div#content-area article h4');
Cufon.replace('div#content-area article h3');
Cufon.replace('#academics header h2');
Cufon.replace('#academics header h2 span');
Cufon.replace('#academics nav#coursesubnav ul li', { 
	hover: {
		color: '#A21D20'
	}
});
Cufon.replace('#academics nav ul li', { 
	hover: {
		color: '#ffffff'
	}
});



$(document).ready(function(){

	$("nav#banners ul li").mouseover(function(){ 
		//alert("ere");
		$("#courseOverview .ribbondetails").removeClass('show');

		var currentId = $(this).attr('id');

		$("#courseOverview #details-"+currentId).addClass('show');

	});
	$(".calendar").toggle('show');
	$("a#toggleCalLink").bind('click',function(){ 
		 $(".calendar").toggle('show');
	});


	var $box = $('#newhereContent')
	$box.blindToggle('fast');

	$("a#newhereBtn").bind('click',function(){ 
		 $box.blindToggle('slow');
	});

	$("#mainnav ul li:nth-child(3)").addClass("push");
	$("#courseOverview .ribbondetails:nth-child(1)").addClass("show");

	
	
	// SLIDER BANNER PLUGIN

	var buttons = null, // dot nav goes here
		slides = $("#slideGallery article"),
		nCurrSlide = 0,
		autoSlide;

	slides.hide().eq(0).show();

	function getNextIndex() {
		var n = nCurrSlide+1;
		return (n>slides.length-1) ? 0 : n;
	}

	function getPrevIndex() {
		var n = nCurrSlide-1;
		return (n<0) ? slides.length-1 : n;
	}

	function slideEvent (index) {
		if (buttons) {
			buttons.removeClass('active').eq(index).addClass('active');
		}
		if (nCurrSlide != index) {
			slides.stop(true, true).hide().eq(nCurrSlide).show().fadeOut(400, function(){
				slides.hide().eq(index).fadeIn(400);
			});
		}
		nCurrSlide = index;
	}
	
	if (buttons) {
		buttons.click(function() {
			var index = $(this).parent().index();
			clearInterval(autoSlide);
			slideEvent(index);
		});
	}

	$("#prevSlide a").click(function(){
		clearInterval(autoSlide);
		slideEvent(getPrevIndex());
	});

	$("#nextSlide a").click(function(){
		clearInterval(autoSlide);
		slideEvent(getNextIndex());
	});
	
	autoSlide = window.setInterval(function(){ 
		slideEvent(getNextIndex());
	},10000);



});

function galleryWorks(parent) {
		
	$(parent).each(function(){

		var oParent = $(this),
			oHolder = $('.thumbnails .thumbHolder',oParent),
			oChildren = oHolder.children('.slab'),
			moving = false;

		oHolder.width(oChildren.eq(0).width()*oChildren.length);
		
		$(".controls .prev",oParent).hide(); // we never need the prev button on page load
		if (oChildren.length<=1) {	
			$(".controls .next",oParent).hide(); // if only 1 slab is available then we dont need the next button
		}

		$(".controls .next",oParent).click(function(){
			var obj1 = $(".thumbnails",oParent);
			var obj2 = $(".thumbnails .thumbHolder",oParent);
			var obj3 = $(".thumbnails .thumbHolder .slab",oParent);
			var wObj1 = obj1.width();
			var wObj2 = obj2.width();
			var wObj3 = obj3.width();
			var offset = function(){ return Math.round(obj1.offset().left) - Math.round(obj2.offset().left); };
			if ((wObj2-offset())>wObj1&&moving!==true) { 
				moving=true;
				if ((wObj2-offset()-wObj3)<=wObj1) {
					$(".controls .next",oParent).hide();
				}
				obj2.animate({ left:-(offset()+wObj3) }, 500, function(){
					moving=false;
				});
				$(".controls .prev",oParent).show();
			}
			return false;

		});
		
		$(".controls .prev",oParent).click(function(){
			var obj1 = $(".thumbnails",oParent);
			var obj2 = $(".thumbnails .thumbHolder",oParent);
			var obj3 = $(".thumbnails .thumbHolder .slab",oParent);
			var wObj1 = obj1.width();
			var wObj2 = obj2.width();
			var wObj3 = obj3.width();
			var offset = function(){ return Math.round(obj1.offset().left) - Math.round(obj2.offset().left); };
			if (offset()>0&&moving!==true) {
				moving=true;
				if ((offset()-wObj3)===0) {
					$(".controls .prev",oParent).hide();
				}
				obj2.animate({ left:-(offset()-wObj3) }, 500, function(){
					moving=false;
				});
				$(".controls .next",oParent).show();
			}
			return false;
		});

	});

}

