function confirm_delete(action_name) {
	return confirm("Akcija\n\n\t" + action_name + "\n\nbo zbrisana!\n\nAli ste prepricani?");
}

function set_category(indx, category) {
	
	var kategorija;
	var inputObj = document.getElementById('KATEGORIJA');
	
	for (i=0; i<4; i++) {
		if (indx == i) {
			document.getElementById('kat'+i).style.backgroundColor = 'white';
			document.getElementById('kat'+i).style.color = '#3398cc';
		} else {
			document.getElementById('kat'+i).style.backgroundColor = '#3398cc';
			document.getElementById('kat'+i).style.color = 'white';
		}
	}
	
	inputObj.value = category;
	
}

function add_tag(obj) {
	$('#tag').val(obj.innerHTML);
}

function check_action() {
	var error = false;
	
	if ($('#naziv_akcije').val() == '') {
		error = true;
		$('#naziv_akcije').css({backgroundColor: '#ffcaca'});
	}
	
	if ($('#opis_akcije').val() == '') {
		error = true;
		$('#opis_akcije').css({backgroundColor: '#ffcaca'});
	}
	
	if ($('#KATEGORIJA').val() == '') {
		error = true;
		$('#kategorija_title').css({ color: '#f00'});
	}
	
	if (error) {
		return false;
	} else {
		return true;
	}
}

function check_poll() {
	var frm = $('#frm_poll')[0];
	var valid = false;

	for(i = 0; i<frm.POLL_VOTE.length; i++) {
		if (frm.POLL_VOTE[i].checked) valid = true;
	}
	
	if (!valid) {
		alert('Označite odgovor!');
	}
	
	return valid;
	
}

function check_action_vote() {
	
	var frm = $('#action_vote')[0];
	
	var valid1 = false;
	var valid2 = false;
	var valid = false;
	
	for(i=0; i<frm.zanimivo.length; i++) {
		if (frm.zanimivo[i].checked) {
			valid1 = true;
			break;
		}
	}
	
	for(i=0; i<frm.lepo.length; i++) {
		if (frm.lepo[i].checked) {
			valid2 = true;
			break;
		}
	}
	
	valid = (valid1 && valid2) ? true : false;
	
	if ($('#tag').val() == '' || $('#tag').val() == 'Oznaka')
		valid = false;
	if (!valid) alert('Definirani morajo biti vsi podatki!');
	return valid;
}

function open_instructions(uri) {
	
	if (typeof($('#jds_overlay')[0]) == 'undefined') {
		
		var overlay  = '<div id="jds_overlay"></div>';
		$("body").append(overlay);
		
		// applying style
		$("#jds_overlay").css({
			opacity: 0.7
		});
		
		$("#jds_overlay").css({ height:$(document).height() });
		
		$("#jds_overlay").bind('click', function() {
			$('#jds_frame, #jds_overlay, #jds_close').fadeOut('fast', function() {
				$(window).unbind('scroll', instructions_position);
			})
		});
	}
	
	
	
	if (typeof($('#jds_frame')[0]) == 'undefined') {
			var jds_frame = '<iframe id="jds_frame" src="" width="582" height="580" frameborder="0" marginheight="0" marginwidth="0" scrolling="auto"></iframe>';
			$("body").append(jds_frame);
			
			var frame_left = ($(document).width()/2) - (580/2);
			var frame_top = $(document).scrollTop() + Math.round(($(window).height() - 580)/2);
			
			$('#jds_frame').css({
				position: 'absolute',
				left: frame_left,
				top: frame_top
			});
			
			if (typeof($('#jds_close')[0]) == 'undefined') {
				$("body").append('<div id="jds_close"><a href="#"></a></div>');
				
				$('#jds_close').css({
					position: 'absolute',
					left: frame_left + 564,
					top: frame_top - 19,
					zIndex: 110
				});
				
				$("#jds_close").bind('click', function() {
					$('#jds_frame, #jds_overlay, #jds_close').fadeOut('fast', function() {
						$(window).unbind('scroll', instructions_position);
					})
				});
			}
			
			
	}
	
	// opening sequence
	$("#jds_overlay").fadeIn('normal', function() {
			$('#jds_frame')[0].src=uri;
			$('#jds_frame, #jds_close').fadeIn('normal');
			// IE 7 hack
			// Ce ni IE6, pozicioniraj
			if (typeof document.body.style.maxHeight != "undefined") {
				$('#jds_frame').css({ position: 'fixed' });
				$('#jds_close').css({ position: 'fixed' });
			} else {
				$(window).bind('scroll', instructions_position);
			}
	});
}

function instructions_position() {
	
	var frame_left = ($(document).width()/2) - (580/2);
	var frame_top = $(document).scrollTop() + Math.round(($(window).height() - 580)/2);
	
	$('#jds_frame').css({
		position: 'absolute',
		left: frame_left,
		top: frame_top,
		zIndex: 100
	});
}


$(document).ready( function(){

	$('#gallery img').click(function() {
		var thumb = this.src.replace('/min_', '/th_');
		var index = $("#gallery img").index(this);
		$('#photo').attr('rel', index+1);
		$('#photo img').attr('src', thumb);
		return false;
	});

} );