// sIFR
var univers = {
  src: 'http://www.d1013782.cp.blacknight.com/thediscoverypartnership.com/public/swf/univers.swf'
};
 
sIFR.activate(univers);
 
sIFR.replace(univers, {
      selector: '#left-col-header h2',
      css: [
      '.sIFR-root { font-size: 16px; color: #28506c; text-align: left;}'
      ],
      wmode: 'transparent'
});

sIFR.replace(univers, {
      selector: '#left-col-header h3',
      css: [
      '.sIFR-root { font-size: 13px; color: #8d7d24; text-align: left;}'
      ],
      wmode: 'transparent'
});

sIFR.replace(univers, {
      selector: '#right-col-header strong',
      css: [
      '.sIFR-root { width: 200px; font-size: 15px; color: #28506c; text-align: right;}'
      ],
      wmode: 'transparent'
});

sIFR.replace(univers, {
      selector: '#right-col-header em',
      css: [
      '.sIFR-root { font-size: 13px; color: #8d7d24; text-align: right;}'
      ],
      wmode: 'transparent'
});





$(document).ready(function()
{
	// DROPDOWNS
	$('#navigation ul.sf-menu').superfish(
	{ 
	    delay:       500,                            // one second delay on mouseout 
	    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
	    speed:       'fast',                          // faster animation speed 
	    autoArrows:  false,                           // disable generation of arrow mark-up 
	    dropShadows: false                            // disable drop shadows 
	});
	
	// FORM INPUT VALUES
	focusLabels();
	prepareForms();
	
	// EXTERNAL LINKS
	$('A[rel="external"]').click(function()
	{
		window.open($(this).attr('href'));
		return false;
	});
	
	// SMALL ENQUIRY FORM VALIDATION
	if ($('#get-in-touch'))
	{
		$('input[name="get-in-touch"]').click(function()
		{
			var verdict		= true;
			
			// VALIDATE NAME
			var name		= $.trim($("#name").val());
			$('#name').attr('value', name);
			
			// VALIDATE EMAIL
			var emailReg	= /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
			var email		= $.trim($("#email").val());
			$('#email').attr('value', email);
			
			// VALIDATE PHONE
			var phoneReg	= /^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$/;
			var phone		= $.trim($("#phone").val());
			$('#phone').attr('value', phone);
			
			if (name == '' || name == 'Name: ') {
				$("#get-in-touch div").fadeOut('slow', function() {
					$("#get-in-touch strong").replaceWith('<strong class="error">Name is required.</strong>');
					$("#get-in-touch em").replaceWith('<em class="error">Please enter your name.</em>');
					$("##get-in-touch div").fadeIn('slow');
				});
				verdict = false;
			} else if (email == '' || email == 'Email: ') {
				$("#get-in-touch").fadeOut('slow', function() {
					$("#get-in-touch strong").replaceWith('<strong class="error">Email is required</strong>');
					$("#get-in-touch em").replaceWith('<em class="error">Must be formatted correctly (name@domain.com)</em>');
					$("#get-in-touch").fadeIn('slow');
				});
				verdict = false;
			} else if (!emailReg.test(email)) {
				$("#get-in-touch div").fadeOut('slow', function() {
					$("#get-in-touch strong").replaceWith('<strong class="error">Check your email</strong>');
					$("#get-in-touch em").replaceWith('<em class="error">Must be formatted correctly (name@domain.com)</em>');
					$("#get-in-touch div").fadeIn('slow');
				});
				verdict = false;
			} else if (phone == '' || phone == 'Phone: ') {
				$("#get-in-touch div").fadeOut('slow', function() {
					$("#get-in-touch strong").replaceWith('<strong class="error">Phone is required.</strong>');
					$("#get-in-touch em").replaceWith('<em class="error">Must be a valid phone number</em>');
					$("#get-in-touch div").fadeIn('slow');
				});

				verdict = false;
			} else if (!phoneReg.test(phone)) {
				$("#get-in-touch div").fadeOut('slow', function() {
					$("#get-in-touch strong").replaceWith('<strong class="error">Check your phone number</strong>');
					$("#get-in-touch em").replaceWith('<em class="error">Must be a valid phone number</em>');
					$("#get-in-touch div").fadeIn('slow');
				});
				verdict = false;
			}
		
			return verdict;
		});
	}
	
});