			function decision(message, url)
			{
				if(confirm(message)) location.href = url;
			}
			
			function decision2(message, url)
			{
				if(confirm(message)) location.href = url + '&rid=' + document.getElementById('rjecnik_add').value
			}
			
			function decision_form(message)
			{
				if(confirm(message))  document.new_word.submit();
			}
			
			function decision_form_user(message)
			{
				if ($("#prov_user_result").html() == "OK")
				{
					if(confirm(message))  document.new_word.submit();
				}
				else
				{
					alert("Provjerite polja!");
				}
			}
			
			
			function check_word(data)
			{
				var back_data;
				$.post("ajax_result.php", { 'word_check': data },  function(back_data){ if (back_data > 0) alert("Unesena riječ već se nalazi u bazi!")});
			}

			
			function print_r(theObj){
			  if(theObj.constructor == Array ||
				 theObj.constructor == Object){
				document.write("<ul>")
				for(var p in theObj){
				  if(theObj[p].constructor == Array||
					 theObj[p].constructor == Object){
			document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
					document.write("<ul>")
					print_r(theObj[p]);
					document.write("</ul>")
				  } else {
			document.write("<li>["+p+"] => "+theObj[p]+"</li>");
				  }
				}
				document.write("</ul>")
			  }
			}

			
			$(document).ready(function() 
			{ 
			
				var tmp_alo;
				var tmp_user_ex = false;
			
				/*
				$(document).bind('keydown', 'Ctrl+E', function()
				{
					 alert("aa");
					 return true;
				});
				*/
					
				$(".tooltipbox").tooltip({ 
					track: true, 
					delay: 0, 
					showURL: false, 
					opacity: 1, 
					fixPNG: true, 
					showBody: " - ", 
					extraClass: "pretty fancy", 
					top: -40, 
					left: 10 
				});
					
				$("#def_premission").change(function(){
					if (this.value == 1)
					{
						$("#ch_perm_4").attr("checked", true);
						$("#ch_perm_6").attr("checked", true);
						$("#ch_perm_8").attr("checked", true);
					}
					else
					{
						$("#ch_perm_4").attr("checked", false);
						$("#ch_perm_6").attr("checked", false);
						$("#ch_perm_8").attr("checked", false);
					}
				});
				
				$("#rjecnik_add").change(function(){
					if (this.value == 'new')
					{
						$("#new_rjecnik").show();
					}
					else
					{
						$("#new_rjecnik").hide();
					}
				});
				
				$("#prov_user").keyup(function(){
					$("#prov_user_result").load("ajax_result.php", { 'user_check': this.value });
				});
				
				$(".user_perm_ch").click(function(){
					$.post("ajax_save.php", { 'value': this.checked, 'id': this.id });
				});
				
				$("#add_new_suggest").keyup(function()
				{
					if (this.value != tmp_alo)
					{
						tmp_alo = this.value;
						check_word(this.value);
					}
				});
			
				var options = { 
			        target:    '#result',   // target element(s) to be updated with server response 
			        url:       'ajax_result.php',
			        type:      'POST'
			    }; 
			 
				$("#loading").ajaxStart(function(){
					$(this).show();
				})
				.ajaxComplete(function(){
					$(this).hide();
				});
			 
				$('#lexis_form').submit(function() { 
			        $(this).ajaxSubmit(options); 
			        return false; 
			    }); 
				
				$('#add_new_word_icon').click(function(){
					$('#add_new_word').css("display", "block");
				});
				
				$('#lexis_csv_upload').submit(function() {
					$.ajaxFileUpload({
							url:'ajax_csv.php?id=' + $('#rjecnik_add').val() + '&' + $('#new_rjecnik').val(),
							secureuri: false,
							fileElementId:'filepc',
							dataType: 'json',
							success: function (data, status)
							{
								if(data.error != '')
								{
									$('#result_upl').html(data.error);
								}
								else
								{
									$('#result_upl').html(data.msg);
								}
							},
							error: function (data, status, e)
							{
								alert(e);
							}
						});
					
					return false;
				});
			 
			
				 $(".edit_area").editable("ajax_save.php", 
				 { 
					 type      : 'text',
					 cancel    : '<button type="cancel" class="button_cancel">x</button>',
					 submit    : '<button type="submit" class="button_submit">save</button>',
					 indicator : "<img src='imgs/ajax_load.gif' alt='' />",
					 tooltip   : 'Click to edit...',
					 placeholder : '<i>nema komentara</i>',
					 width	   : '500px',
					 onblur    : 'ignore',
					 style     : "display: inline" 
				 });
			 
				$(".edit_area_select").editable("ajax_save.php", 
				 { 
					 type      : 'select',
					 data	   :  popis,	
					 cancel    : '<button type="cancel" class="button_cancel">x</button>',
					 submit    : '<button type="submit" class="button_submit">save</button>',
					 indicator : "<img src='imgs/ajax_load.gif' alt='' />",
					 tooltip   : 'Click to edit...',
					 width	   : '80px',
					 onblur    : 'ignore',
					 style     : "display: inline"
				 });
			 
				$(".edit_area_txt").editable("ajax_save.php", 
				 { 
					 type      : 'textarea',
					 cancel    : '<button type="cancel" class="button_cancel">x</button>',
					 submit    : '<button type="submit" class="button_submit">save</button>',
					 indicator : "<img src='imgs/ajax_load.gif' alt='' />",
					 tooltip   : 'Click to edit...',
					 placeholder : '<i>nema komentara</i>',
					 width	   : '700px',
					 onblur    : 'ignore',
					 height	   : '80px',
					 onblur    : 'ignore'
				 });
				 
				$("#button_hlp").click(function(){
					$("#help_text").fadeIn(500);
					$("#button_hlp").hide();
					$("#button_hlp_hide").show();
					return false;
				 });
				 
				 $("#button_hlp_hide").click(function(){
					$("#help_text").fadeOut(500);
					$("#button_hlp_hide").hide();
					$("#button_hlp").show();
					return false;
				 });
				 
				 $("#button_find").click(function(){
					$("#button_find").fadeOut();
					$("#word_finder").fadeIn(500);
					return false;
				 });
				 
				 $("#button_add_new").click(function(){
					$("#button_add_new").fadeOut();
					$("#add_new_word_a").fadeIn(500);
					return false;
				 });

				$.editable.addInputType("password", {
				    element : function(settings, original) {
				        var input = $('<input type="password" />');  
						input.val("");
				        $(this).append(input);
				        return(input);
				    },
					content : function(string, settings, original) {
				        var input = $(':input:first', this);
				        $(input).val("");
				    }

				});

				$(".edit_pass_1").editable("ajax_save.php", 
				 { 
					 type      : 'password',
					 cancel    : 'a',
					 submit    : 'a',
					 indicator : "<img src='imgs/ajax_load.gif' alt='' />",
					 tooltip   : 'Click to edit...',
					 width	   : '80px',
					 style     : "display: inline"
					 //callback  : (function(data){$.jGrowl(data, { life: 2000 });})
				 });
				 
				 $(".edit_pass").editable("ajax_save.php", 
				 { 
					 type      : 'password',
					 cancel    : 'a',
					 submit    : 'a',
					 indicator : "<img src='imgs/ajax_load.gif' alt='' />",
					 tooltip   : 'Click to edit...',
					 width	   : '80px',
					 style     : "display: inline"
					 //callback  : (function(data){$.jGrowl(data, { life: 2000 });})
				 });

			});
