createMailto = function(pers, domain, customText) {
	var email = pers + '@' + domain;
	(customText == null) ? lnk = email : lnk = customText;
	document.write('<a href="mailto:'+email+'">'+lnk+'</a>');
}

// portfolio logic
Portfolio = {}
Portfolio.image = 1;
Portfolio.timeoutId = 1;
Portfolio.width;
Portfolio.border;
Portfolio.intervalId;
Portfolio.numberOfImages = 1;
Portfolio.isScrolling = 0;

Portfolio.init = function() {
	document.getElementById('wrapper').style.left = 0;
	this.numberOfImages = document.getElementById('wrapper').getElementsByTagName('IMG').length;
	this.width = this.numberOfImages * 104- 4;
	this.border = 696 - this.width;
	if (this.border > 0) this.border = 0;
	document.getElementById('info').innerHTML = this.image + ' / ' + this.numberOfImages;
	this.show(document.getElementById('wrapper').getElementsByTagName('IMG')[0])
}

Portfolio.expand = function() {
	if (this.image) {
		var w = 500;
		var h = 500;
		var x = parseInt(screen.width / 2) - parseInt(w/2);
		var y = parseInt(screen.height / 2) - parseInt(h/2);
		var features = 'toolbar=0,location=0,menubar=0,toolbar=0,scrollbars=0,status=0,width=' + w + ',height=' + h + ',top=' + y + ',left=' + x + ',screenY=' + y + ',screenX=' + x;
		var w = window.open('/photo.asp?img=' + this.directory + '/large/' + this.image + '.jpg', 'photo', features);
		if (w.focus) w.focus();
		return w;
	}
}

Portfolio.scrollLeft = function() {
	clearInterval(this.intervalId);
	var x = parseInt(document.getElementById('wrapper').style.left, 10);
	this.intervalId = setInterval(function() {
		x -= 2;
		if (x <= Portfolio.border) { x = Portfolio.border; Portfolio.stopScroll(); }
		document.getElementById('wrapper').style.left = x + 'px';
	}, 5);
}

Portfolio.scrollRight = function() {
	clearInterval(this.intervalId);
	var x = parseInt(document.getElementById('wrapper').style.left, 10);
	this.intervalId = setInterval(function() {
		x += 2;
		if (x > 0) { x = 0; Portfolio.stopScroll(); }
		document.getElementById('wrapper').style.left = x + 'px';
	}, 5);
}

Portfolio.stopScroll = function() {
	this.isScrolling = false;
	clearInterval(this.intervalId);
}

Portfolio.show = function(img) {
	var imageList = img.parentNode;
	var thumbnails = imageList.getElementsByTagName('IMG');
	for (var i=0; i<thumbnails.length; i++) {
		if (thumbnails[i] == img) {
			this.cnt = i + 1;
			this.src = thumbnails[i].src;
			this.image = this.src.substring(this.src.lastIndexOf('/') + 1, this.src.lastIndexOf('.'));
		}
	}
	document.getElementById('photo').src = this.image + '.gif';
	document.getElementById('info').innerHTML = this.cnt + ' / ' + this.numberOfImages;
}

Portfolio.toggleScrollLeft = function() {
	if (this.isScrolling) {
	 	this.stopScroll();
	} else {
		this.isScrolling = true;
		this.scrollLeft();
	}
}

Portfolio.toggleScrollRight = function() {
	if (this.isScrolling) {
	 	this.stopScroll();
	} else {
		this.isScrolling = true;
		this.scrollRight();
	}
}

// images
function showImage(imgSrc) {
	var w = 500;
	var h = 500;
	var x = parseInt(screen.width / 2) - parseInt(w/2);
	var y = parseInt(screen.height / 2) - parseInt(h/2);
	var features = 'toolbar=0,location=0,menubar=0,toolbar=0,scrollbars=0,status=0,width=' + w + ',height=' + h + ',top=' + y + ',left=' + x + ',screenY=' + y + ',screenX=' + x;
	var w = window.open('/photo.asp?img=' + imgSrc, 'photo', features);
	if (w.focus) w.focus();
	return false;
}



initPhotos = function() {
	$('a.enlarge').each(function(e) {
		src = $(this).attr('href'); 
		$(this).bind("click", function(e) {
			return showImage(src);
		});							  
	});
}


$(document).ready(function() {
	initPhotos();
});
