/* 
 * FTA website javascript functions
 */

$.validator.addMethod("ukphone", function(value, element) {
	if (value == "") return true;
    return /^[0-9 ]+$/i.test(value);
}, "The number entered must be a valid UK telephone number.");

$(document).ready(function() {
    // enable the menus
	$("ul.sf-menu").superfish();
	
	// third example
	$("#operator-tools").treeview({
		animated: "fast",
		collapsed: true,
		unique: true,
		persist: "cookie"
	});
	
	$('a.lightbox').lightBox();
	
	var fid = $('.further-info div.info');
	if (fid.size() > 1) {
		var parts = fid.size();
		var percentspacer = parts * 3;
		var percent = Math.round((100 - percentspacer) / parts);
		$('.further-info div.info').not(':last').each(function() {
			$(this).css('float', 'left');
			//$(this).css('width', (percent + 3) + '%');
			$(this).css('width', percent + '%');
			$(this).css('padding-right', '3%');
		});
		$('.further-info div.info:last').each(function() {
			$(this).css('float', 'left');
			$(this).css('width', percent + '%');
		});
		$('.further-info').append('<div class="clear"></div>');
	}
	
	var pagestoskip = new Array("/careers/*",
            "/services/training/*",
            "/emembership/*",
            "/dhl/*");
            
    var matchFound = null;
    var foundRealm = false;
    var url = $.url.attr("path");
    
    for (var i = 0; i < pagestoskip.length; i++) {
    	var mapPattern = pagestoskip[i].replace("\\*", ".*");
		matchFound = url.match(mapPattern);
		if (matchFound) {
			foundRealm = true;
			break;
		}
    }
    
    // THIS MUST STAY IN!
    $.gaTracker("UA-5943155-1");
    
});
