// JavaScript Document


$(function() {
	
	// Make external links open in a window
	$('a[href^=http]').click( function() {
		if (this.href.toLowerCase().indexOf("mailright.co.uk") < 1 && this.href.toLowerCase().indexOf("mail-right.com") < 1) {
        	window.open(this.href);
        	return false;
		}
    });
	
	// Call lightbox on these elements
	$('ul.list-seemore li a, #portfolio ul li a, ul#free-templates li a').lightBox();
	
	// Add a newsletter archive link to the footer nav, for JS enabled devices (as the page requires JS)
	$('.footer ul').append('<li><a href="/email-marketing-newsletter/">Newsletter archive</a></li>');
	
	// Convert phone numbers to links, for iPhone, as the default funcionality's been turned off
	
	function isiPhone(){
		return (
			(navigator.platform.indexOf("iPhone") != -1) ||
			(navigator.platform.indexOf("iPod") != -1) ||
			(navigator.platform.indexOf("iPad") != -1)
		);
	}
	
	if (isiPhone()) {
		$('span.tel').wrap(function() {
  		return '<a href="tel:' + $(this).text() + '" />';
		});
	};
});
