
function showhide(layer_ref, opt) {

var ie = (document.all) ? true : false;

	
	var element = (ie) ? document.all(layer_ref) : document.getElementById(layer_ref);
  
  
  if (opt=='0')
  element.style.display='none';
  
  else if (opt=='1')
    
     element.style.display='';
  
}


function deakt_taster(tip) {
	
	if (tip==0)
	document.forma2.prethodna.disabled= true;
	
	else
	document.forma2.sledeca.disabled=true;
	
}



function getScriptPage(div_id, opcija, strana)
		{
			subject_id = div_id;
			
			var ime = document.forma1.ime0.value;
			var naslov = document.forma1.ime1.value;
			var select1 = document.forma1.aut.selectedIndex;
			var ime_opt = document.forma1.aut.options[select1].value;
			var select2 = document.forma1.delo.selectedIndex;
			var naslov_opt = document.forma1.delo.options[select2].value;
			
			var radio = 0;
			for( i = 0; i < document.forma1.god_radio.length; i++ )
			{
			if( document.forma1.god_radio[i].checked == true )
				radio = document.forma1.god_radio[i].value;
			}
			
			if (radio==1){
			
			var select3 = document.forma1.sel_godina0.selectedIndex;
			var god_opt = document.forma1.sel_godina0.options[select3].value;
			}
			
			else if (radio==2) {
			var select4 = document.forma1.sel_godina1.selectedIndex;
			var period_opt1 = document.forma1.sel_godina1.options[select4].value;
			var select5 = document.forma1.sel_godina2.selectedIndex;
			var period_opt2 = document.forma1.sel_godina2.options[select5].value;
			}
			else
				;
			
			
			http.open("GET", "./e107_plugins/katalog/script_page.php?ime="+escape(ime)+"&naslov="+escape(naslov)+"&ime_opt="+ime_opt+"&naslov_opt="+naslov_opt+"&radio="+radio+"&god_opt="+god_opt+"&period_opt1="+period_opt1+"&period_opt2="+period_opt2+"&opcija="+opcija+"&strana="+strana, true);
			http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
			
		}	
		
		
		
/* function lookup(inputString) {
	
	alert("ucitao je lookup string: "+ inputString);
	$('#suggestions').show();
	
	}
	
	*/	
		

	function lookup(inputString, polje, tip) {
		
		//tip nula je za lookup autora, tip 1 je za lookup naslova
		
	if (tip==0) {	
	
		var signindex = document.forma1.aut.selectedIndex;
		var opcija = document.forma1.aut.options[signindex ].value;
	}
	
	else {
		var signindex = document.forma1.delo.selectedIndex;
		var opcija = document.forma1.delo.options[signindex ].value;
		
	}
		
		
		
		
		if(inputString.length <2) {
			// Hide the suggestion box.
			$('#suggestions'+polje).hide();
		} else {
		
			$.post("./e107_plugins/katalog/rpc.php", {queryString: ""+inputString+"", polje: ""+polje+"", opcija: ""+ opcija +""}, function(data){
				//na osnovu opcije se odredjuje upit
				if(data.length >0) {
					$('#suggestions'+polje).show();
					$('#autoSuggestionsList'+polje).html(data);
				}
			});
		}
	} // lookup
	
	function fill(thisValue, polje) {
		
		if (polje=='suggestions0')
		$('#ime0').val(thisValue);
		
		if (polje=='suggestions1')
		$('#ime1').val(thisValue);
			
			
			
		$('#'+polje+'').hide();
	}	
		
		
			function goaway(param) {
		
				
		$('#suggestions'+param).hide();
	}	
		
		
		
			

		


	

function str_replace(search, replace, subject) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Gabriel Paderni
    // +   improved by: Philip Peterson
    // +   improved by: Simon Willison (http://simonwillison.net)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   bugfixed by: Anton Ongson
    // +      input by: Onno Marsman
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    tweaked by: Onno Marsman
    // +      input by: Brett Zamir
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: str_replace(' ', '.', 'Kevin van Zonneveld');
    // *     returns 1: 'Kevin.van.Zonneveld'
    // *     example 2: str_replace(['{name}', 'l'], ['hello', 'm'], '{name}, lars');
    // *     returns 2: 'hemmo, mars'
 
    
    
    var s = subject;
    var ra = r instanceof Array, sa = s instanceof Array;
    var f = [].concat(search);
    var r = [].concat(replace);
    var i = (s = [].concat(s)).length;
    var j = 0;
    
    while (j = 0, i--) {
        if (s[i]) {
            while (s[i] = (s[i]+'').split(f[j]).join(ra ? r[j] || "" : r[0]), ++j in f){};
        }
    }
 
    return sa ? s : s[0];
}