// adDict: dictionary jQuery plugin
(function($){$.fn.adDict=function(dictionary,options){var defaults={url_prefix:'http://'+document.domain+'/dictionary/',reg_prefix:'__ -- __',reg_sufix:'-- __ --',url_class:'adDict'};var options=$.extend(defaults,options);for(var i in dictionary)dictionary[i][3]=new RegExp('('+dictionary[i][0].replace(/([.*+?^${}()|[\]\/\\])/g,'\\$1')+')','gi');this.traverse=function(node){if(node.nodeType==3&&node.parentNode.nodeName!='A')for(var i in dictionary)node.nodeValue=node.nodeValue.replace(dictionary[i][3],options.reg_prefix+'$1'+options.reg_sufix);if(node.childNodes!=null)for(var i=0;i<node.childNodes.length;i++)this.traverse(node.childNodes.item(i));};if(this[0]!==undefined){var temp=this.clone();this.traverse(temp[0]);temp=temp.html();for(var i in dictionary)temp=temp.replace(new RegExp(options.reg_prefix+'('+dictionary[i][0]+')'+options.reg_sufix,'gi'),'<a class="'+options.url_class+'" href="'+options.url_prefix+dictionary[i][1]+'">$1</a>');this.html(temp);}};})(jQuery);


/* 
 * Auto Expanding Text Area (1.2.2)
 * by Chrys Bader (www.chrysbader.com)
 * chrysb@gmail.com
 *
 * Copyright (c) 2008 Chrys Bader (www.chrysbader.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 */

(function(jQuery){var self=null;jQuery.fn.autogrow=function(o)
{return this.each(function(){new jQuery.autogrow(this,o);});};jQuery.autogrow=function(e,o)
{this.options=o||{};this.dummy=null;this.interval=null;this.line_height=this.options.lineHeight||parseInt(jQuery(e).css('line-height'));this.min_height=this.options.minHeight||parseInt(jQuery(e).css('min-height'));this.max_height=this.options.maxHeight||parseInt(jQuery(e).css('max-height'));;this.textarea=jQuery(e);if(this.line_height==NaN)
{this.line_height=0;}
if(this.min_height==NaN||this.min_height==0)
{this.min_height==this.textarea.height();}
this.init();};jQuery.autogrow.fn=jQuery.autogrow.prototype={autogrow:'1.2.2'};jQuery.autogrow.fn.extend=jQuery.autogrow.extend=jQuery.extend;jQuery.autogrow.fn.extend({init:function(){var self=this;this.textarea.css({overflow:'hidden',display:'block'});this.textarea.bind('focus',function(){self.startExpand()}).bind('blur',function(){self.stopExpand()});this.checkExpand();},startExpand:function(){var self=this;this.interval=window.setInterval(function(){self.checkExpand()},400);},stopExpand:function(){clearInterval(this.interval);},checkExpand:function(){if(this.dummy==null)
{this.dummy=jQuery('<div></div>');this.dummy.css({'font-size':this.textarea.css('font-size'),'font-family':this.textarea.css('font-family'),'width':this.textarea.css('width'),'padding':this.textarea.css('padding'),'line-height':this.line_height+'px','overflow-x':'hidden','position':'absolute','top':0,'left':-9999}).appendTo('body');}
var html=this.textarea.val().replace(/(<|>)/g,'');if($.browser.msie)
{html=html.replace(/\n/g,'<BR>new');}
else
{html=html.replace(/\n/g,'<br>new');}
if(this.dummy.html()!=html)
{this.dummy.html(html);if(this.max_height>0&&(this.dummy.height()+this.line_height>this.max_height))
{this.textarea.css('overflow-y','auto');}
else
{this.textarea.css('overflow-y','hidden');if(this.textarea.height()<this.dummy.height()+this.line_height||(this.dummy.height()<this.textarea.height()))
{this.textarea.animate({height:(this.dummy.height()+this.line_height)+'px'},100);}}}}});})(jQuery);


$(function(){
	var base='http://'+document.domain+'/';
	var enc=encodeURIComponent||escape;
	
	// Add dictionary to text
	$('div.adDict').adDict(dictionary,{url_prefix:base+'rjecnik-pojmova/'});
	
	// Click tracker
	$('a').mousedown(function(){(new Image).src=base+'brojac/statistika-linkova/'+enc(this.href)});
	
	// Autogrow textareas
	$('#content .form textarea').autogrow();
});


// Additional menu

$('#pro_menu')
	.live('mouseover',function(){$('.tab',this).stop().addClass('active').siblings().show();return false})
	.live('mouseout',function(){$('.tab',this).stop().animate({dummy:1},500,null,function(){$(this).removeClass('active').siblings().hide();});return false});

// Datepicker additional functionality
$('.selected_date').live('click',function(event){var a=$('#tooltip .content a:last').attr('href');if(a.length>0)location.href=a});