kosarica();

function visina(){
	
		var visina = document.getElementById('desnistupac').offsetHeight - 300;
		document.getElementById('glavni').height = visina;
	
}

function klikPretraz(objekt){
	 if(objekt.value == "Pretraživanje"){
		objekt.value = '';	
		objekt.style.color = "#000";
	  }
	 
}

function vratiPretraz(objekt){
	  if(objekt.value == ''){
		objekt.value = 'Pretraživanje';	
		objekt.style.color = "#999";
	  }
	 
}


function klikPretraz2(objekt){
	 if(objekt.value == "Pretraživanje elemenata"){
		objekt.value = '';	
	  }
	 
}

function vratiPretraz2(objekt){
	  if(objekt.value == ''){
		objekt.value = 'Pretraživanje elemenata';	
	  }
	 
}


function logiranje(){
			
			if(document.getElementById('username').value == ""){
				alert("Niste upisali korisničko ime");
				return false;
			}
			
			if(document.getElementById('password').value == ""){
				alert("Niste upisali lozinku");
				return false;
			}
			var username = document.getElementById('username').value;
			var password = document.getElementById('password').value;
			
			document.getElementById('loader').style.display = "inline";
			
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						document.getElementById('loader').style.display = "none";					
												
						var trimmed = xmlhttp.responseText;
							trimmed = trimmed.replace(/^\s+|\s+$/g, '') ;
						
						if(trimmed == 'ok'){
							
							//ako je logiranje prošlo ok onda refrešamo stranicu:
							document.location = document.location;
						
							document.getElementById('logiranje').style.display="none";
							document.getElementById('greska').style.display="none";
						}else{
							document.getElementById('logiranje').style.display="inline";
							document.getElementById('greska').style.display="inline";
							document.getElementById('username').value = ""
							document.getElementById('password').value = "";
							
						}
						
						
						
						
					}
				}	
			}
			
						
			var url="includes/ajax-login.php";
			url=url+"?username="+username+"&password="+password+"&bezveze="+new Date().getTime();
			
			xmlhttp.open("POST",url,true);
			xmlhttp.send(null);
		}
		
	function logiranje2(){
			
			if(document.getElementById('username2').value == ""){
				alert("Niste upisali korisničko ime");
				return false;
			}
			
			if(document.getElementById('password2').value == ""){
				alert("Niste upisali lozinku");
				return false;
			}
			var username = document.getElementById('username2').value;
			var password = document.getElementById('password2').value;
			
			
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						document.getElementById('loader').style.display = "none";					
												
						var trimmed = xmlhttp.responseText;
							trimmed = trimmed.replace(/^\s+|\s+$/g, '') ;
						
						if(trimmed == 'ok'){
							
							//ako je logiranje prošlo ok onda refrešamo stranicu:
							document.location = document.location;
						
							document.getElementById('logiranje').style.display="none";
							document.getElementById('greska').style.display="none";
						}else{
							document.getElementById('logiranje').style.display="inline";
							document.getElementById('greska').style.display="inline";
							document.getElementById('username2').value = ""
							document.getElementById('password2').value = "";
							
						}
						
						
						
						
					}
				}	
			}
			
						
			var url="includes/ajax-login.php";
			url=url+"?username="+username+"&password="+password+"&bezveze="+new Date().getTime();
			
			xmlhttp.open("POST",url,true);
			xmlhttp.send(null);
		}
					
			
		function GetXmlHttpObject(){
			//za provjeru ajax
			var xmlHttp=null;
			
			try{
				// Firefox, Opera 8.0+, Safari
				xmlHttp=new XMLHttpRequest();
			}
				  catch (e){
				  		// Internet Explorer
					  try{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					  }
					  catch (e){
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
				  	  }
			 }
			
			return xmlHttp;
		}
		
				
		function writeHTML(req,koji) {
			
			document.getElementById(koji).innerHTML = req.responseText;
		
			
		}

///////////////////////

