  var http_request = false;
 var PATH = 'http://www.exyuguide.de/ajax/';
 var PATH1 = 'http://www.exyuguide.de/';
   function goajax(url, parameters, g) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } 
	  else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
     
	
	  if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = function() 
		  {
	document.getElementById('box_'+g).innerHTML = '<img src="http://www.exyuguide.de/images/indicator.gif" />';         
      if (http_request.readyState == '4') {
         if (http_request.status == '200') {
 
 
			result = http_request.responseText;
	document.getElementById('box_'+g).innerHTML = result;         
		 } 
		 else {
            alert('Pojavio se problem ha zahtevom.');
         }
      }
   }
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }


	function profil_add_friend(USER) {goajax(PATH+'izmena_profila.php', "add_friend=" + USER, '2');}
	function ShowAreaCity() {goajax(PATH+'dgd_ajax.php', "ShowAreaCity_=" + document.getElementById("area").value, 'oglas_mesto');}


   function nograd(ID) {if(document.getElementById("lokacijaid").value=="0"){document.getElementById('t'+ ID).style.display = "";}else{document.getElementById('t'+ ID).style.display = "none";}}

   function objekatLIST(id) {goajax(PATH+'dgd_ajax.php', "podkategorija_obj=" + encodeURI( document.getElementById("tip_lokala_ajax").value ), 'subcat');}
//   function get(obj) { makePOSTRequest('./doc_ajax.php', "tip_lokala_ajax=" + encodeURI( document.getElementById("tip_lokala_ajax").value ));}
   function brisanje_oglasa(id) {goajax(PATH+'brisanje_oglasa.php', "oglas=" +  id, '1');}
   function izmena_oglasa(id) {goajax(PATH+'brisanje_oglasa.php', "izmenaoglasa=" +  id, '1');}
   function izmena_lozinke(ID) {goajax(PATH+'dgd_ajax.php', "nova_lozinka=" +  ID, '2');}
   function brisanje_ob_kom(id, user) {goajax(PATH+'objekat.php', "komentar_id=" +  id + " " + user, 'comment_'+id);}
   function izmena_komentara(id) {goajax(PATH+'brisanje_oglasa.php', "edit_komentar_id=" +  id, '1');}
   function pps(id) {makeSENDRequest(PATH+'set_ajax.php', "prikaz_po_strani=" + encodeURI( document.getElementById("ppss").value));}
   function brisanje_dogadjaja(id) {goajax(PATH+'desavanja.php', "del_dogadjaj=" +  id, '1');}
   function izmena_dogadjaja(id) {goajax(PATH+'brisanje_oglasa.php', "izmenadogadjaja=" +  id, '1');}
   function lost_pass(ID) {goajax(PATH+'brisanje_oglasa.php', "lost_pass=" +  ID, '1');}
   function adminAjax(ID) {goajax(PATH+'admin_ajax.php', "adminid=" +  ID, '1');}
   function SendadminAjax(IDs) {goajax(PATH+'admin_ajax.php', "adizmene=" +  encodeURI( document.getElementById("adizmene").value) + " " + IDs, '1');}
   function Komentari(ID) {goajax(PATH+'dgd_ajax.php', "komentari=" +  ID, '1');}
   function KomentarDodaj(ID) {goajax(PATH+'dgd_ajax.php', "komentardodaj=" +  ID, '1');}
   function GreskaTekst(ID) {goajax(PATH+'dgd_ajax.php', "greskautekstu=" +  ID, '1');}
   function SubmitError(ID) {goajax(PATH+'dgd_ajax.php', "greskaposalji=" +  ID + "|||" + encodeURI( document.getElementById("km_ime").value)  + "|||" + encodeURI( document.getElementById("km_email").value)  + "|||" + encodeURI( document.getElementById("km_komentar").value), '1');}
   //function stampaj(ID) {goajax(PATH+'dgd_ajax.php', "stampaj=" +  ID);}
   function SubmitComent(ID) {
   if (document.getElementById('km_komentar').value.length < '6') {document.getElementById('alertkom').style.color = "#ff0000"; return false;}
	   goajax(PATH+'desavanja.php', "komentarobjavi=" +  ID + "|||" + encodeURI( document.getElementById("km_komentar").value), '1');
   }
   function brisanje_komentara(ID, user_id) {goajax(PATH+'dgd_ajax.php', "komentarbrisi=" +  ID + "-" + user_id); document.getElementById("kmnt"+ID).style.display = 'none';}
   function sacuvaj(ID, userid, textareaid, tag) {goajax(PATH+'dgd_ajax.php', "saved=" +  ID + "|||" + userid + "|||" + encodeURI( document.getElementById(textareaid).value), tag);}
   function cct(usernick) {goajax(PATH+'dgd_ajax.php', "undosaved=" +  usernick, '1');}

   function LokalCmd(ID) {goajax(PATH+'dgd_ajax.php', "lokal_cmd=" +  ID, '2');}
   function LokalCmds(ID) {
	   if (document.getElementById('komentar').value.length < '6') {document.getElementById('alertkom').style.color = "#ff0000"; return false;}
goajax(PATH+'dgd_ajax.php', "lokal_cmd_send=" +  ID + "|||" + encodeURI( document.getElementById("ime").value) + "|||" + encodeURI( document.getElementById("ocena_usluga").value) + "|||" + encodeURI( document.getElementById("ocena_cena").value) + "|||" + encodeURI( document.getElementById("komentar").value), '2');}

   function add_vote(ID) {goajax(PATH+'dgd_ajax.php', "add_votes=" +  ID, '2');}
   function add_vote_send(ID) {goajax(PATH+'dgd_ajax.php', "add_votes_send=" +  encodeURI( document.getElementById("vote_id").value) + "|||" + encodeURI( document.getElementById("naslov").value) + "|||" + encodeURI( document.getElementById("opcija").value), '2'); document.getElementById("opcija").value = '';}
   function remove_vote_send(ID) {goajax(PATH+'dgd_ajax.php', "remove_votes_send="+  encodeURI( document.getElementById("remove_vote").value), '2');}
   var voteid='0';
   function user_vd(ID) {voteid = ID; return voteid;}
   function user_vote(ID, ids) {goajax(PATH+'dgd_ajax.php', "user_votes=" + ID + " " + ids, '1');}
   function uvrm(ID) {goajax(PATH+'dgd_ajax.php', "user_votes_remove=" + ID, '1');}
  
   function user_view_vote(ID) {goajax(PATH+'dgd_ajax.php', "user_view_votes=" + ID, '1');}
   function kreirajIframe(ID) {goajax(PATH+'dgd_ajax.php', "kreirajIframe=" + ID + "|||" + encodeURI( document.getElementById("sirina").value) + "|||" + encodeURI( document.getElementById("pozadina").value) + "|||" + encodeURI( document.getElementById("slova").value) + "|||" + encodeURI( document.getElementById("naslovbg").value), '2');}
