
		function setSmile(add,where)
		{
			/*document.getElementById(where).value = document.getElementById(where).value + (' '+add+' ');*/
			add = '<img src="' + add + '" alt="smile" />';
			inst = tinyMCE.getInstanceById(where);
			inst.execCommand('mceInsertContent',false, add);
			inst.execCommand('mceInsertContent',false, '&nbsp;');
		}

		function openpicture(file,width,height)
		{
			var param = "width="+width+",height="+height+",statusbar=0,menubar=0";
			newwin = window.open(file,"preview",param);
			newwin.moveTo(screen.width/2-width/2,200);
			return false;
		}

		function openprint(idecko, formPrint, formUserId)
		{
			var screenW = 640;
			if (parseInt(navigator.appVersion)>3) {
			 screenW = screen.width;
			}
			else if (navigator.appName == "Netscape"
			    && parseInt(navigator.appVersion)==3
			    && navigator.javaEnabled()
			   )
			{
			 var jToolkit = java.awt.Toolkit.getDefaultToolkit();
			 var jScreenSize = jToolkit.getScreenSize();
			 screenW = jScreenSize.width;
			}


			var param = "width=700,height=700,statusbar=0,menubar=0,scrollbars=1";
			var file = "";
			if(formPrint != 1)
			{
				file = "http://www.bio-watergardens.sk/print.php?id=" + idecko;
			}
			else
			{
				file = "http://www.bio-watergardens.sk/print.php?id=" + idecko + "&formPrint=1&formUserId=" + formUserId;
			}
			newwin = window.open(file,"print",param);
			newwin.moveTo(screenW.width/2-screenW/2,200);
			return false;
		}

		function uncheckAllRadios(whichForm, otazkaId)
		{

			var otazka = 'radio_answer_' + otazkaId;
			radios = document.getElementsByName(otazka);
			for (var i = 0; i < radios.length; i++)
			{
  				radios[i].checked = false;
  			}
		}

		function processReqInnerHtml(data, textStatus)
		{
	        if (textStatus == 'success')
			{
				if (data.contentType == 'text/xml')
				{
					var xmlResponse = data;
				}
				else if (data.contentType == 'text/plain')
				{
					var xmlResponse = (new DOMParser()).parseFromString(data, "text/xml");
				}

				var xmlRoot = xmlResponse.documentElement;
				var responseHtmlArray = xmlRoot.getElementsByTagName("responseHtml");
				var responseWhereToPutArray = xmlRoot.getElementsByTagName("responseWhereToPut");

            	$(responseWhereToPutArray.item(0).firstChild.nodeValue).html(responseHtmlArray.item(0).firstChild.nodeValue);

            	if ($(responseWhereToPutArray.item(0).firstChild.data).css('display') == 'none')
            	{
            		$(responseWhereToPutArray.item(0).firstChild.data).slideDown(400);
            	}

	            return;
	        }
		}

	$(document).ready(function() {
		$("a[href='']:not(:has(img))").addClass("dotted");
		$("a[href='#']:not(:has(img))").addClass("dotted");
		$("a[href='javascript:void(0);']:not(:has(img))").addClass("dotted");
		$("a[href='javascript:void(0)']:not(:has(img))").addClass("dotted");
			});

	//aniamacia infoBox
	$(document).ready(function() {
		$("div[class='infoBox']").Highlight(1000, $("div[class='infoBox']").css("color"));
	});


		$(document).ready(
			function ()
			{
				$.ImageBox.init(
					{
						loaderSRC: 'http://www.bio-watergardens.sk/styles/Default_Style/design/loadingAnimation.gif',
						closeHTML: 'zatvoriť (ESC)'
					}
				);

				
				// floating windows
				$('a.windowOpen').click(
						function(e)
						{
							var thisRel = $(this).attr('rel');
							var currentWindow = 'div.floatingWindow[@id=' + thisRel + ']';
							if($(currentWindow).css('display') == 'none')
							{
								$(currentWindow).css('left', 0);
								$(currentWindow).css('top', 0);
								if((e.pageX + $(currentWindow).width()) > $(window).width())
								{
									_left = ($(window).width() - $(currentWindow).width() - 20);
								}
								else if((e.pageX - ($(currentWindow).width() / 2)) < 0)
								{
									_left = 20;
								}
								else
								{
									_left = (e.pageX - ($(currentWindow).width() / 2));
								}
								_top = e.pageY - ($(currentWindow).height() / 2);
								$(currentWindow).css('left', _left);
								$(currentWindow).css('top', _top);
								$(currentWindow).slideDown(500);
							}
						return false;
						}
					);
					$('img.floatingWindowClose').click(
						function()
						{
							var currentWindow = $(this.parentNode.parentNode);
							$(currentWindow).fadeOut(400);
						}
					);
					$('div.floatingWindow').Draggable(
							function()
							{
								handle: $(this.parentNode);
							}
						);
			}
		);



		/* star rating system - thnx to http://www.nofunc.com */

		function $getMyType(v,o) { return((typeof(o)=='object'?o:document).getElementById(v)); }
		function $S(o) { return((typeof(o)=='object'?o:$getMyType(o)).style); }
		function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
		function abPos(o) { var o=(typeof(o)=='object'?o:$getMyType(o)), z={X:0,Y:0}; while(o!=null) { z.X+=o.offsetLeft; z.Y+=o.offsetTop; o=o.offsetParent; }; return(z); }
		function XY(e,v) { var o=agent('msie')?{'X':event.clientX+document.documentElement.scrollLeft,'Y':event.clientY+document.documentElement.scrollTop}:{'X':e.pageX,'Y':e.pageY}; return(v?o[v]:o); }

		star={};

		star.mouse=function(e,o)
		{
			if(star.stop || isNaN(star.stop))
			{
				star.stop=0;

				document.onmousemove=function(e)
				{
					var n = star.num;
					var p = abPos($getMyType('star' + n));
					var x = XY(e);
					var oX = x.X-p.X;
					var oY = x.Y-p.Y;

					star.num = o.id.substr(4);

					if(oX<1 || oX>100 || oY<0 || oY>19)
					{
						star.stop = 1;
						star.revert();
					}
					else
					{
						$S('starCur'+n).width = oX + 'px';
						$getMyType('starUser'+n).innerHTML = Math.round(oX/100*100) + '%';
					}
			};
		} };

		star.update=function(e,o)
		{
			var n = star.num;
			var v = parseInt($getMyType('starUser'+n).innerHTML);

			n = o.id.substr(4);
			$getMyType('starCur'+n).title = v;

			myStr = 'op=articleRating&vote=' + v + '&itemId=' + star.num;

			$.ajax({
					type:	"GET",
					url:	"http://www.bio-watergardens.sk/js/ajaxHandler.php",
					data:	myStr,
					success:  processReqChangeRating
				   });
		};
		star.revert=function()
		{
			var n = star.num;
			var v = parseInt($getMyType('starCur'+n).title);

			$S('starCur'+n).width=Math.round(v*100/100) + 'px';
			$getMyType('starUser'+n).innerHTML = (v > 0 ? Math.round(v) + '%' : 'n/a');

			document.onmousemove = '';
		};

		star.num = 0;

		function processReqChangeRating(data, textStatus) // custom ajax called response
		{
			if (textStatus == 'success')
			{
				if (data.contentType == 'text/xml')
				{
					var xmlResponse = data;
				}
				else if (data.contentType == 'text/plain')
				{
					var xmlResponse = (new DOMParser()).parseFromString(data, "text/xml");
				}

				var xmlRoot = xmlResponse.documentElement;
				var responseTextArray = xmlRoot.getElementsByTagName("responseText");

				document.onmousemove = '';

				if(null == $(".starResult").text().match(responseTextArray.item(0).firstChild.data))
				{
	            	$(".starResult").prepend(responseTextArray.item(0).firstChild.data);
	            }

	            $(".starResult").slideDown(400);
	            return;
		    }
		}

		/* end of star rating system */


		/* user to user and thanks rating */

		user = {};

		user.update=function(o,u,p)
		{
			var n = parseInt(u);

			if(p != 'thanks')
			{
				var myStr = 'op=userToUserRating&vote=' + p + '&userId=' + n;

				$.ajax({
						type:	"GET",
						url:	"http://www.bio-watergardens.sk/js/ajaxHandler.php",
						data:	myStr,
						success:  processReqChangeUserToUserRating
					   });
			}
			else
			{
				var myStr = 'op=thanksRating&userId=' + n;

				$.ajax({
						type:	"GET",
						url:	"http://www.bio-watergardens.sk/js/ajaxHandler.php",
						data:	myStr,
						success:  processReqChangeThanks
					   });
			}
		};

		function processReqChangeUserToUserRating(data, textStatus)
		{
			if (textStatus == 'success')
			{
				if (data.contentType == 'text/xml')
				{
					var xmlResponse = data;
				}
				else if (data.contentType == 'text/plain')
				{
					var xmlResponse = (new DOMParser()).parseFromString(data, "text/xml");
				}

				var xmlRoot = xmlResponse.documentElement;
				var responseTextArray = xmlRoot.getElementsByTagName("responseText");
				var responseUserArray = xmlRoot.getElementsByTagName("responseUser");
				var tmpRes = '#userRatingResult' + responseUserArray.item(0).firstChild.data;

				if( responseTextArray.item(0).firstChild.data != 'ok' &&
					null == $(tmpRes).text().match(responseTextArray.item(0).firstChild.data))
				{
	            	$(tmpRes).prepend(responseTextArray.item(0).firstChild.data);
	            	$(tmpRes).slideDown(400);
	            }

				if(responseTextArray.item(0).firstChild.data == 'ok')
	            {
	            	var responsePointsArray = xmlRoot.getElementsByTagName("responsePoints");
	            	var tmpSpn = '#userRating' + responseUserArray.item(0).firstChild.data;
	            	var tempTxt = (parseInt(responsePointsArray.item(0).firstChild.data) > 0) ? '+' + responsePointsArray.item(0).firstChild.data : responsePointsArray.item(0).firstChild.data;

					$(tmpSpn).removeClass();
	            	if(parseInt(responsePointsArray.item(0).firstChild.data) > 0)
	            	{
	            		$(tmpSpn).addClass("green");
	            	}
	            	if(parseInt(responsePointsArray.item(0).firstChild.data) < 0)
	            	{
	            		$(tmpSpn).addClass("red");
	            	}

	            	$(tmpSpn).text(tempTxt);
		        }
		    }
		}

		function processReqChangeThanks(data, textStatus)
		{
		    if (textStatus == 'success')
			{
				if (data.contentType == 'text/xml')
				{
					var xmlResponse = data;
				}
				else if (data.contentType == 'text/plain')
				{
					var xmlResponse = (new DOMParser()).parseFromString(data, "text/xml");
				}

				var xmlRoot = xmlResponse.documentElement;
				var responseTextArray = xmlRoot.getElementsByTagName("responseText");
				var responseUserArray = xmlRoot.getElementsByTagName("responseUser");
				var tmpRes = '#userRatingResult' + responseUserArray.item(0).firstChild.data;

				if( responseTextArray.item(0).firstChild.data != 'ok' &&
					null == $(tmpRes).text().match(responseTextArray.item(0).firstChild.data))
				{
	            	$(tmpRes).prepend(responseTextArray.item(0).firstChild.data);
	            	$(tmpRes).slideDown(400);
	            }

				if(responseTextArray.item(0).firstChild.data == 'ok')
	            {
	            	var responsePointsArray = xmlRoot.getElementsByTagName("responsePoints");
	            	var tmpSpn = '#thanksRating' + responseUserArray.item(0).firstChild.data;

	            	$(tmpSpn).text(responsePointsArray.item(0).firstChild.data);
	            }
			}
		}

		/* end of user to user rating */