// Na pproizvodima //
function otvoripopup(id){
		
		
		dajAjax = false;
		
		var objekt = document.getElementById('detalji_' + id);
		
		
		if(objekt.style.display == "" || objekt.style.display == "none"){
			objekt.style.display = "block";
			document.getElementById('loader_'+id).style.display = "inline";
			dajAjax = true;
		}else{
			
			objekt.style.display = "none";
			objekt.innerHTML = "";
		}
		
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						document.getElementById('loader_'+id).style.display = "none";
						var idpopupa = 'detalji_'+id;
						
						writeHTML(xmlhttp,idpopupa)	;					
						
					}
				}	
			}
			
			
			if(dajAjax == true){
			params="?id="+id;			
			var url="proizvod_element.php"+params;
			
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
			}
		
		
	}
	
	
	
	/////// Registracija 
	
	function onloadReg(){
			
						
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						writeHTML(xmlhttp,'registracija');
						
						document.getElementById('pr_reg').style.visibility = "hidden";
						
					}
				}	
			}
			
						
			var url="ajax_registracija.php";
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}
		
	function onloadReg2(){
			
						
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						writeHTML(xmlhttp,'registracija');
						
						document.getElementById('pr_reg').style.visibility = "hidden";
						
					}
				}	
			}
			
						
			var url="ajax_podaci.php";
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		}	
		
		
		function provjeraForme(){
			
			var forma =document.getElementById('aurelis');
			/*rad_val = 0;
			for (var i=0; i < document.aurelis.R1.length; i++) {
				   if (document.aurelis.R1[i].checked){
					  var rad_val = document.aurelis.R1[i].value;
					  //alert(rad_val)
				  }
			}*/
			
			/*
			if(rad_val != 1){
				
				if(rad_val == 0){
					alert("Niste potvrdili da imate više od 18 godina");
					return false;
				}else{
					alert("Registracija je moguća samo za starije od 18 godina");
					return false;
				}
			}*/

			
			
			
			if(forma.username2.value == ""){
				alert("Niste odabrali korisničko ime");
				return false;
			}
			if(forma.password2.value == ""){
				alert("Niste upisali lozinku");
				return false;
			}
			/*
			if(forma.Ime.value == ""){
				
				if(document.getElementById('tvrtka').checked == true){
					alert("Niste upisali naziv tvrtke");
					return false;
					}else{
					alert("Niste upisali ime i prezime");
					return false;
				}
				
				
			}*/
			
			if(forma.email.value == ""){
				alert("Niste upisali e-mail adresu");
				return false;
			}
			if(forma.adresa.value == ""){
				alert("Niste upisali adresu");
				return false;
			}
			if(forma.post.value == ""){
				alert("Niste upisali poštanski broj");
				return false;
			}
			if(forma.grad.value == ""){
				alert("Niste upisali grad");
				return false;
			}
			if(forma.drzava.value == ""){
				alert("Niste upisali državu");
				return false;
			}
			if(forma.tel_fax.value == ""){
				alert("Niste upisali broj telefona");
				return false;
			}
			
			
			registriraj();
			
		}
		
		function provjeraForme2(){
			
			var forma =document.getElementById('aurelis');
					

			
			
			
			if(forma.username2.value == ""){
				alert("Niste odabrali korisničko ime");
				return false;
			}
			if(forma.password2.value == ""){
				alert("Niste upisali lozinku");
				return false;
			}
			/*
			if(forma.Ime.value == ""){
				
				if(document.getElementById('tvrtka').checked == true){
					alert("Niste upisali naziv tvrtke");
					return false;
					}else{
					alert("Niste upisali ime i prezime");
					return false;
				}
				
				
			}*/
			if(forma.email.value == ""){
				alert("Niste upisali e-mail adresu");
				return false;
			}
			if(forma.adresa.value == ""){
				alert("Niste upisali adresu");
				return false;
			}
			if(forma.post.value == ""){
				alert("Niste upisali poštanski broj");
				return false;
			}
			if(forma.grad.value == ""){
				alert("Niste upisali grad");
				return false;
			}
			if(forma.drzava.value == ""){
				alert("Niste upisali državu");
				return false;
			}
			if(forma.tel_fax.value == ""){
				alert("Niste upisali broj telefona");
				return false;
			}
			
			
			updetaj();
			
		}
		
		function provjera(){
			
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						
						if(trim(xmlhttp.responseText) != ""){
							alert("Takvo korisničko ime već postoji u bazi korisnika\n\nMolimo izaberite neko drugo")
							document.getElementById('username2').value = "";
							document.getElementById('username2').focus();
						}
						
					}
				}	
			}
			
						
			var url="ajax_provjera.php";	
			
			
			xmlhttp.open("POST",url,true);
			var params="un="+document.getElementById('username2').value
			
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.setRequestHeader("Content-length", params.length);
			xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(params);
			
			
			
			
		}
		
 	function registriraj(){
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						
						writeHTML(xmlhttp,'registracija');
						
					}
				}	
			}
			
						
			
			
			var forma = document.getElementById('aurelis');	
			
			/*if(forma.lista.checked==true){
					var lista = 1;
				}else{
					var lista = 0;
					}*/
			
			var params="username2="+forma.username2.value;
				params += "&password2="+forma.password2.value;
				/*params += "&tvrtka="+forma.tvrtka.value;*/
				params += "&Ime="+forma.Ime.value;
				params += "&email="+forma.email.value;
				params += "&adresa="+forma.adresa.value;
				params += "&post="+forma.post.value;
				params += "&grad="+forma.grad.value;
				params += "&drzava="+forma.drzava.value;
				params += "&tel_fax="+forma.tel_fax.value;
				/*params += "&Maticni_broj="+forma.Maticni_broj.value;
				params += "&Ziro_racun="+forma.Ziro_racun.value;*/
				/*params += "&lista="+lista;*/
			
			var url="ajax-registracija2.php?"+params;	
			
			
			xmlhttp.open("GET",url,true);
			//xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=windows-1250");
			//xmlhttp.setRequestHeader("Content-length", params.length);
			//xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(null);
		
		
	}
	
	 	function updetaj(){
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						
						alert("Podaci su promijenjeni")
						
					}
				}	
			}
			
						
			
			
			var forma = document.getElementById('aurelis');	
			var params="username2="+forma.username2.value;
				params += "&IDkupca="+forma.IDkupca.value;
				params += "&password2="+forma.password2.value;
				/*params += "&tvrtka="+forma.tvrtka.value;*/
				params += "&Ime="+forma.Ime.value;
				params += "&email="+forma.email.value;
				params += "&adresa="+forma.adresa.value;
				params += "&post="+forma.post.value;
				params += "&grad="+forma.grad.value;
				params += "&drzava="+forma.drzava.value;
				params += "&tel_fax="+forma.tel_fax.value;
				/*params += "&Maticni_broj="+forma.Maticni_broj.value;
				params += "&Ziro_racun="+forma.Ziro_racun.value;*/
				/*params += "&lista="+forma.lista.value;*/
			
			var url="ajax-update.php?"+params;	
			
			
			xmlhttp.open("GET",url,true);
			//xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=windows-1250");
			//xmlhttp.setRequestHeader("Content-length", params.length);
			//xmlhttp.setRequestHeader("Connection", "close");
			xmlhttp.send(null);
		
		
	}
		
		
		
		
		
	function tvrtkaa(){
		if(document.getElementById('tvrtka').checked == true){
			document.getElementById('Maticni_broj').disabled = "";
			document.getElementById('Ziro_racun').disabled = "";
			document.getElementById('Maticni_broj').value = "";
			document.getElementById('Ziro_racun').value = "";
			
		}else{
			document.getElementById('Maticni_broj').disabled = "disabled";
			document.getElementById('Ziro_racun').disabled = "disabled";
			document.getElementById('Maticni_broj').value = "-- samo za tvrtku --";
			document.getElementById('Ziro_racun').value = "-- samo za tvrtku --";
		}
	}
	
	
	function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
	}
	
	function ltrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
	
	function rtrim(str, chars) {
		chars = chars || "\\s";
		return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}
	
	
	/////////// KOŠRAICA ////
	
	function dodajUkosaricu(id,cijena,cijena_eur,gore){
		
		var komada = document.getElementById('komada_'+id).value;
		var params="?id="+id+"&kom="+komada+"&cijena="+cijena+"&cijena_eur="+cijena_eur+"&b="+new Date().getTime();	
			
		if(gore){
			document.getElementById('dodano_'+id).innerHTML = "<img src='images/ajax-loader.gif' width='16' height='16' />";
		}else{
			document.getElementById('dodano_'+id).innerHTML = "<img src='images/ajax-loader.gif' width='16' height='16' />";
		}
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						if(trim(xmlhttp.responseText) == "OK"){
							
							if(gore){
							
								document.getElementById('slicica1_'+id).style.display = "none";
								document.getElementById('slicica2_'+id).style.display = "inline";
								
								document.getElementById('komada_'+id).disabled = "disabled";
								
								document.getElementById('dodano_'+id).innerHTML = "<img src='images/spacer.gif' width='16' height='16' />";
								
							}else{
														
							document.getElementById('dodano_'+id).innerHTML = "<img src='images/dodano.png' title='Proizvod je u košarici' alt='Proizvod je u košarici'/>";
							
							document.getElementById('slicica1_'+id).style.display = "none";
							document.getElementById('slicica2_'+id).style.display = "inline";
							document.getElementById('komada_'+id).disabled = "disabled";
							}
							
							
							kosarica();
						}
						
						
					}
				}	
			}
			
			
			
			
			
			var url="ajax_dod_kos.php"+params;	
			
			
			xmlhttp.open("GET",url,true);
			
		
			xmlhttp.send(null);
	
		
	}
	
	function kosarica(){
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
						writeHTML(xmlhttp,'kosarica')
						
						
					}
				}	
			}
			
			
			var url="ajax_kosarica.php";	
			xmlhttp.open("GET",url,true);
			
		
			xmlhttp.send(null);
	}
	
	
	function izbaci(id,gore){
		
		if(gore){
			document.getElementById('dodano_'+id).innerHTML = "<img src='images/ajax-loader.gif' width='16' height='16' />";
		}else{
			document.getElementById('dodano_'+id).innerHTML = "<img src='images/ajax-loader.gif' width='16' height='16' />";
		}
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
							if(trim(xmlhttp.responseText) == "OK"){
							
								if(gore){
									document.getElementById('slicica1_'+id).style.display = "inline";
									document.getElementById('slicica2_'+id).style.display = "none";
									
									document.getElementById('komada_'+id).value = "1";
									document.getElementById('komada_'+id).disabled = "";
								
								}else{
									document.getElementById('dodano_'+id).innerHTML= "<img src='images/spacer.gif' width='16' height='16' />";
									
									document.getElementById('slicica1_'+id).style.display = "inline";
									document.getElementById('slicica2_'+id).style.display = "none";
									
									document.getElementById('komada_'+id).value = "1";
									document.getElementById('komada_'+id).disabled = "";
								}
							document.getElementById('dodano_'+id).innerHTML = "<img src='images/spacer.gif' width='16' height='16' />";
							kosarica();
							}				
						
					}
				}	
			}
			
			var params="?id="+id+"&k="+new Date().getTime();
			var url="ajax_izb_kos.php"+params;	
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
	}
	
	function izbaci2(id){
			//s pregleda košarice
		
		document.getElementById('loder').style.visibility = "visible";
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						
							sadrzajKosarice()
							
					}
				}	
			}
			
			var params="?id="+id+"&k="+new Date().getTime();
			var url="ajax_izb_kos2.php"+params;	
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
	}
	
	function promjenaKolicine(id){
		document.getElementById('loder').style.visibility = "visible";
		
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
											
						sadrzajKosarice();
					}
				}	
			}
			var komada = document.getElementById('komada_'+id).value;
			
			var params="?id="+id+"&kom="+komada+"&k="+new Date().getTime();
			var url="ajax_pro_kol.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
		
	}
	
	function sadrzajKosarice(){
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					
					if (xmlhttp.status==200){
						writeHTML(xmlhttp,'sadrzajKosarice');
						document.getElementById('loder').style.visibility = "hidden";
						kosarica();
					}
				}	
			}
						
			var params="?k="+new Date().getTime();
			var url="ajax_sadrzajkosarice.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		
	}
	
	function nacinPlacanja(){
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						
						window.location="kosarica.php";
						
					}
				}	
			}
						
			var params="?n= "+document.getElementById('nacin').value+"&d="+new Date().getTime();
			var url="ajax_nacinPlacanja.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		
	}
	
	function dostava(){
		alert(document.getElementById('dostava').value);
		/*xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						
												
					}
				}	
			}
				
				
				
			var params="?n= "+document.getElementById('nacin').value+"&d="+new Date().getTime();
			var url="ajax_dostava.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		*/
	}
	
	function dostava1(){
		
		document.getElementById('loader_dostava').style.visibility = "visible";
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						document.getElementById('loader_dostava').style.visibility = "hidden";
												
					}
				}	
			}
				
				
				
			if(document.getElementById('dostava').checked == true){
						dostava = 1;
					}else{
						dostava = 0;
				}
				
			var params="?dostava="+dostava+"&d="+new Date().getTime();
			var url="ajax_dostava.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
		
	}
	
	function montaza1(){
		
		document.getElementById('loader_montaza').style.visibility = "visible";
		
		xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						document.getElementById('loader_montaza').style.visibility = "hidden";
												
					}
				}	
			}
				
				if(document.getElementById('montaza').checked == true){
						montaza = 1;
					}else{
						montaza = 0;
				}
				
			var params="?montaza="+montaza+"&d="+new Date().getTime();
			var url="ajax_montaza.php"+params;	
			
			xmlhttp.open("GET",url,true);
			xmlhttp.send(null);
	
		
	}
	
	
	////////////// NARUDŽBA 
	function narudzba(){
		document.getElementById('loader_narudzba').style.visibility = "visible";
		
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						    document.getElementById('loader_narudzba').style.visibility = "hidden";
							window.location = "naruceno.php?kej="+xmlhttp.responseText;
					}else{
						alert("Došlo je do pogreške prilikom slanja narudžbe!\n\n\Narudžba nije poslana.")	
					}
				}	
			}
				
				
				
			var params="?komentar="+kodirajKvacice(document.getElementById('komentar').value)+"&d="+new Date().getTime();
			var url="ajax_narudzba.php"+params;	
			
			xmlhttp.open("GET",url,true);
		 	xmlhttp.send(null);
			
			
		}
		
		
		function saljilozinku(){
			
			if(document.getElementById('email').value != ""){
				
				xmlhttp=GetXmlHttpObject();
				//xmlhttp=new XMLHttpRequest();
				xmlhttp.onreadystatechange= function() { 
					if (xmlhttp.readyState==4){
						if (xmlhttp.status==200){
							writeHTML(xmlhttp,'lozinka');
						}else{
							alert("Došlo je do pogreške prilikom slanja lozinke")	
						}
					}	
				}
					
					
					
				var params="?email="+document.getElementById('email').value+"&d="+new Date().getTime();
				var url="ajax_lozinka.php"+params;	
				
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
			
			
			
			}else{
				alert("Upišie e-mail adresu")	;
			}
		
		}
		
		
		function kodirajKvacice(kej){
			
			var vrati = kej;
			
			
			vrati=vrati.replace(/š/g, "itb01");
			vrati=vrati.replace(/đ/g, "itb02");
			vrati=vrati.replace(/č/g, "itb03");
			vrati=vrati.replace(/ć/g, "itb04");
			vrati=vrati.replace(/ž/g, "itb05");
			
			vrati=vrati.replace(/Š/g, "itb06");
			vrati=vrati.replace(/Đ/g, "itb07");
			vrati=vrati.replace(/Č/g, "itb08");
			vrati=vrati.replace(/Ć/g, "itb09");
			vrati=vrati.replace(/Ž/g, "itb10");
			
			return vrati;
		
				
	    }
	function narudzba(){
		document.getElementById('loader_narudzba').style.visibility = "visible";
		
			xmlhttp=GetXmlHttpObject();
			//xmlhttp=new XMLHttpRequest();
			xmlhttp.onreadystatechange= function() { 
				if (xmlhttp.readyState==4){
					if (xmlhttp.status==200){
						    
							if(trim(xmlhttp.responseText)=="NOT OK!"){
								alert("ERROR CODE: 954\nDošlo je do pogreške prilikom slanja narudžbe!\n\n\Narudžba nije poslana.")	
							}else{
								document.getElementById('loader_narudzba').style.visibility = "hidden";
								window.location = "blagajna.php?"+xmlhttp.responseText;
							}
					
					}else{
						alert("ERROR CODE: 961\nDošlo je do pogreške prilikom slanja narudžbe!\n\n\Narudžba nije poslana.")	
					}
				}	
			}
				
				
				
			var params="?komentar="+kodirajKvacice(document.getElementById('komentar').value)+"&d="+new Date().getTime();
			var url="ajax_narudzba.php"+params;	
			
			xmlhttp.open("GET",url,true);
		 	xmlhttp.send(null);
			
			
		}