// JavaScript Document

// Replace Fonts
Cufon.replace('#side-bar h1', { fontFamily: 'DIN Light' });
Cufon.replace('.page-title h1', { fontFamily: 'DIN Medium' });
Cufon.replace('.gallery-category h2', { fontFamily: 'DIN Light' });

$(document).ready(function() {
	 
	 
	thisContentContainment();
	$(window).resize(function() {
        thisContentContainment();
    });
	
	// Menu Initialisation
	$("ul.sf-menu").superfish({
		pathClass:  'active'
	});
	
	$(".copy-container tr:nth-child(even)").addClass("alt");
	
	$(".copy-container h2:first-child").addClass("firstchild");
	$(".copy-container h3:first-child").addClass("firstchild");
	$(".copy-container h4:first-child").addClass("firstchild");
	$(".copy-container h5:first-child").addClass("firstchild");
	$(".copy-container h5:first-child").addClass("firstchild");
	$(".gallery-category:first").addClass("firstchild");
	
	$(".print-page").click(function() {
		window.print();
		return false;
	});
	
	//$(".copy-container, .menu-container").css("overflow-x","hidden");
	
});

function thisContentContainment() {
	
    var verticalMargin = $(".headcontainer").outerHeight();
    var containerOverflow = $("body").height() - verticalMargin;
    
	$("#wrapper").css("overflow","auto");
	$("#wrapper").height(containerOverflow);
	
} 

function displayErrorsAlert(aErrors) {

    if (aErrors.length) {
        if (aErrors.length > 1) {
            var prefix = 'Some errors occurred:\n\n';
            var suffix = '\nPlease correct these errors and try again.';
        }
        else {
            var prefix = 'An error has occurred:\n\n';
            var suffix = '\nPlease correct this error and try again.';
        }

        var errorMessage = prefix;

        for (var i = 0; i < aErrors.length; i++) {
            errorMessage += aErrors[i] + "\n";
        }

        errorMessage += suffix;

        alert(errorMessage);
    }

}