//   function viewIframe(ID) {goajax(PATH+'dgd_ajax.php', "viewIframes=" + ID + "|||" + encodeURI( document.getElementById("sirina").value) + "|||" + encodeURI( document.getElementById("pozadina").value) + "|||" + encodeURI( document.getElementById("slova").value) + "|||" + encodeURI( document.getElementById("naslovbg").value), '2');}

   function ListajVest(ID) {goajax(PATH+'dgd_ajax.php', "prethodna_vest=" + ID, '2');}
   function statusLF(ID) {goajax(PATH+'dgd_ajax.php', "status_l_f=" + ID, '1');}

   function Obrisi_sliku(slika) {goajax(PATH+'brisanje_oglasa.php', "obrisi_sliku2=" +  slika, '2');}


// ***********************************************************
// administracija profila
// ***********************************************************


function profil_izmeni_opis() {document.getElementById('form_opis').style.display = "";}
function profil_izmeni_info() {document.getElementById('form_info').style.display = "";}
function profil_dodaj_sliku() {document.getElementById('form_slika').style.display = "";}
function profil_izmeni_podatke() {document.getElementById('form_podaci').style.display = "";}
function profil_izmeni_notifikaciju() {document.getElementById('obavestenja_korisnika').style.display = "";}
function profil_add_friend(USER) {goajax(PATH+'izmena_profila.php', "add_friend=" + USER, '2'); document.getElementById('friendurl').innerHTML = 'Zahtev je poslat';}
function profil_remove_friend(USER) {goajax(PATH+'izmena_profila.php', "remove_friend=" + USER, '2'); document.getElementById('friendurl').innerHTML = 'Zahtev je obrisan';}
function profil_accept_friend(USER) {goajax(PATH+'izmena_profila.php', "accept_friend=" + USER, '2'); document.getElementById('friendurl').innerHTML = 'Zahtev je prihvacen';}
function profil_decline_friend(USER) {goajax(PATH+'izmena_profila.php', "decl_friend=" + USER, '2'); document.getElementById('friendurl').innerHTML = 'Zahtev je odbijen';}
function profil_add_pp(ID) {document.getElementById('box_2').innerHTML = '<form name="pp" method="post" action="'+PATH1+'/panel/inbox/#new">Naslov poruke<br /><input type="hidden" name="pp_profil_b"value="'+ID+'" /><input type="text" name="pp_naslov"  style="font-size:11px; width:100%;" /><br />Tekst poruke<br /><textarea name="pp_tekst" style="width:100%;" rows="6"></textarea><br /><input type="submit" name="pp" value="Po&scaron;alji"  style="font-size:11px;" /></form>';}
function invite_frend() {document.getElementById('invite').innerHTML = '<form name="invite"  method="post" action=""> Email prijatelja:<br /><input type="text" name="invite_mail" /> <br />Izgled poruke:<br /><textarea name="invite_tekst" rows="16" disabled>Zdravo\n\n(tvoje ime) te poziva da se registruje&scaron; i kreira&scaron; profil na sajtu www.exyuguide.de \n\nEx YU guide je mesto gde se okupljaju svi oni koji su &#382;eljni dobrog provoda, novih de&scaron;avanja, izlazaka. Gde mo&#382;e&scaron; razmenjivati iskustva i preporuke restorana, kafi&#263;a i drugih mesta. Kao i obave&scaron;tavati druge o aktuelnim de&scaron;avanjima u tvojoj okolini: &#382;urkama, festivalima, svirkama, koncertima...\n\nMoj profil je '+PATH1+'/profile/(ime profila) \n </textarea><br /><input type="submit" name="Submit" value="Posalji poruku prijatelju" /></form>';}
function profil_privatne_poruke(ID) {goajax(PATH+'profile_ajax.php', "profil_pp=" + ID, '2');}
function profil_read_in_poruke(ID) {goajax(PATH+'profile_ajax.php', "profil_read_in_pp=" + ID, '2');}
function profil_read_out_poruke(ID) {goajax(PATH+'profile_ajax.php', "profil_read_out_pp=" + ID, '2');}
function profil_delete_poruke(ID) {goajax(PATH+'profile_ajax.php', "profil_delete_pp=" + ID); document.getElementById('msgs' + ID).innerHTML = '<div style="text-align: center; padding: 5px; margin: auto; width: 300px; border: 1px solid red;"> Poruka je obrisana.</div>';}
function profil_izmena_objekta(ID) {goajax(PATH+'profile_ajax.php', "profil_edit_objekat=" + ID, '1');}
function preporuka_ocena_dobra(ID, VOT) {goajax(PATH+'objekat.php', "preporuka_vote_up=" + ID); document.getElementById('pd_ocena' + ID).innerHTML = "(" + (VOT + 1) + ") <img src=\""+PATH1+"/images/thumb_up.png\" alt=\"\" style=\"margin-bottom: -4px;\" />";}
function preporuka_ocena_losa(ID, VOT) {goajax(PATH+'objekat.php', "preporuka_vote_down=" + ID); document.getElementById('pl_ocena' + ID).innerHTML = "(" + (VOT + 1) + ") <img src=\"http://localhost/povedime/images/thumb_down.png\" alt=\"\" style=\"margin-bottom: -4px;\" />";}
function profil_odgovor_pp(ID) {goajax(PATH+'profile_ajax.php', "profil_reply_pp=" + ID, '2');}
function profil_nova_poruka(ID) {goajax(PATH+'profile_ajax.php', "profil_new_pp=" + ID, '2');}
function submit_provera() {
	if (document.getElementById('lokacijaid').value == "-") {document.getElementById('ml').style.color = "#ff0000"; document.getElementById('alert').innerHTML = 'Odaberi lokaciju'; return false;}
	if (document.getElementById('nlv').value.length < '3') {document.getElementById('nl').style.color = "#ff0000"; document.getElementById('alert').innerHTML = 'Upi&scaron;i naziv lokala'; return false;}
	if (document.getElementById('tip_lokala_ajax').value == '0') {document.getElementById('tl').style.color = "#ff0000"; document.getElementById('alert').innerHTML = 'Odaberi tip lokala'; return false;}
 }

