function removeFbConnNote(el) 
{
	Cookie.init({name: 'removeFbConnNote', expires: 90});
	Cookie.setData('Y', false);
	$(el).up('div.ui-widget').remove();
}
var Cookie = {
		  data: {},
		  options: {expires: 1, domain: "", path: "", secure: false},

		init: function(options, data) {
		  Cookie.options = Object.extend(Cookie.options, options || {});

		  var payload = Cookie.retrieve();
		        if(payload) {
		            Cookie.data = payload.evalJSON();
		        }
		        else {
		            Cookie.data = data || {};
		        }
		        Cookie.store();
		    },
		    getData: function(key) {
		        return Cookie.data[key];
		    },
		    setData: function(key, value) {
		        Cookie.data[key] = value;
		        Cookie.store();
		    },
		    removeData: function(key) {
		        delete Cookie.data[key];
		        Cookie.store();
		    },
		    retrieve: function() {
		        var start = document.cookie.indexOf(Cookie.options.name + "=");

		        if(start == -1) {
		            return null;
		        }
		        if(Cookie.options.name != document.cookie.substr(start, Cookie.options.name.length)) {
		            return null;
		        }

		        var len = start + Cookie.options.name.length + 1;   
		        var end = document.cookie.indexOf(';', len);

		        if(end == -1) {
		            end = document.cookie.length;
		        } 
		        return unescape(document.cookie.substring(len, end));
		    },
		    store: function() {
		        var expires = '';

		        if (Cookie.options.expires) {
		            var today = new Date();
		            expires = Cookie.options.expires * 86400000;
		            expires = ';expires=' + new Date(today.getTime() + expires);
		        }

		        document.cookie = Cookie.options.name + '=' + escape(Object.toJSON(Cookie.data)) + Cookie.getOptions() + expires;
		    },
		    erase: function() {
		        document.cookie = Cookie.options.name + '=' + Cookie.getOptions() + ';expires=Thu, 01-Jan-1970 00:00:01 GMT';
		    },
		    getOptions: function() {
		        return (Cookie.options.path ? ';path=' + Cookie.options.path : '') + (Cookie.options.domain ? ';domain=' + Cookie.options.domain : '') + (Cookie.options.secure ? ';secure' : '');      
		    }
		};

function checkCapsLock( e ) {
	var myKeyCode=0;
	var myShiftKey=false;
	var myMsg='Caps Lock is On.\n\nTo prevent entering your password incorrectly,\nyou should press Caps Lock to turn it off.';

	// Internet Explorer 4+
	if ( document.all ) {
		myKeyCode=e.keyCode;
		myShiftKey=e.shiftKey;

	// Netscape 4
	} else if ( document.layers ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	// Netscape 6
	} else if ( document.getElementById ) {
		myKeyCode=e.which;
		myShiftKey=( myKeyCode == 16 ) ? true : false;

	}

	// Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
	if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
		alert( myMsg );

	// Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
	} else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
		alert( myMsg );

	}
}

function passwordField(){
	$$('input[type="password"]').each(function(element){
		var el = element;
		el.setAttribute('type', 'text');


		randId = randomString();
		toggleFieldType = new Element('input', { type: "checkbox", checked: true, id: randId });
		toggleFieldTypeLabel = new Element('label', { 'for': randId, checked: true, 'class': 'show-pass-lable', style: 'float:left;width:100px;' }).update('Prikažite lozinku');
		el.insert({
			after: toggleFieldType
		});
		toggleFieldType.insert({
			before: toggleFieldTypeLabel
		});
		toggleFieldTypeLabel.insert({
			before: '<div class="clear:both"></div>'
		});
		toggleFieldType.insert({
			after: '<div class="clear:both"></div>'
		});
		toggleFieldType.observe('click', function(event){
			if (this.checked) {
				el.setAttribute('type', 'text');
			} else {
				el.setAttribute('type', 'password');
			}
		});
		
	});
}

