// START JQUERY
$(document).ready(function(){
	
	
// VALIDATE    
    $.validator.addMethod("personalEmail", function(value, element) {

        var flag = true;

        if (value.match(/@hotmail.com$/)) { flag = false; }
        if (value.match(/@hotmail.co.uk$/)) { flag = false; }
        if (value.match(/@yahoo.com$/)) { flag = false; }
        if (value.match(/@yahoo.co.uk$/)) { flag = false; }
        if (value.match(/@gmail.com$/)) { flag = false; }
        if (value.match(/@aol.com$/)) { flag = false; }
        if (value.match(/@gmx.com$/)) { flag = false; }
        if (value.match(/@me.com$/)) { flag = false; }  

        return flag;

    }, "Sorry, but we don't accept personal email accounts. If you have any queries about this, then please contact us on 0207 832 1800");
	
$("#eventForm").validate();


// SET TALLEST
	$.fn.equalHeight = function() {
		tallest = 0;
		this.each(function(){
			thisHeight = $(this).height();
			if( thisHeight > tallest)
				tallest = thisHeight;

		});
		this.each(function(){
			$(this).height(tallest);
		});
	}
	$('.row.rowone .module .pad').equalHeight();
	$('.row.rowtwo .module .pad').equalHeight();
	
	$("hr").replaceWith("<div class=\"hr\"></div>");
    
	$(".lnav li a:not(li li a, a.subnav-sel)").prepend("> ");
	$(".lnav li a.subnav-sel:not(li li a)").prepend("&#8744; ");
	
	
// SUPERFISH
	$(".sf-menu").superfish({
		pathClass: 'current',
		delay:			500,
		animation:		{opacity:0.95,height:'show'},
		speed:			'fast',
		disableHI:		false,
		dropShadows:	false,
		autoArrows:		false
	});

// SET ACTIVE MENUS
	$("#lcol li a").each(function() {
		if(this.href == window.location.href.split("#")[0]) {
			$(this).addClass("active");
			$(this).parents("li:last").addClass("current");
		}
	});
	
// ADD CLASSES
	$("li:first-child,dl:first-child").addClass("first");
	$("li:last-child,dl:first-child").addClass("last");
	
});
// END JQUERY
	
function ajaxPageMethod(fn, paramArray, page) {

    var pagePath = window.location.pathname;
    var paramList = '';

    if (paramArray.length > 0) {
        for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
            ob_post.AddParam(paramArray[i], paramArray[i + 1]);
        }
    }

    ob_post.post(page, fn, function() { });
}

function updateResultCount(fn, paramArray, page) {

    var pagePath = window.location.pathname;
    var paramList = '';

    if (paramArray.length > 0) {
        for (var i = 0; i < paramArray.length; i += 2) {
            if (paramList.length > 0) paramList += ',';
            ob_post.AddParam(paramArray[i], paramArray[i + 1]);
        }
    }

    ob_post.post(page, fn, function(msg) { $("#trainingresultcount").text(msg); });

}