function profil_MSGS_provera() {
	if (document.getElementById('gpr').value == "") {alert('Odaberi prvo primaoca iz liste prijatelja'); return false;}
	if (document.getElementById('gtxt').value.length < '3') {alert('Unesi tekst poruke'); return false;}
	return true;
 }

function dodatne_opcije() {document.getElementById('ekstra_polja').style.display = "";}



function DodajOmiljen(ID) {goajax(PATH+'objekat.php', "Dodaj_u_Omiljen=" + ID, 'omiljen'); 
}


function ObrisiOmiljen(ID) {
	goajax(PATH+'objekat.php', "Obrisi_iz_Omiljenih=" + ID); 
	document.getElementById('omiljen'+ID).innerHTML = '<td colspan="4" style="text-align: center; padding: 5px; color: red;"> Objekat je obrisan iz favorita.</td>';
}

function ShowFriendRequestPanel() {
	if(document.getElementById('friends').style.display == "none") {
	document.getElementById('friends').style.display = "";
	}else{document.getElementById('friends').style.display = "none";}

}
 

function DelCom(ID) {
	goajax(PATH+'desavanja.php', "DelCom_=" + ID); 
	document.getElementById('com'+ID).innerHTML = '<div style="text-align: center; padding: 5px; color: red;"> Komentar je obrisan.</div>';

}




function IzmeniOpis() {goajax(PATH+'izmena_profila.php', "IzmeniOpis_=" +  document.getElementById("EditOpisTekst").value, 'EditOpis');}
function DodajComentar0(profil) {goajax(PATH+'izmena_profila.php', "DodajComentar_=" + profil + "|||" + document.getElementById("DodajComentarText").value, 'DodajComentar');}
 function ObrisiComentar0(cmnt) {


	   if(document.getElementById('box_DodajComentar').style.display == 'none') {
		   document.getElementById('box_DodajComentar').style.display = ''; 
}else{
	document.getElementById('box_DodajComentar').style.display = 'none';
}
	document.getElementById('cmnt'+cmnt).style.display = 'none';

	   goajax(PATH+'izmena_profila.php', "ObrisiComentar_=" + cmnt, 'DodajComentar');}

