//Flash Putnik
	function setSlider( number, total ) {
		var obj = swfobject.getObjectById("intro");
		obj.setSlider( number );	
		for(i=0;i<total;i++) {
			id = 'intro_link'+i;
			document.getElementById(id).className = '';
		}
	}

	function clearClass( name, total ) {
		for(i=0;i<total;i++) {
			id = name+i;
			document.getElementById(id).className = '';
		}
	}
	
	function onImageChange( number) {
		var id = 'intro_link'+number;
		clearClass('intro_link','4');
		document.getElementById(id).className = 'on';
	}
//END Putnik
	
//Input text koji se sklanja i vraca
	function input_blur_word(e,value) {
	    if(e.value == "")
	        e.value = value;
	}
	function input_focus_word(e,value) {
	    if(e.value == value)
	        e.value = "";
	}

//Gallery Load
		// Ucitava stranicu u definisan id uz mogucnost samostalnog azuriranja
	function galleryLoad(link, id) {
		window.addEvent('domready', function() {
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$(id).tween('height', '350');
					$(id).set('html', '<div align="center">Loading ...<img src="/img/gallery-loader.gif" alt="" /></div>');
				},
				onSuccess: function(html) {
					$(id).tween('height', '350');
					$(id).set('text', '');
					$(id).adopt(html);
					fadeIn.start(0,1); 
					//ajax Mediabox
					Mediabox.scanPage = function() {
						var links = $$("a").filter(function(el) {
							return el.rel && el.rel.test(/^lightbox/i);
						});
						$$(links).mediabox({/* Put custom options here */}, null, function(el) {
							var rel0 = this.rel.replace(/[[]|]/gi," ");
							var relsize = rel0.split(" ");
							return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1]));
						});
					};
					window.addEvent("domready", Mediabox.scanPage);		
					//# ajax

				
				},
				onFailure: function() {
					$(id).set('html', 'The request failed.');
				}
			});
			req.send();
		});
		var fadeIn = new Fx.Tween(id,{property:'opacity', duration: 1000 }); 
		
	}		

//Delete block
	// Ucitava stranicu u definisan id uz mogucnost samostalnog azuriranja
	function deleteBox(link, id) {

		window.addEvent('domready', function() {
			
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$(id).set('html', 'Deleting ...');
					$(id).highlight('#c92637');
				},
				onSuccess: function(html) {
					$(id).set('text', '');
					$(id).adopt(html);
					//Setuj da za 5s se lagano ugasi i onda sakrije
					//$(id).set('tween', {duration: 3000, onComplete: function() { $(id).dispose();} });
					fadeOut.start({ opacity : 0 }); 
					$(id).fade('out');
				},
				onFailure: function() {
					//alert(link);
					$(id).set('html', 'The request failed.');
				}
			});
			
			var doRefresh = function() {
			  req.send();
			};

			var fadeOut = new Fx.Morph(id,{ 
				duration: 5000, 
				onComplete: function () { 
					$(id).dispose()
				} 
			});

			req.send();
			
		});
	}		

	// Ucitava stranicu u definisan id uz mogucnost samostalnog azuriranja
	function updateBox(link, id) {

		window.addEvent('domready', function() {
			
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$(id).set('html', 'Update ...');
					$(id).highlight('#c92637');
				},
				onSuccess: function(html) {
					$(id).set('text', '');
					$(id).adopt(html);
				},
				onFailure: function() {
					//alert(link);
					$(id).set('html', 'The request failed.');
				}
			});
			
			var doRefresh = function() {
			  req.send();
			};

			req.send();
			
		});
	}		
	
// Close box
		function closeGoBody(id) {
			document.getElementById(id).style.display = 'none';			
		}
//Open box
		function openGoBody(id) {
			document.getElementById(id).style.display = 'block';
		}

		
// AJAX predefinisan id otvaranja i url, saljes mu samo articleid
		function goArticleBody(articleid) {
			document.getElementById('article_print').style.display = 'block';			
			goBody('/cms/view.php?id='+articleid+'&page_type=ajax&template=product-general', 'article_print');		
		}

		function resetCssClass(name, total) {
			for(i=1;i<=total;i++) {
				document.getElementById(name+i).className = '';
			}
        }
		
		function changeCssClass(id, name) {
            if(name) {
                document.getElementById(id).className = name;
            }
            else {
                document.getElementById(id).className = '';
            }
        }

//ajax ucitavanje strane
	// <a href="javascript:goCMS('video1.php');" id="cmsid1">Video 111</a>
		function goCMS(link) {
			
			window.addEvent('domready', function() {
			//alert(link);	
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$('body').set('html', 'Loading ...<img src="/img/loading.gif" alt="" />');
				},
				onSuccess: function(html) {
					$('body').set('text', '');
					$('body').adopt(html);
				},
				onFailure: function() {
					$('body').set('html', 'The request failed.');
				}
			});
			
			//pozovi funkciju za ucitavanje
			req.send();
			
			/*
			//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() {
			var req = new Request.HTML({
				url:link, 
				onRequest: function() { 
					$(id).set('html', 'Loading ...<img src="/img/loading.gif" alt="" />');
				},
				onSuccess: function(html) {
					$(id).set('text', '');
					$(id).adopt(html);

					//ajax Title
					Cufon.replace('h1', {hover: true})
					('h2', {hover: true})
					('h3', {hover: true})
					('h4', {hover: true})
					('h5', {hover: true})
					;
					Cufon.now();
					
					//ajax Mediabox
					Mediabox.scanPage = function() {
						var links = $$("a").filter(function(el) {
							return el.rel && el.rel.test(/^lightbox/i);
						});
						$$(links).mediabox({/* Put custom options here */}, null, function(el) {
							var rel0 = this.rel.replace(/[[]|]/gi," ");
							var relsize = rel0.split(" ");
							return (this == el) || ((this.rel.length > 8) && el.rel.match(relsize[1]));
						});
					};
					window.addEvent("domready", Mediabox.scanPage);		
					//# ajax


					//ajax submit form into ajax
					FormScanPage = function() {
						if (!window.demo_path) window.demo_path = '';
						var demo_path = window.demo_path;
						$('form_comment').addEvent('submit', function(e) {
							e.stop();
							//Empty the log and show the spinning indicator.
							var log = $('CommentResolt').empty().addClass('ajax-loading');
							this.set('send', {onComplete: function(response) { 
								log.removeClass('ajax-loading');
								log.set('html', response);
							}});
							//Send the form.
							this.send();
						});
					}
					window.addEvent("domready", FormScanPage);
					//# form	
				
				},
				onFailure: function() {
					//alert(link);
					$(id).set('html', 'The request failed.');
				}
			});
			
			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 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;
		}
