	function toggleDiv(id,flagit) {
		if (flagit=="1"){
			if (document.layers) document.layers[''+id+''].visibility = "show"
			else if (document.all) document.all[''+id+''].style.visibility = "visible"
			else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
		} else if (flagit=="0"){
			if (document.layers) document.layers[''+id+''].visibility = "hide"
			else if (document.all) document.all[''+id+''].style.visibility = "hidden"
			else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
		}
	
	}

	
	function changeBg(id, background) {
			if(background) document.getElementById(id).style.background='url(../../img/bg_box-C_links_on.gif) 0 100% repeat-x';
			else document.getElementById(id).style.background= 'transparent';
	}

	function setClass(id, myclass) {
			document.getElementById(id).className = myclass;
	}
		
//ajax ucitavanje strane
	// <a href="javascript:goCMS('video1.php');" id="cmsid1">Video 111</a>
	
	//Ajax ucitavanje strane sa intervalom osvezavanja u sekundama
		function goCMS(link, interval) {
			
			window.addEvent('domready', function() {
			//alert(link);	
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$('body').set('html', 'Loading page...<img src="/img/loading.gif" alt="" />');
				},
				onSuccess: function(html) {
					$('body').set('text', '');
					$('body').adopt(html);
				},
				onFailure: function() {
					$('body').set('html', '<h2>The request failed.</h2>');
				}
			});
			
			var doRefresh = function() {
			  req.send();
			};

			//pozovi funkciju za ucitavanje, ako ima interval onda sa osvezavanjem
			if(!interval) 
				req.send();
			else {
				req.send();
				doRefresh.periodical(interval*1000);
			}
		
			/*
			//ako hoces moze zvati i klikom na neki ID
			$(id).addEvent('click', function(e){
						//We can pass new options for our Request object to the send method.
						req.send({url:cms});
					});
			*/
			});
		
		}


// Ucitava stranicu u definisan id uz mogucnost samostalnog azuriranja
		function goBody(link, id, interval) {
			
			window.addEvent('domready', function() {
			//alert(link);	
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$(id).set('html', 'Loading page...<img src="/img/loading.gif" alt="" />');
				},
				onSuccess: function(html) {
					$(id).set('text', '');
					$(id).adopt(html);
				},
				onFailure: function() {
					$(id).set('html', '<h2>The request failed.</h2>');
				}
			});
			
			var doRefresh = function() {
			  req.send();
			};

			//pozovi funkciju za ucitavanje, ako ima interval onda sa osvezavanjem
			if(!interval) 
				req.send();
			else {
				req.send();
				doRefresh.periodical(interval*1000);
			}
			
			});
		
		}

		function isEmpty(s) {
                if (s.length == 0) return true;
                if (trim(s).length == 0) return true;
                return false;
        }

        function trim(s) {
                var i = 0;
                while(isspace(s.charAt(i))) i++;
                if (i == s.length) return new String('');

                var j = s.length - 1;
                while(isspace(s.charAt(j))) j=j-1;

                return s.substring(i, j + 1);
        }

        function isspace(c) {
                if (c == ' ') return true;
                if (c == '\n') return true;
                return false;
        }


		function rightclick() {
			if (event.button==2) {
				alert('Nije dozvoljeno koriscenje desnog misa!');		
			}
		}

		/***********************************************
		* Disable Text Selection script- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
		* This notice MUST stay intact for legal use
		* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
		***********************************************/

		function disableSelection(target){
			if (typeof target.onselectstart!="undefined") //IE route
				target.onselectstart=function(){return false}
			else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
				target.style.MozUserSelect="none"
			else //All other route (ie: Opera)
				target.onmousedown=function(){return false}
			target.style.cursor = "default"
		}
		//Sample usages
		//disableSelection(document.body) //Disable text selection on entire body
		//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"


		function bookmarksite(title,url){
			if (window.sidebar) // firefox
				window.sidebar.addPanel(title, url, "");
			else if(window.opera && window.print){ // opera
				var elem = document.createElement('a');
				elem.setAttribute('href',url);
				elem.setAttribute('title',title);
				elem.setAttribute('rel','sidebar');
				elem.click();
			} 
			else if(document.all)// ie
				window.external.AddFavorite(url, title);
		}

		function link_bookmark(url) {
			var txt = "Bookmark";
			//var url = "<?php echo $conf->web->home_domain; ?>";
			var who = "CodeBrain.com FREE JAVA";
			
			var ver = navigator.appName;
			var num = parseInt(navigator.appVersion);
			if ((ver == "Microsoft Internet Explorer") && (num >= 4)) {
			document.write('<a href="javascript:window.external.AddFavorite(url,who);" ');
			document.write('onmouseover=" window.status=');
			document.write("txt; return true ");
			document.write('"onmouseout=" window.status=');
			document.write("' '; return true ");
			document.write('">'+ txt + '</a>');
			} else {
			txt += "  (Ctrl+D)";
			document.write('<a href="javascript:void(0);" title="Bookmark">'+ txt + '</a>');
			} 
		}


		/* novi prozor	*/
		function open_win(t,x,y) {
			if ((t) && (t != null)) {
	    		pWindow = open(t,"np","width="+x+",height="+y+",menubar=no,scrollbars=no,resizable=yes");
	        	pWindow.focus();
	    	}
		}

		function goSelect(name){
			var f = document.forms[name];
			var list=f.goURL
			location = list.options[list.selectedIndex ].value
		}
		
		function go(url) {
			if (url.charAt(0) == '/') location.href = url;
			else location.href = '<?php echo $GLOBALS["conf"]->web->home_url ?>' + url;
		}

				
		function visibleclick(id)
		{
		   if (document.getElementById(id).style.display=='none')
		     document.getElementById(id).style.display='';
		   else
		     document.getElementById(id).style.display='none';
		
		}
		
		function displayclick(id, action)
		{
		   if ( (action=='on') && (document.getElementById(id).style.display=='none') ) {
		     document.getElementById(id).style.display='';
		   }
		   else {
		     document.getElementById(id).style.display='none';
		  }
		  return null;
		}
		
		function checkAll() {
			var f = document.formular;
	
			for (var i=0;i<f.elements.length;i++){
				var e = f.elements[i];
				if (e.type=='checkbox')
					e.checked = true;
			}
		}
	
		function decheckAll() {
			var f = document.formular;
	
			for (var i=0;i<f.elements.length;i++){
				var e = f.elements[i];
				if (e.type=='checkbox')
					e.checked = false;
			}
		}
		
		function submitForm(name) {
            var f = document.forms[name];
			f.submit();
        	return true;
		}