function dodajSastojak(el) {
	$(el).hide();;
	elm = $('prvi_sastojak');
	$('ostali_sastojci').insert({ bottom: elm.innerHTML });
	lks = $$('.dodaj_sastojak');
	lks[lks.length-1].show();
	
	arr = $$('#ostali_sastojci input[type="text"]');
	arr[arr.length-2].value = '';
	arr[arr.length-1].value = '';
	new Ajax.Autocompleter(lks[lks.length-1].up().previous().previous().previous().down('input'), "autocomplete_choices", "/callback/sastojci.php", {
	  paramName: "value", 
	  minChars: 1,
	  frequency: 0
	});

	$('ostali_sastojci').descendants().each(function(elm){
		if (elm.tagName=='LABEL') elm.remove();
	});
}
function brisanje_recepta(id) {
	if (confirm('Da li ste sigurni da želite da obrišete ovaj recept?')) {
		go('/account/brisanje_recepta.php?id='+id);
	}
}
function go(url) {
	location.href=url;
}
function reportSpam(receptid){	
	var randId = randomString();
	$('reportSpam').down('a').insert({
		bottom: '<img id="'+randId+'" src="/common/g/loader.gif">'
	});
	new Ajax.Request('/callback/reportSpam.php?receptid='+receptid, {
	  method: 'get',
	  onSuccess: function(t) {
	  	console.log($(randId));
	  	$(randId).hide();
		$('reportSpam').update('<span class="favadded">Hvala na prijavi!</span>');
	  }
	});
}
function addToFav(receptid){
	var randId = randomString();
	$('addtofav').insert({
		bottom: '<img id="'+randId+'" src="/common/g/loader.gif">'
	});
	new Ajax.Request('/callback/addtofav.php?receptid='+receptid, {
	  method: 'get',
	  onSuccess: function(t) {
		$('addtofav').update('<span class="favadded">Recept dodat u omiljene</span>');
	  }
	});
}
function randomString() {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 10;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}
function remfav(receptid){
	new Ajax.Request('/callback/remfav.php?receptid='+receptid, {
	  method: 'get',
	  onSuccess: function(t) {
		$('remfav').update('<span class="favadded">Recept uklonjen iz omiljenih</span>');
	  }
	});
}
var ExpandableTextarea = Class.create({

	initialize: function(tb) {
		tb = $( tb );
		
		this.textbox = { element: tb, defaultheight: tb.getHeight() }
		this.textbox.element.update = this.setTextboxHeight;
		this.createHiddenElement();
		this.setTextboxHeight(false);
		this.animate = (typeof Scriptaculous == 'undefined')?false:true;
		this.textbox.element.setStyle({'overflow': 'hidden'});
		Event.observe(this.textbox.element, 'keyup', this.handleKeyUp.bind(this));
		Event.observe(this.textbox.element, 'focus', this.setTextboxHeight.bind(this));
	},

	createHiddenElement: function() {
		this.hiddenelement = new Element('div').show();

		// How do I get rid of this mess?
		this.hiddenelement.setStyle({
			'paddingTop': this.textbox.element.getStyle('paddingTop'),
			'paddingRight': this.textbox.element.getStyle('paddingRight'),
			'paddingBottom': this.textbox.element.getStyle('paddingBottom'),
			'paddingLeft': this.textbox.element.getStyle('paddingLeft'),
			'fontSize': this.textbox.element.getStyle('font-size'),
			'fontFamily': this.textbox.element.getStyle('font-family'),
			'width': this.textbox.element.getStyle('width'),
			'line-height': this.textbox.element.getStyle('line-height'),
			'letter-spacing': this.textbox.element.getStyle('letter-spacing'),
			'display': 'block',
			'visibility': 'hidden',
			'position': 'absolute',
			'top': '0',
			'left': '0'
		});
		this.textbox.element.parentNode.appendChild(this.hiddenelement);
	},

	handleKeyUp: function() {
		this.setTextboxHeight(this.animate);
	},

	setTextboxHeight: function(animate) {
		currenttextheight = this.hiddenelement.update(this.textbox.element.value.replace(/\n/g, '<br />')).getHeight();
		goalheight = ((currenttextheight>this.textbox.defaultheight)?currenttextheight+40:this.textbox.defaultheight);

		if(animate)
			this.textbox.element.morph({ height: goalheight + 30 + 'px'}, { duration: 0.2 });
		else
			this.textbox.element.setStyle({ height: goalheight + 'px' });

	}

});

