// JavaScript Document

// initialise plugins
$(document).ready(function() { 
       $('ul.sf-menu').superfish(); 
	   $(".colorbox").colorbox({rel:'group1', title:'Close Window&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'});
	   $(".colorbox_video").colorbox({iframe:true, width:685, height:545});
	   
	   $(".eml").defuscate();
}); 

function validateRequest() {

		var fields = 'Name|name,Company|company,Address|address,City|city,State|state,Country|country,Zip|zip,Phone|phone,Fax|fax,Email|email'.split(',');
		var message = '';	
		for(var i = 0; i <= fields.length - 1; i++) {
		
			var data = fields[i].split('|');
			if ($('#' + data[1]).val() == '') {
				message += data[0] + '\n';
			}
		}
		
		if (message != '') {
			
			alert('The following fields cannot be blank\n\n' + message);
			return false;
			
		}
}

jQuery.fn.defuscate = function( settings ) {
    settings = jQuery.extend({
        link: true
    }, settings);
    var regex = /\b([A-Z0-9._%-]+)\([^)]+\)((?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b/gi;
    return this.each(function() {
        if ( $(this).is('a[@href]') ) {
            // If it's an <a> element, defuscate the href attribute
            $(this).attr('href', $(this).attr('href').replace(regex, '$1@$2'));
            // Make sure that the element's contents is not made into a link
            var is_link = true;
            //alert($(this).attr('href'));
        }
        // Defuscate the element's contents
        $(this).html($(this).html().replace(regex, (settings.link && !is_link ? '<a href="mailto:$1@$2">$1@$2</a>' : '$1@$2')));
  });
}
