// Common JQuery and Javascript for NZFT
$(document).ready(function() {
	
	// Preload page images
	preload([
    'images/titles/title_directory.jpg'
]);
	
	// Video Close / Open
	$("#video_close").click(function(){
		$("#videos").fadeOut(300);
		$("#showvideos").fadeIn(200);
	});
	
	$("#showvideos").click(function(){
		$("#showvideos").fadeOut(200);
		$("#videos").fadeIn(300);
	});
	
	// Fade in boxes
	$("#kiaora").fadeIn(300, function(){
		$("#forstudents").fadeIn(500, function(){
			$("#forindustry").fadeIn(500);
			$("#videos").fadeIn(1000);
		});
	});
	
	// Hover
	$("#forstudents").mouseenter(function() {
		$("#kiaora").fadeTo(250,1);
		$("#forindustry").fadeTo(250,.5);
	});
	$("#forstudents").mouseleave(function() {
		$("#kiaora").fadeTo(250,1);
		$("#forindustry").fadeTo(250,1);
	});
	$("#forindustry").mouseenter(function() {
		$("#kiaora").fadeTo(250,1);
		$("#forstudents").fadeTo(250,.5);
	});
	$("#forindustry").mouseleave(function() {
		$("#kiaora").fadeTo(250,1);
		$("#forstudents").fadeTo(250,1);
	});
	
	// Click home buttons
	$("#forstudents").click(function() {
		window.location="students/"
	});
	$("#forindustry").click(function() {
		window.location="industry/"
	});
	
	//Png Fix
	$(document).pngFix(); 
	
	// Colour Box Styles
	$('.colorbox1').colorbox({transition:"none", width:"75%", height:"75%"});
	$(".colorbox2").colorbox({width:"80%", height:"80%", iframe:true});
	$(".colorbox3").colorbox({width:850, height:"80%"});
	$(".youtube").colorbox({iframe:true, innerWidth:782, innerHeight:470});
	$(".colorboxflickr").colorbox({iframe:true, innerWidth:"90%", innerHeight:"90%"});
	
    // Gate Date
	var d = new Date();
	var displayYear = d.getFullYear();
	$("#year").html(displayYear);
	
	// Directory Show Hide
	$('#directory_close').click(function() {
		
		$('#directory_close').fadeOut(100, function() {
			$('#directory').slideUp(500, function() {
				$('#directory_close').fadeIn();
				});	
			});
		});
	
	$('#tabs_directory').click(function () {
		$('#directory').slideToggle('500', function() {
    // Animation complete.
  });
	});
	
	//Video Player controls
	$('#videocycle').cycle({
		fx: 'scrollHorz',
		pause: 1,
		speed: 1000,
		timeout: 0,
		cleartype: 1,
		cleartypeNoBg: 1,
		prev: '#video_prev',
		next: '#video_next'
	});
	
	// Show Related
	$(".showvideos").click(function() {
		$("#realtedvideos").slideDown(1000);
		$(".showvideos").hide();
		$(".hidevideos").fadeIn(1000);
		});
	$(".hidevideos").click(function() {
		$("#realtedvideos").slideUp(1000);
		$(".hidevideos").hide();
		$(".showvideos").fadeIn(1000);
		});
	
	// Latest News Ticker
	$('#newsitemsticker').cycle({
		fx: 'scrollHorz',
		pause: 1,
		speed: 850,
		timeout: 6000,
		cleartype: 1,
		cleartypeNoBg: 1,
		prev: '#newsticker_prev',
		next: '#newsticker_next'
	});
	
	// Hide Video Pane by default
	
	
});
