/* javascript function to update form field
 *  field		form field that is being counted
 *  count		form field that will show characters left
 *  maxchars 	maximum number of characters
*/
function characterCount(field, count, maxchars) {
	if (field.value.length > maxchars) {
		field.value = field.value.substring(0, maxchars);
		alert("Error:\n\n- You are only allowed to enter up to "+maxchars+" characters.");
	} else {
		count.value = maxchars - field.value.length;
	}
}


$(document).ready(function() {

	$('#allPhotoBox a').click(function() {
		return littleImageClick($(this));
	})
		
	$('#infoListBox > ul').tabs();
	
	$('#principalPhotoBox a').click(function() {
		$('#allPhotoBox a').lightbox();
		$('#allPhotoBox a[rel="'+$('#principalPhotoBox img').attr('src')+'"]').click();
		
		var elem = $('#allPhotoBox').clone();
		$('#allPhotoBox').replaceWith($(elem));
		$('#allPhotoBox a').click(function() {
			return littleImageClick($(this));
		})
		return false;
	})
	
	function littleImageClick(aElem)
	{
		$('#principalPhotoBox img.glowne').attr('src',$(aElem).attr('rel'));
		$('#principalPhotoBox a').attr('href',$(aElem).attr('href'));
		return false;
	}
	
	$('.tooltip_desc').each(function() {
		$(this).simpletip({
			content: $(this).find('.tooltip_text').text(),
			position: 'right',
			offset: [5,0]
		});
	});
	
});

