$(document).ready(function() {
	  //Fancybox Options
	  /*$(".booknow").fancybox({
			'titleShow'		:false,
			'autoScale' :false,
			'scrolling' :false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'margin'			: '0',
			'padding'			: '0',
			'overlayColor'		: '#000',
			'overlayOpacity'	: '0.4'
	});	*/
	$(".fancy-event").fancybox({
			'titleShow'		:false,
			'autoScale' :false,
			'scrolling' :false,
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'margin'			: '0',
			'padding'			: '0',
			'overlayColor'		: '#000',
			'overlayOpacity'	: '0.4'
	});	
	$("#news_gallery_main").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'margin'				: '50',
		  'padding'				: '2'  
	  }); 
	$("#help1_button").fancybox({
		  'titleShow'		:false,
		  'autoScale' :false,
		  'scrolling' :false,
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'margin'				: '50',
		  'padding'				: '0'  
	  });
	  	$("#help2_button").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'margin'				: '50',
		  'padding'				: '0'  
	  }); 
	  	$("#help3_button").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'margin'				: '50',
		  'padding'				: '0'  
	  }); 
	  	$("#help4_button").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'margin'				: '50',
		  'padding'				: '0'  
	  }); 
	  	$("#help5_button").fancybox({
		  'titlePosition'		: 'inside',
		  'transitionIn'		: 'fade',
		  'transitionOut'		: 'fade',
		  'overlayColor'		: '#000',
		  'overlayOpacity'		: '0.3',
		  'width'				: '500',
		  'height'				: '200',
		  'margin'				: '50',
		  'padding'				: '0'  
	  }); 
});

jQuery(document).ready(function($){
	
		//CHANGE ME!!! Define the relative or absolute path to your backend script
		var remoteUrl = 'includes/backend.php';
		
		//Initialize the HTTP cache
		var remoteCache = new Array();
		
		
		
		//For each link in the calendar...
		$('table.calendar a').each(function(i,item) { 
		
		
		//$('table.calendar a').each(function(i,item){
			
			//Unique ID for the link
			var linkId = item.id;
			
			//Unique URL for the link
			var linkUrl = remoteUrl+'?timestamp='+linkId;
			
			//Attach onclick event handler
			$(this).click(function() {
			
				var calendarEvents = $('#calendar-events');			
				calendarEvents.slideUp('fast',function(){			
					if( remoteCache[linkId] != undefined ) { 
						calendarEvents.html(remoteCache[linkId]);
						calendarEvents.slideDown('fast');
					} else {
						calendarEvents.load(linkUrl,function(){
							remoteCache[linkId] = calendarEvents.html();
						 	calendarEvents.slideDown('fast');
						});
					}
				});
				return false;
			});
			
		});
});
	

//DROPDOWN
$(function() {
	//SHOW DROPDOWNS
	$('.centredropdown').mouseover(function() {
		$('.centredrop').show();
		$('.centredropdown').addClass('selected');
                $('#mapsignbox').removeClass().hide();
	});
	$('.coursedropdown').mouseover(function() {
		$('.coursedrop').show();
		$('.coursedropdown').addClass('selected');
                $('#mapsignbox').removeClass().hide();
	});
	
	
	$('.off').mouseover(function() {
		$('.coursedrop').hide();
		$('.coursedropdown').removeClass('selected');
		$('.centredrop').hide();
		$('.centredropdown').removeClass('selected');
	});
	$('.centreoff').mouseover(function() {
		$('.centredrop').hide();
		$('.centredropdown').removeClass('selected');
	});
	$('.courseoff').mouseover(function() {
		$('.coursedrop').hide();
		$('.coursedropdown').removeClass('selected');
	});
        /*$('#ukmap').mouseout(function() {
		$('#mapsignbox').removeClass().hide();
	});*/
	$('#top, #number, #callback, #content').mouseover(function() {
		$('.coursedrop').hide();
		$('.coursedropdown').removeClass('selected');	
		$('.centredrop').hide();
		$('.centredropdown').removeClass('selected');					   
	});
	$('#play-music').click(function() {
		window.open('musicplayer.html','musicPlayer','width=360,height=265,toolbar=0,location=0, directories=0, status=0, menubar=0,scrollbars=1,resizable=0,left=0,top=0');
	});
});
//MAP HOVER
function doMap(img) {
	document.getElementById('mapimg').src = 'images/map/'+img;
}

//MENU OPEN AND CLOSE
jQuery.fn.openMenu = function(id) {
    var box = document.getElementById('a'+id);
	if(box.style.display == "none") {
		$('#a'+id).slideDown(400);
		$(this[0]).removeClass('expand');
		$(this[0]).addClass('close');
	} else if(box.style.display == "block") {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('close');
		$(this[0]).addClass('expand');
	} else {
		$('#a'+id).slideUp(400);
		$(this[0]).removeClass('close');
		$(this[0]).addClass('expand');
	}
};

