﻿function imtl() {
    var at = '@';
    var e = 'mariasullivan2003' + at + 'yahoo.co.uk';
    document.write('<a href="mailto:' + e + '">' + e + '</a>');
}

var $i;

function showImg(u) {
    if (u == null || u == '')  u = $i.attr('src');
    $i.attr('src', u).stop(true, true).hide().fadeIn('slow');
}

function doClick(t) {
    showImg(t.attr('showimg'));
    $('a').removeClass('sel');
    t.addClass('sel');
    makeCaption(t.attr('alt'));
}

$(document).ready(function () {
	if (navigator.appName == 'Microsoft Internet Explorer') {
		$('#NavBar > a').addClass('IEtweak');
		$('#NavBar > b').addClass('IEtweak');
	}
    $i = $('#MainImage > img');

    var ilinks = $('*[showimg]');
    if (ilinks.length > 0) {
        ilinks.click(function () {doClick($(this));});
        doClick(ilinks.first());
    } else showImg('');
});

function makeCaption(t) {
    if (t.indexOf('http://') == 0) {
        $i.wrap($('<a>').attr({
            href: t,
            target: '_blank',
            title: t
        }));
        t = '<a href="' + t + '" target="_blank">Visit website</a>';
    } else {
        if ($i.parent('a').length>0) $i.unwrap();
        if (t.indexOf('|') > 0) {
            var x = t.split('|');
            t = '<span class="halfCap"><b>Title:</b> ' + x[0] + '</span><b>Client:</b> ' + x[1];
        }
    }
    $('#Caption').html(t);
}
