/*
	HS AVIATION JS
	DEPENDENT ON THE JQUERY LIBRARY
	CREATED:28.04.11
	MODIFIED:08.06.11
	AUTHOR:ANDY FIELD
*/

 $(document).ready(function(){
	//window.onload = function(){alert("welcome");}
	
	/* SECONDARY SCHOOLS - QUICK FIX */
	
	$("#se01a a.add").click(function(){
        $("#se01a").hide();
        $("#se02").show();
        $("#se02a").show();
        return false;
    });
    
    $("#se02a a.add").click(function(){
        $("#se03").show();
        $("#se03a").show();
        $("#se02a").hide();
        return false;
    });
    
    $("#se02a a.remove").click(function(){
        $("#se01a").show();
        $("#se02").hide();
        $("#se02a").hide();
        return false;
    });
    
     $("#se03a a.remove").click(function(){
        $("#se03").hide();
        $("#se03a").hide();
        $("#se02a").show();
        return false;
    });
    
    /* FURTHER EDUCATION - QUICK FIX */
	
	$("#fe01a a.add").click(function(){
        $("#fe01a").hide();
        $("#fe02").show();
        $("#fe02a").show();
        return false;
    });
    
    $("#fe02a a.add").click(function(){
        $("#fe03").show();
        $("#fe03a").show();
        $("#fe02a").hide();
        return false;
    });
    
    $("#fe02a a.remove").click(function(){
        $("#fe01a").show();
        $("#fe02").hide();
        $("#fe02a").hide();
        return false;
    });
    
     $("#fe03a a.remove").click(function(){
        $("#fe03").hide();
        $("#fe03a").hide();
        $("#fe02a").show();
        return false;
    });
    
    /* PREVIOUS EMPLOYMENT - QUICK FIX */
    
    $("#prev01a a.add").click(function(){
        $("#prev01a").hide();
        $("#prev02").show();
        $("#prev02a").show();
        return false;
    });
    
    $("#prev02a a.remove").click(function(){
        $("#prev01a").show();
        $("#prev02").hide();
        $("#prev02a").hide();
        return false;
    });
    
    /* REFERENCES - QUICK FIX */
	
	$("#ref01a a.add").click(function(){
        $("#ref01a").hide();
        $("#ref02").show();
        $("#ref02a").show();
        return false;
    });
    
    $("#ref02a a.add").click(function(){
        $("#ref03").show();
        $("#ref03a").show();
        $("#ref02a").hide();
        return false;
    });
    
    $("#ref02a a.remove").click(function(){
        $("#ref01a").show();
        $("#ref02").hide();
        $("#ref02a").hide();
        return false;
    });
    
     $("#ref03a a.remove").click(function(){
        $("#ref03").hide();
        $("#ref03a").hide();
        $("#ref02a").show();
        return false;
    });
    
	$("a[href=#top]").click(function(){
        $("html, body").animate({scrollTop:0}, "slow");
        return false;
    });
	
	$("#slides").slides({
	    	preload: true,
			preloadImage: '/assets/homepage-loading.gif',
			container: 'slides-container',
			generateNextPrev: true,
			pagination: false,
			generatePagination: false,
			play: 8000,
			pause: 6000,
			//hoverPause: true,
			animationStart: function(current){
					$('.panel').animate({bottom:-285},300);
					if (window.console && console.log) {
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.panel').animate({bottom:0},200);
					if (window.console && console.log) {
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.panel').animate({bottom:0},300);
				}
	});
	
	$("#newsletter-form").validate();
	$("#freeform").validate();
	
	$(".r01 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -1584px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });
    
    $(".r02 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -792px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });
    
    $(".r03 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -1056px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });
    
    $(".r04 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -528px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });
    
    $(".r05 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -264px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });
    
	$(".r06 a").hover(function(){
        $("#regional-map").css('backgroundPosition', '0 -1320px');
    }, function(){
        $("#regional-map").css('backgroundPosition', '0 0');
    });

	$.fn.setAllToMaxHeight = function(){
		return this.height( Math.max.apply(this, $.map( this , function(e){ return $(e).height() }) ) );
	}
	$("ul.units li").setAllToMaxHeight();

});


 
$(window).load(function() {
	$("#slider").nivoSlider({
        effect:'fade',
        animSpeed:1000,
        pauseTime:12000,
        directionNav:true,
        directionNavHide:true,
		controlNav:false,
		keyboardNav:true,
        pauseOnHover:true,
        captionOpacity:0.8
	});
	
	$("#noslider").nivoSlider({
        effect:'fade',
        animSpeed:1000,
        pauseTime:12000,
        directionNav:false,
        directionNavHide:false,
		controlNav:false,
		keyboardNav:false,
        pauseOnHover:false,
        captionOpacity:0.8
	});
});