//PARTNERS CAROUSEL
function mycarousel_initCallback(carousel){
	carousel.buttonNext.bind('click', function() {
		carousel.startAuto(0);
	});			
	carousel.buttonPrev.bind('click', function() {
		carousel.startAuto(0);
	});			
	carousel.clip.hover(function() {
		carousel.stopAuto();
	}, function() {
		carousel.startAuto();
	});
};
jQuery(document).ready(function() {
	jQuery('#mycarousel').jcarousel({
		auto: 3,
		wrap: 'circular',
		initCallback: mycarousel_initCallback
	});
     //$('img[usemap]').maphilight({fillColor:"d7e66a", fillOpacity:1, strokeColor:"ffffff"});
	 jQuery('#mycarousel2').jcarousel({
		scroll: 1, 
        auto: 3,
        wrap: 'circular'
    });
});
$('.coursedrop').hide();
setTimeout("scroll()",1500);
setTimeout("scrollnews()",1500);
setTimeout("scrollsuccess()",1500);
function scroll() {
	$('#scrolling-header').cycle({
		fx: 'fade',
		speed:  2500,
		delay: 1000 
	});
	$('#scrolling-header').show();
}
function scrollnews() {
	$('#news-scroll').cycle({
		fx: 'fade',
		speed:  2500,
		delay:   2500
	});
}
function scrollsuccess() {
	$('#success-scroll').cycle({
		fx: 'fade',
		speed:  4200,
		delay: 500 
	});
}

<!--FORM LABEL-->
function clearText(field){
    if (field.defaultValue == field.value) field.value = '';
    else if (field.value == '') field.value = field.defaultValue;
}
function showCentres(cat,id) {
       $.ajax({
          type: "POST",
          url: "includes/findcentres.php",
		  data: "regionid="+ id+ "&catid="+ cat,  
          success: function(html){ 
		  	  var redirect = html.split('##'); 
			  if (redirect[0] == 'redirect') {
				window.location.href = redirect[1];
			  } else {
				var ajaxDisplay = document.getElementById('centre_list');
				ajaxDisplay.innerHTML = html;
				$('#region_list').hide();
				$('#centre_list').show();				  
			  }
		  }
        });
	 return false;
}
function negMonth(month, year) {
		var negmonth = parseInt(month - 1);
		var posmonth = Number(month) + Number(1);
		
		if(negmonth == 0) {
			negmonth = 12;
			year = year -1;
		}
		
		jsneg = null;
		newneg = null;
		
		delete jsneg;
		delete newneg;

		$('.scroll_left').attr('onclick', '');
		$('.scroll_left').unbind('click');
		
		$('.scroll_right').attr('onclick', '');
		$('.scroll_right').unbind('click');
		
		var jsneg = "showCalendar("+ negmonth +"," + year + "); negMonth("+ negmonth +"," + year + ");";
    	var newneg = new Function(jsneg);
		$("#calender-left").attr('onclick', '').click(newneg);
		
		var jsplus = "showCalendar("+ posmonth +"," + year + "); posMonth("+ posmonth +"," + year + ");";
    	var newplus = new Function(jsplus);
		$("#calender-right").attr('onclick', '').click(newplus);
		
}
function posMonth(month, year) {

		var posmonth = Number(month) + Number(1);
		var negmonth = Number(month) - Number(1);
		
		if(posmonth == '13') {
			posmonth = 1;
			year = Number(year) + Number(1);
		}
		
		jspos = null;
		newpos = null;
		
		delete jspos;
		delete newpos;

		$('.scroll_left').attr('onclick', '');
		$('.scroll_left').unbind('click');
		
		$('.scroll_right').attr('onclick', '');
		$('.scroll_right').unbind('click');
		
		var jsneg = "showCalendar("+ negmonth +"," + year + "); negMonth("+ negmonth +"," + year + ");";
    	var newneg = new Function(jsneg);
		$("#calender-left").attr('onclick', '').click(newneg);
		
		var jsplus = "showCalendar("+ posmonth +"," + year + "); posMonth("+ posmonth +"," + year + ");";
    	var newplus = new Function(jsplus);
		$("#calender-right").attr('onclick', '').click(newplus);
}
function showCalendar(month,year) {
       $.ajax({
          type: "POST",
          url: "includes/findcalendar.php",
		  data: "month="+ month+ "&year="+ year,  
          success: function(html){ 
			$('#calender-results').empty().append(html);
          }
        });
		$.ajax({
          type: "POST",
          url: "includes/finddate.php",
		  data: "month="+ month+ "&year="+ year,  
          success: function(html){ 
			$('#month-results').empty().append(html);
          }
        });
}
function hideCentres() {
	$('#centre_list').hide();
	$('#region_list').show();
	
}

