function getObj() {
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest(); } catch (e) {
		try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
	return xmlHttp;
}
function getCookie(c_name) {
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1) { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	  } 
	}
	return "";
}
function addFriends(a,b,c) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","../z_do_sendfriendrequest.php?sender="+a+"&receiver="+b+"&secret="+c,true);
	xmlHttp.send(null);
	return true;
}
function blockFriends(a,b) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","../z_do_sendblockrequest.php?sender="+a+"&receiver="+b,true);
	xmlHttp.send(null);
	return true;
}
function vote(a,b) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","../../z_do_vote.php?itemid="+a+"&vote="+b,true);
	xmlHttp.send(null);
	return true;
}
function voteprofile(a,b) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","../../z_do_voteprofile.php?username="+a+"&vote="+b,true);
	xmlHttp.send(null);
	return true;
}
function forumVisibility(id,forum,val) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) var t=xmlHttp.responseText;
	}
	xmlHttp.open("GET","../../z_do_f.php?id="+id+"&forum="+forum+"&toset="+val,true);
	xmlHttp.send(null);
	return true;
}

function checkMonth() {
	var dan=parseInt(document.getElementById('op_r_d').value);
	var mesec=parseInt(document.getElementById('op_r_m').value);
	var godina=parseInt(document.getElementById('op_r_g').value);
	if (dan==0 || mesec==0 || godina==0) return;
	if ((mesec==4 || mesec==6 || mesec==9 || mesec==11) && dan==31) document.getElementById('op_r_d').value='30';
	var prestupna=(godina % 4);
	if (mesec==2 && dan>28 && prestupna!=0) document.getElementById('op_r_d').value='28';
	if (mesec==2 && dan>29 && prestupna==0) document.getElementById('op_r_d').value='29';
	return true;
}
function forumOpenClose(a,b) {
	var blok=document.getElementById('f'+a);
	var icon=document.getElementById('i'+a);
	var toSet="0";
	if (blok.style.display=="none") {
		blok.style.display="block";
		icon.src="http://my.zoki.com/images/fminus.gif";
		toSet="1";
	} else {
		blok.style.display="none";
		icon.src="http://my.zoki.com/images/fplus.gif";
		toSet="0";
	}
	var t=forumVisibility(b,a,toSet);
}
function areyousure(a,b) {
	var t=window.confirm(a);
	if (t) document.location=b;
}
function callFriends(a,b) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			var v=t.split(",");
			alert(v[1]);
			var url='http://my.zoki.com/z_pvtchatwait.php?id='+v[0];
			var wo=window.open(url,v[0]+"",'width=510,height=430,left=0,top=0,menubar=No,toolbar=No,scrollbars=No,status=No,resizable=Yes,location=No'); 
			wo.focus();
		}
	}
	xmlHttp.open("GET","http://my.zoki.com/z_do_sendpvtrequest.php?sender="+a+"&receiver="+b,true);
	xmlHttp.send(null);
	return true;
}
function acceptingChat(a,b,c) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			if (a==1) {
				var url='http://my.zoki.com/z_pvtchat.php?id='+c;
				var wo=window.open(url,c+"",'width=510,height=430,left=0,top=0,menubar=No,toolbar=No,scrollbars=No,status=No,resizable=Yes,location=No'); 
				wo.focus();
				document.getElementById('zivpo').innerHTML="Poziv privacen.";
			}	else {
				document.getElementById('zivpo').innerHTML="Poziv odbijen.";
			}			
		}
	}
	xmlHttp.open("GET","http://my.zoki.com/z_do_acceptchat.php?value="+a+"&id="+b+"&cid="+c,true);
	xmlHttp.send(null);
	return true;
}
function groupjoinrequest(a) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","http://my.zoki.com/z_do_groupjoinrequest.php?id="+a,true);
	xmlHttp.send(null);
	return true;
}
function groupInvite(grpid,logid,member) {
	var xmlHttp=getObj();
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var t=xmlHttp.responseText;
			alert(t);
		}
	}
	xmlHttp.open("GET","http://my.zoki.com/z_do_groupinvitemembers.php?grpid="+grpid+"&userid="+logid+"&member="+member,true);
	xmlHttp.send(null);
	return true;
}
function swappa(a) {
	var u="bimvzLqpj";
	for (var i=0;i<9;i++) {
		document.getElementById('show'+u.charAt(i)).style.display='none';
	}
	document.getElementById('show'+a).style.display='block';
}
function startProgress(uid) {
  document.getElementById('mp3_new').style.display = 'none';
  document.getElementById('pb_outer').style.display = 'block';
  setTimeout('getProgress("' + uid + '")', 1500);
}
function getProgress(uid) {
	HttpRequestObject=getObj();
	if(HttpRequestObject) {
		HttpRequestObject.open('GET', 'http://my.zoki.com/getprogress.php?uid=' + uid, true);
		HttpRequestObject.onreadystatechange = function() {
			if(HttpRequestObject.readyState == 4 && HttpRequestObject.status == 200) {
				var prog = HttpRequestObject.responseText;
				var pr=prog.split("#");
				var progress=pr[0];
				var bps=pr[1];
				document.getElementById('pb_outer').innerHTML = "Uploading: "+progress + "% <span>(Time left: "+bps + ")</span>";
				if(progress < 100) {
					setTimeout('getProgress("' + uid + '")', 2000);
				} else {
					document.getElementById('pb_outer').style.display='none';
				}
			}
		}
		HttpRequestObject.send(null);
	}
}
function javaShowHide(a,b,c) {
	if (document.getElementById('div'+a).style.display=="none") {
		document.getElementById('div'+a).style.display="block";
		document.getElementById('span'+a).innerHTML='<a href="javascript:void(0);" onclick="javaShowHide(\''+a+'\',\''+b+'\',\''+c+'\');">'+c+'</a>';
	} else {
		document.getElementById('div'+a).style.display="none";
		document.getElementById('span'+a).innerHTML='<a href="javascript:void(0);" onclick="javaShowHide(\''+a+'\',\''+b+'\',\''+c+'\');">'+b+'</a>';
	}
}
