$(document).ready(function () {

	$('ul.sf-menu').superfish({
		autoArrows: false,
		dropShadows: false,
		pathClass: 'current',
		delay: 1000,                // the delay in milliseconds that the mouse can remain outside a submenu without it closing 
    	animation: {opacity:'show'},   // an object equivalent to first parameter of jQueryÕs .animate() method 
    	speed: 'normal'
	});
	
	// EXTERNAL LINKS
	$('A[rel="external"]').click(function()
	{
		window.open($(this).attr('href'));
		return false;
	});
	
	Cufon.replace('h2');
	
	$("a#watchvideo").colorbox();
	
	$("a.cpModal").colorbox();
	
	   	
	jQuery.validator.addMethod
	(
		"phoneIE", 
		function(phone_number, element)
		{
			phone_number = phone_number.replace(/\s+/g, ""); 
			return this.optional(element) || phone_number.length > 9 && phone_number.match(/^(\+353)?\s?-?\(?[0-9]{1,4}\)?\s?-?[0-9]{5,8}$/);
		},
		"Please specify a valid phone number"
	);

	$('#getintouch-header').ajaxForm
	({
		target: "#header-hiddenDIV",
		beforeSubmit: function()
		{
			$(".msg").empty();
			//$(".msg").html("Sending...");
		},
		success: function(rtn)
		{ 
			if(rtn == 'success')
			{
				$(".msg").html("Thank you for contacting us. We will be in touch shortly.");
					$("#getintouch-header").resetForm();
			}
			$("#header-hiddenDIV").empty();
   	    }
	});
});
