$(document).ready( function() {

	$("#nextFoto").click( function() {
		showPreviev( $(this).attr("rel"), $(this).attr("href") );
		return false;
	});
	
	$("#prevFoto").click( function() {
		showPreviev( $(this).attr("rel"), $(this).attr("href") );
		return false;
	});
	
	$("#nl_email").focus( function() {
		if ( $(this).val() == $(this).attr("title") ) {
			$(this).val("")
		}
	}).blur( function() {
		if ( $(this).val() == '' ) {
			$(this).val( $(this).attr("title") );
		}
	});
	
});

function showPreviev( gal,cur ) {
	var prev = parseInt(cur)-1;
	var next = parseInt(cur)+1;
	
	if ( fotki[gal][cur] != '' ) {
		$("#foto_"+gal+" img").attr( 'src', $("#thumb_"+fotki[gal][cur]).attr("src").replace(/thumb2_/, "") );
	}
	$("#nextFoto").attr("href",next);
	$("#prevFoto").attr("href",prev);
	
	if ( typeof fotki[gal][next] == 'undefined' ) {
		$("#nextFoto").hide();
	} else {
		$("#nextFoto").show();
	}
	if ( typeof fotki[gal][prev] == 'undefined' ) {
		$("#prevFoto").hide();
	} else {
		$("#prevFoto").show();
	}
	return false;
}

$.fn.equalHeights = function(px) {
	var currentTallest = 0;
	$(this).each(function() {
		var currentHeight = $(this).height();
		if ( currentHeight > currentTallest) {
			currentTallest = currentHeight;
		}
	});
	currentTallest += 'px';
	// for ie6, set height since min-height isn't supported
	if ($.browser.msie && $.browser.version == 6.0) {
		$(this).css({'height': currentTallest});
	}
	$(this).css({'min-height': currentTallest}); 
	
	return this;
};
