// JavaScript Document

$(document).ready(function() {
	/* Sliding menu */
	$(".titleText").click(function(){
		$(this).parent().next().css("background-color","#e8e8e8").find(".innerData").toggle("slow");
		$(this).parent().next().css("background-color","#e8e8e8").find(".innerSubContent").toggle("slow");
	});
	
	$(".slideDescription").cycle({
		fx: 'fade',
		cleartypeNoBg: true,
	    startingSlide: 0,	
		continuous: 0,
		fit: 0,
		autostop:3,
		autostopCount:4,
		pager:'#navControl',
		next:'#rightArrow',
		prev:'#leftArrow',
		after:onAfter
	});
	$("#navControl a, #leftArrow, #rightArrow").click(function() {
		$(".slideDescription").cycle("pause");
	});
	function onAfter(curr, next, opts) {
		var index = opts.currSlide;
		//$('#leftArrow')[index == 0 ? 'hide' : 'show']();
		$('#leftArrow img')[index == 0 ? 'addClass' : 'removeClass']("dispOverlay");
		//$('#rightArrow')[index == opts.slideCount - 1 ? 'hide' : 'show']();
		$('#rightArrow img')[index == opts.slideCount - 1 ? 'addClass' : 'removeClass']("dispOverlay");
	}
});
function openVideoModal(videoPath, headerText) {
	$.ajax({
		url: "/classwareweb/html/videoPlaceHolder.html",
		cache: true,
		success: function(html){
			html = html.replace('$$VIDEOPATH$$', videoPath);
			html = html.replace('$$HEADERTEXT$$', headerText);
			$.facebox(function() {
				$.facebox('<div id="videoPlace" style="width:750px;"></div>');
			});
			$("#facebox").focus();
			$('#facebox').css('left', $(window).width() / 2 - ($('#facebox table').width() / 2));
			$("#videoPlace").html(html);
			//Calling an event on click of close button
			$('.closeIcon').click(function() {
				$(document).trigger('close.facebox');
			});
			//if($.browser.msie && $.browser.version < 7){
				resizeFaceboxOverlay();
			//}
		},
		error: function(XMLHttpRequest, textStatus, errorThrown) {
			alert("Error:"+ textStatus + ":" + errorThrown);
		}
	});
}
