$(document).ready(function(){
	$('a.lightbox').lightBox({
		imageLoading: '/gfx_www/lb-loading.gif',
		imageBtnClose: '/gfx_www/lb-close.gif',
		imageBtnPrev: '/gfx_www/lb-p.gif',
		imageBtnNext: '/gfx_www/lb-n.gif',
		txtImage: '',
		txtOf: '/'
	});

	$('.radio').click(function(){
		$('.radio').removeClass('radio-on');
		$(this).addClass('radio-on');

		var id = $('#'+$(this).attr('id')+' input').val();

		showSpotlight(id);
	});

	$('.spotlight').mouseover(function(){
		stopSpotlight();
	});
	$('.spotlight').mouseout(function(){
		startSpotlight();
	});

	$('.def').each(function(){
		var txt = $(this).attr('title');

		if(txt != undefined && txt != ''){
			$(this).html(txt);
			$(this).val(txt);
		}
		else{
			$(this).removeClass('def');
		}
	});
	$('.def').focus(function(){
		var txt = $(this).attr('title');

		if($(this).html() == txt || $(this).val() == txt){
			$(this).html('');
			$(this).val('');
			$(this).removeClass('def');
		}
	});
	$('.def').blur(function(){
		var txt = $(this).attr('title');

		if(($(this).html == undefined || $(this).html() == '') && ($(this).val() == undefined || $(this).val() == '')){
			$(this).html(txt);
			$(this).val(txt);

			$(this).addClass('def');
		}
	});
});

function showSpotlight(id){
	id = '#spotlight'+id;

	if(!$(id).is(':visible')){
		$('.spotlight').slideUp();

		$(id).slideDown();
	}
}
function startSpotlight(){
	if(IntValue($('#total-spotlights').val()) > 1){
		var time = IntValue($('#spotlight-time').val());

		if(time < 1 || !time){
			time = 1;
		}

		int_id = setInterval('changeSpotlight()', time*1000);

		$('#spotlight-interval-id').val(int_id);
	}
}
function stopSpotlight(){
	int_id = $('#spotlight-interval-id').val();

	clearInterval(int_id);
}
function changeSpotlight(){
	var next = $('#last-spotlight').val();
	next = IntValue(next)+1;

	var total = $('#total-spotlights').val();
	total = IntValue(total);

	if(next > total){
		next = 1;
	}

	$('.radio').removeClass('radio-on');
	$('#radio'+next).addClass('radio-on');

	$('#last-spotlight').val(next);

	showSpotlight(next);
}
