var duration = 5000
var slide = null
var is_slideshow = false

function slideshow_on()
{
	$(".sended").hide().text("")

	$(".thumbs a:first").click()
	slide = window.setInterval(function() {
		is_slideshow = true
		if ($('#TB_next').length) $('#TB_next').click()
		else tb_remove()
	}, duration)
}

function slideshow_off()
{
	window.clearInterval(slide)
	slide = null
}


function onprint()
{
	tb_remove()
	window.open("/pages/50?gallery=" + $.jget["gallery"] + "&photo=" + $(".thumbs div.active a:eq(0)").attr("photo_id"), 'print', 'width=800,height=600,resizeble=1,statusbar=0')
	return false
}

function onsendtofriend()
{
	tb_remove()
	$('.send_friend form input[name=gallery]').val($.jget["gallery"])
	$('.send_friend form input[name=photo]').val($(".thumbs div.active a:eq(0)").attr("photo_id"))
	$(".send_friend").show()
	return false
}

function submit_to_friend(obj)
{
	var flag = true;
	$('.send_friend form input[type!=submit]').each(function(i, obj) {
		$(obj).css("borderColor", "#5D6570")
		if (!$(obj).val())
		{
			flag = false;
			$(obj).css("borderColor", "#CD7706")
		}
	})

	if (flag)
	{
		$.ajax({
			url: $(obj).attr('action'),
			type: $(obj).attr('method'),
			type: "post",
			dataType: "json",
			data: $('.send_friend form input[type!=submit]').serialize(),
			cache: false,
			success: function(data) {
				$(".sended").show().text(data.text)
				if (data.status) hide_send_form()
			}
		})
	}

	return false
}

function hide_send_form()
{
	$(".send_friend").hide()
	$(".send_friend input[type!=submit]").each(function(i, obj) { $(obj).val("") })
}

