// "Loading..." text
$(document).ready(function() {
	$('div#loading').fadeOut("slow");
});

tinyMCE.init({
	// General options
	language : "sl",
	elements : "simple",
	mode : "textareas",
	editor_selector : "simple",
	theme : "advanced",
	plugins : "safari,advlink,emotions,insertdatetime,contextmenu,xhtmlxtras",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,|,link,unlink,|,forecolor,backcolor,|,sub,sup,|,charmap,emotions",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false
});

tinyMCE.init({
	// General options
	language : "sl",
	elements : "advanced",
	mode : "textareas",
	editor_selector : "advanced",
	theme : "advanced",
	plugins : "safari,pagebreak,layer,table,advhr,advimage,advlink,emotions,inlinepopups,insertdatetime,media,contextmenu,paste,directionality,fullscreen,visualchars,nonbreaking,xhtmlxtras",

	// Theme options
	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,fontselect,fontsizeselectcut,copy,paste,pastetext,pasteword,bullist,numlist,|,outdent,indent,blockquote",
	theme_advanced_buttons2 : "fullscreen,|,link,unlink,image,insertdate,inserttime,preview,|,forecolor,backcolor,|,tablecontrols,|,hr,removeformat,visualaid",
	theme_advanced_buttons3 : "undo,redo,|,sub,sup,|,charmap,emotions,media,advhr,|,ltr,rtl,|,insertlayer,moveforward,movebackward,absolute,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : true
});



function prikaziDodatnaPoljaClanstvo()
{
	try {
		var dropdown = document.getElementById("user_group");
	    var index = dropdown.selectedIndex;
	    var ddVal = dropdown.options[index].value;
	} catch (err) {
		$("div#dodatnaPoljaClanstvo").show();
	}

	if (ddVal == 0 || ddVal == 5)
	{
    	$("div#dodatnaPoljaClanstvo").hide();
    }
    else
    {
    	$("div#dodatnaPoljaClanstvo").show();
    }
}







function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotator ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	
	setInterval('rotate()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.rotator ul li:first');

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));
	
	//Un-comment the 3 lines below to get the images in random order
	
	//var sibs = current.siblings();
    //var rndNum = Math.floor(Math.random() * sibs.length );
    //var next = $( sibs[ rndNum ] );
			

	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};



$(document).ready(function() {		
	//Load the slideshow
	theRotator();
	$('div.rotator').fadeIn(1000);
    $('div.rotator ul li').fadeIn(1000); // tweek for IE
});
