
var tid_cu;function check_username(xmlhttp)
{if(!xmlhttp)
new Ajax.Request('ajax.php?mode=registracija&f=username&u='+encodeURIComponent($('ja_registracija_username').value),{asynchronous:true,onSuccess:check_username});else
{if(xmlhttp.responseXML.getElementsByTagName('result')[0].hasChildNodes())
document.getElementById('ja_registracija_username').style.background="url('images/input_free.gif') center right no-repeat";else
document.getElementById('ja_registracija_username').style.background="url('images/input_taken.gif') center right no-repeat";}}
function ajax_ja_zaboravljen_login()
{show_loading(1,'soinfo_profil_slanje',32);new Ajax.Request("ajax.php?mode=profil&f=zaboravljen_login&RandomKey="+Math.random()*Date.parse(new Date()),{method:'post',parameters:{username:$('soinfo_profil_pretraga').value,email:$('soinfo_profil_email').value},onComplete:function(xmlhttp){if(xmlhttp.responseXML.getElementsByTagName('result')[0].childNodes.length>0)
{if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='1')
{var bs_div=document.createElement('div');bs_div.style.textAlign="center";bs_div.innerHTML='Vaši login podaci su Vam poslati e-mailom.';clear_popup();popup_title('Zaboravljen login');$('popup_container').appendChild(document.createElement('br'));$('popup_container').appendChild(bs_div);show_popup();}
else if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='0')
{var bs_div=document.createElement('div');bs_div.style.textAlign="center";bs_div.innerHTML='<span class="red">Greška.</span><br />Traženi nalog ne postoji.';clear_popup();popup_title('Zaboravljen login');$('popup_container').appendChild(document.createElement('br'));$('popup_container').appendChild(bs_div);show_popup();}
else
{var bs_div=document.createElement('div');bs_div.style.textAlign="center";bs_div.innerHTML='<span class="red">Greška.</span><br />'+xmlhttp.responseText;clear_popup();popup_title('Zaboravljen login');$('popup_container').appendChild(document.createElement('br'));$('popup_container').appendChild(bs_div);show_popup();}}
hide_loading('soinfo_profil_slanje');}});}
function ajax_ja_profil_update_datum_rodjenja(a)
{show_loading(1,'ja_profil_datum_rodjenja_'+a,15);new Ajax.Request("ajax.php?mode=inplaceedit&f=soinfo_profil_datum_rodjenja&RandomKey="+Math.random()*Date.parse(new Date()),{method:'post',parameters:{d:$('ja_profil_datum_rodjenja_d').value,m:$('ja_profil_datum_rodjenja_m').value,y:$('ja_profil_datum_rodjenja_y').value},onComplete:function(xmlhttp){if(xmlhttp.responseXML.getElementsByTagName('result')[0].childNodes.length>0)
{var d=(xmlhttp.responseXML.getElementsByTagName('d')[0].childNodes.length>0)?xmlhttp.responseXML.getElementsByTagName('d')[0].firstChild.nodeValue:'-';$('ja_profil_datum_rodjenja_d').selectOptionByValue(d);var m=(xmlhttp.responseXML.getElementsByTagName('m')[0].childNodes.length>0)?xmlhttp.responseXML.getElementsByTagName('m')[0].firstChild.nodeValue:'-';$('ja_profil_datum_rodjenja_m').selectOptionByValue(m);var y=(xmlhttp.responseXML.getElementsByTagName('y')[0].childNodes.length>0)?xmlhttp.responseXML.getElementsByTagName('y')[0].firstChild.nodeValue:'-';$('ja_profil_datum_rodjenja_y').selectOptionByValue(y);}
hide_loading('ja_profil_datum_rodjenja_'+a);}});}
function ajax_ja_profil_update_pol()
{show_loading(1,'ja_profil_pol',15);new Ajax.Request("ajax.php?mode=inplaceedit&f=soinfo_profil_pol&RandomKey="+Math.random()*Date.parse(new Date()),{method:'post',parameters:{pol:$('ja_profil_pol').value},onComplete:function(xmlhttp){if(xmlhttp.responseXML.getElementsByTagName('result')[0].childNodes.length>0)
{var pol=xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue;$('ja_profil_pol').selectOptionByValue(pol);}
hide_loading('ja_profil_pol');}});}
function ajax_soinfo_profil_sifra()
{if(($('soinfo_profil_sifra_sifra_1').value!=$('soinfo_profil_sifra_sifra_2').value)||$('soinfo_profil_sifra_sifra_1').value=='')
{new Effect.Shake($('soinfo_profil_sifra_sifra_2'),{distance:10,sync:false});return;}
show_loading(1,'soinfo_profil_sifra_submit',32);new Ajax.Request("ajax.php?mode=profil&f=sifra&RandomKey="+Math.random()*Date.parse(new Date()),{method:'post',parameters:{nova_sifra_1:$('soinfo_profil_sifra_sifra_1').value,nova_sifra_2:$('soinfo_profil_sifra_sifra_2').value},onComplete:function(xmlhttp){var bs_div=document.createElement('div');bs_div.style.textAlign="center";if(xmlhttp.responseXML.getElementsByTagName('result')[0].childNodes.length>0)
{if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='1')
{bs_div.innerHTML='Vaša šifra je uspešno promenjena. Ne zaboravite da pri sledećem loginu koristite novu šifru.';popup_title('Promena šifre');}
else if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='-1')
{bs_div.innerHTML='Upisane šifre nisu jednake. Novu šifru morate upisati dva puta.';popup_title('Promena šifre');setTimeout("show_popup('soinfo_profil_sifra', ''); popup_title('Promena šifre');",5000);}
else if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='-2')
{bs_div.innerHTML='Nova šifra ne može biti prazna.';popup_title('Promena šifre');setTimeout("show_popup('soinfo_profil_sifra', ''); popup_title('Promena šifre');",5000);}}
else
{bs_div.innerHTML='<span class="red">Greška.</span><br /><br />Pokušajte ponovo za par sekundi.';popup_title('Greška');setTimeout("show_popup('soinfo_profil_sifra', ''); popup_title('Promena šifre');",5000);}
clear_popup();$('popup_container').appendChild(document.createElement('br'));$('popup_container').appendChild(bs_div);show_popup();hide_loading('soinfo_profil_sifra_submit');}});}
function ajax_soinfo_profil_remove_account()
{if($('soinfo_profil_remove_account_password').value=='')
{new Effect.Shake($('soinfo_profil_remove_account_password'),{distance:10,sync:false});return;}
show_loading(1,'soinfo_profil_remove_account_submit',32);new Ajax.Request("ajax.php?mode=profil&f=remove_account&RandomKey="+Math.random()*Date.parse(new Date()),{method:'post',parameters:{password:$('soinfo_profil_remove_account_password').value},onComplete:function(xmlhttp){var bs_div=document.createElement('div');bs_div.style.textAlign="center";if(xmlhttp.responseXML.getElementsByTagName('result')[0].childNodes.length>0)
{if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='1')
{bs_div.innerHTML='Vaš nalog je uspešno obrisan. Za nekoliko sekundi bićete prebačeni na naslovnu stranu sajta.';popup_title('Brisanje naloga');setTimeout("window.location = http_host",3000);}
else if(xmlhttp.responseXML.getElementsByTagName('result')[0].firstChild.nodeValue=='-1')
{bs_div.innerHTML='Upisana šifra je pogršena. Pokušajte ponovo.';popup_title('Promena šifre');setTimeout("show_popup('soinfo_profil_remove_account', ''); popup_title('Brisanje naloga');",5000);}}
else
{bs_div.innerHTML='<span class="red">Greška.</span><br /><br />Pokušajte ponovo za par sekundi.';popup_title('Greška');setTimeout("show_popup('soinfo_profil_remove_account', ''); popup_title('Brisanje naloga');",5000);}
clear_popup();$('popup_container').appendChild(document.createElement('br'));$('popup_container').appendChild(bs_div);show_popup();hide_loading('soinfo_profil_remove_account_submit');}});}