SlideShow = Class.create({
	initialize: function(e,a) {
	 this.el=$(e);
	 this.paused=0;
	 this.big=0;
	 this.big_type='lightview';
	 (this._oiu(a['fade']))?this.fade=1:this.fade=a['fade'];
	 (this._oiu(a['direction']))?this.direction=1:this.direction=a['direction'];
	 this.slide=0;
	 this.slides=a['slides'];
	 (this._oiu(a['prefix']))?this.prefix='':this.prefix=a['prefix'];
	 (this._oiu(a['suffix']))?this.suffix='':this.suffix=a['suffix'];
	 (this._oiu(a['delay']))?this.delay=3:this.delay=a['delay'];
	 (this._oiu(a['mousepause']))?this.mp=1:this.mp=a['mousepause'];
	 var pl=[];
	 for(var i=0;i<this.slides.length;i++){
	  pl[i]=new Image(1,1);
	  pl[i].src=this.prefix+this.slides[i]+this.suffix;
	 }
	 if(this.mp){
	  Event.observe(this.el,'mouseover',function(){this.pause();}.bind(this));
	  Event.observe(this.el,'mouseout',function(){this.unpause();}.bind(this));
	 }
	 if(!this._oiu(a['big_suffix'])||!this._oiu(a['big_prefix'])) {
	  this._oiu(a['big_suffix'])?this.big_suffix=this.suffix:this.big_suffix=a['big_suffix'];
	  this._oiu(a['big_prefix'])?this.big_prefix=this.prefix:this.big_prefix=a['big_prefix'];
	  this.big=1;
	  this.el.style['cursor']='pointer';
	 /* Event.observe(this.el,'click',function(){
	   var url=this.big_prefix+this.slides[this.slide]+this.big_suffix;
	   this._pi(url);
	  }.bind(this));*/
          var bpl=[];
          for(var i=0;i<this.slides.length;i++){
           bpl[i]=new Image(1,1);
           bpl[i].src=this.big_prefix+this.slides[i]+this.big_suffix;
          }
	 }
	},
	_oiu:function(x){return Object.isUndefined(x);},
	next: function(){
	 if(!this.paused){
	  this.slide++;
	  this._slide_check();
	  this._update();
	 }
	},
	prev: function(){
	 if(!this.paused){
	  this.slide--;
	  this._slide_check();
	  this._update();
	 }
	},
	_slide_check: function() {
	 if(this.direction) {
	  if(this.slide>=this.slides.length||this.slide<0){ this.slide=0; }
	 }
	 else {
	  if(this.slide<0||this.slide>=this.slides.length) { this.slide=this.slides.length-1; }
	 }
	},
	_update: function() {
	 if(this.fade) {

	  this.stop();
	  
	  new Effect.Fade(this.el,{afterFinish:function(){
	//	  console.log(Effect.Fade);
	   this.el.src=this.prefix+this.slides[this.slide]+this.suffix;

	   new Effect.Appear(this.el,{afterFinish:function(){}});
	   this.start();
	  }.bind(this)});

	 }
	 else {
	  this.el.src=this.prefix+this.slides[this.slide]+this.suffix;
	 }
	},
	start: function(){
	 this._executor = new PeriodicalExecuter(function(){
	  if(this.direction) { this.next(); } else { this.prev(); }
	 }.bind(this),this.delay);
	},
	stop: function(){
	 if(this._executor) { this._executor.stop(); }
	},
	toggle: function(){
	 this.paused=!this.paused;
	},
	pause: function(){
	 this.paused=1;
	},
	unpause: function(){
	 this.paused=0;
	},
	// from http://www.howtocreate.co.uk/perfectPopups.html
	_pi: function(url) {
	 AutoClose=false;
	 var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+600+',height='+400+',left='+10+',top='+10+',statusbar=false');
	 if( !imgWin ) { return true; }
	 imgWin.document.write('<html><head><title><\/title><script type="text\/javascript">\n'+
	 'function resizeWinTo() {\n'+
	 'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
	 'var oH = document.images[0].height, oW = document.images[0].width;\n'+
	 'if( !oH || window.doneAlready ) { return; }\n'+
	 'window.doneAlready = true;\n'+
	 'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
	 'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
	 'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
	 'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
	 'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
	 'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
	 'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
	 'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
	 'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
	 'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
	 '}\n'+
	 '<\/script>'+
	 '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
	 (document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
	 '<img src="'+url+'" title="" onload="resizeWinTo();">'+
	 (document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
	 imgWin.document.close();
	 if( imgWin.focus ) { imgWin.focus(); }
	 return false;
	}
});

function dodajSastojakPretraga(el) {
	var sastojakWrap = $(el).up('span.wrap').up('span.wrap');
	var buttonWrap = $(el).up('span.wrap');
	Move.element(sastojakWrap, $('clonedSastojci'), 'copy').insert({after:'<div class="clear"></div>'}).down('input').value='';
	buttonWrap.remove();
}

var Move =	{

		  copy	:   function(e, target)	{
			    var eId      = $(e);
			    var copyE    = eId.cloneNode(true);
			    var cLength  = copyE.childNodes.length -1;
			   /* copyE.id     = e+'-copy';*/

			    for(var i = 0; cLength >= i;  i++)	{
			    if(copyE.childNodes[i].id) {
			    var cNode   = copyE.childNodes[i];
			    /*var firstId = cNode.id;
			    cNode.id    = firstId+'-copy';*/ }
			    }
			    $(target).appendChild(copyE);
			    return copyE;
			    },
		  element:  function(e, target, type)	{
			    var eId =  $(e);
			    if(type == 'move') {
			       $(target).appendChild(eId);
			       return eId;
			    }

			    else if(type == 'copy')	{
			       return this.copy(e, target);
			    }
			    }
		}




var FastInit = {
	onload : function() {
		if (FastInit.done) { return; }
		FastInit.done = true;
		for(var x = 0, al = FastInit.f.length; x < al; x++) {
			FastInit.f[x]();
		}
	},
	addOnLoad : function() {
		var a = arguments;
		for(var x = 0, al = a.length; x < al; x++) {
			if(typeof a[x] === 'function') {
				if (FastInit.done ) {
					a[x]();
				} else {
					FastInit.f.push(a[x]);
				}
			}
		}
	},
	listen : function() {
		if (/WebKit|khtml/i.test(navigator.userAgent)) {
			FastInit.timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					clearInterval(FastInit.timer);
					delete FastInit.timer;
					FastInit.onload();
				}}, 10);
		} else if (document.addEventListener) {
			document.addEventListener('DOMContentLoaded', FastInit.onload, false);
		} else if(!FastInit.iew32) {
			if(window.addEventListener) {
				window.addEventListener('load', FastInit.onload, false);
			} else if (window.attachEvent) {
				return window.attachEvent('onload', FastInit.onload);
			}
		}
	},
	f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
FastInit.addOnLoad(function(){
	$$('textarea').each(function(tb){
		new ExpandableTextarea(tb);
	});
	if ($('prvi_sastojak')) {
		new Ajax.Autocompleter($('prvi_sastojak').down('input'), "autocomplete_choices", "/callback/sastojci.php", {
		  paramName: "value", 
		  minChars: 1,
		  frequency: 0
		});		
	}
	$$('button[type="submit"]').each(function(el){
		var button = el;
		button.observe('click', function(bt){
			button.writeAttribute('disabled', true);
			button.addClassName('disabled');
			button.up('form').submit();
		});
	});
	if ($('sastojci_table')) $('sastojci_table').down().hide();
	
	var textboxes = $$('form.awesome input[type!="checkbox"]', 'form.awesome textarea');

	textboxes.each(function(input, index){
	if (input.previous() && input.previous().tagName=='LABEL') {
		var label = input.previous();

//		if (index == 0){`
			//alert(label);
			new Form.Observer(input.up('form'), 0.1, function(form, value) {
				textboxes.each(function(inputX){
					if (inputX.previous() && inputX.previous().tagName=='LABEL') {
						if (!$F(inputX).empty()) {
							inputX.previous().addClassName('hastext');
						}
					}
				});
			});
		//}
		
		input.onfocus = function(){
			if ($F(input).empty()){
				label.addClassName('focus');            
			}
		}
		input.onblur = function(){
			if ($F(input).empty()){
				label.removeClassName('focus').removeClassName('hastext');          
			}
		}
		
		if (!$F(input).empty()) {
			label.addClassName('hastext');
		}
		
		input.onkeypress = function(){
			label.addClassName('hastext');
		};
	}
	});

	//passwordField();
});

