var tmps = '';
function kontrola_login()
{
	if(document.getElementById('login').value=='' || document.getElementById('pass').value=='')
	{
		alert('Nevyplněny všechny údaje!\nMusíš zadat svoji přezdívku a heslo.');
		return false;
	}else
	{
		return true;
	}
}

function kontrola_uploadu()
{
	document.getElementById('pocitadlo').value--;
	document.getElementById('status2').innerHTML='Náhrávám... &nbsp; [ '+document.getElementById('pocitadlo').value+' soubor/y ]';
	if(document.getElementById('pocitadlo').value<1)
	{
		skryj('status2');
		if(document.getElementById('nahravani_ico')) { skryj('nahravani_ico'); }
		return false;
	} else
	{
		return true;
	}
}

function vzkazy_check(id)
{
	if(document.getElementById(id).checked==true)
	{
		document.getElementById('pocet_del').value++;
	} else
	{
		document.getElementById('pocet_del').value--;
	}
}

function typ_hp_nej_prepinac(vybrane,aktiv)
{
	document.getElementById('nej_1').className='';
	document.getElementById('nej_2').className='';
	document.getElementById('nej_3').className='';
	document.getElementById('nej_4').className='';
	document.getElementById('nej_5').className='';
	document.getElementById('nej_'+aktiv).className='active';
	return false;
}

function skryj(idecko)
{
	el=document.getElementById(idecko).style;
	el.display='none';
	return false;
}

function zobraz(idecko)
{
	el=document.getElementById(idecko).style;
	el.display='block';
	return false;
}

function ajax(url,metoda,id,vrat,loading,text)
	{
		var httpRequest;
		if (window.XMLHttpRequest) { httpRequest = new XMLHttpRequest(); if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {} } }
		if (!httpRequest) { alert('Chyba, nemohu vytvořit spojení.'); return false; }
		httpRequest.onreadystatechange = function() { ajaxVysledek(httpRequest,id,vrat,loading); };
		httpRequest.open(metoda, url, true);
		if (metoda=='POST' || metoda=='post') { httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); if(text!='') { url=url.replace("zmena.php?", ""); httpRequest.send(url+'&text='+text); } else {url=url.replace("zmena.php?", ""); httpRequest.send(url);} } else { httpRequest.send(''); }
		// alert('URL: '+url);
		// alert('Posílaný text: '+text);
	}
function ajaxVysledek(httpRequest,id,vrat,loading)
	{
		if (httpRequest.readyState == 1 || httpRequest.readyState == 2 || httpRequest.readyState == 3) {
			if(id!='' && loading!='')
			{
				document.getElementById(id).innerHTML = '<strong>'+loading+'</strong>';
			}
		}
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				// httpRequest.responseText;
				if(id!='' && vrat!='')
				{
					if(vrat!=1)
					{
						// alert('Vrácený text skriptem: '+vrat);
						document.getElementById(id).innerHTML = ajaxNahradZnaky(vrat);
					}
					else {
						// alert('Vrácený (posílaný) text: '+httpRequest.responseText);
						document.getElementById(id).innerHTML = ajaxNahradZnaky(httpRequest.responseText);
					}
				}
			} else {
				if(httpRequest.status!="0" && httpRequest.status!=NULL && httpRequest.status!=0)
				{ alert('['+httpRequest.status+'] Chyba serveru - zkuste to, prosím, později.'); }
				if(vrat==1){
					document.getElementById(id).innerHTML = '<span class=\'red\'>Chyba serveru, opakujte akci později.</span>';
				}
			}
		}
	}
	
function ajaxNahradZnaky(str)
	{
		str=str.replace(/\\'/g,'\'');
		str=str.replace(/\\"/g,'"');
		str=str.replace(/\\\\/g,'\\');
		str=str.replace(/\\0/g,'\0');
		return str;
	}

function hp_nove_strankovani(s)
{
	ajax('zmena.php?id=1&s='+s,'GET','typ_hp_nejnovejsi_str_id',1,'','');document.getElementById('hp_nove_profily_transp').src='/img/loading_transp.gif';document.getElementById('hp_nove_profily_transp').style.width='18px';document.getElementById('hp_nove_profily_transp').style.height='18px';
	return false;
}

function hp_nove_strankovani_viz(s)
{
	ajax('zmena.php?id=24&s2='+s,'GET','typ_hp_nejnovejsi_viz_str_id',1,'','');document.getElementById('hp_nove_profily_transp_2').src='/img/loading_transp.gif';document.getElementById('hp_nove_profily_transp_2').style.width='18px';document.getElementById('hp_nove_profily_transp_2').style.height='18px';
	return false;
}

function hp_nahodne_fotky_strankovani(m)
{
	// alert(m);
	if(m=='d')
		{	for(p=1;p<9;p++){	if(document.getElementById('hp_nove_fotky_strankovani_id_'+p).className=='active') { m=p; m++; }	}	}
	if(m=='p')
		{	for(p=1;p<9;p++){	if(document.getElementById('hp_nove_fotky_strankovani_id_'+p).className=='active') { m=p; m--; }	}	}
	if(m=='dk')
		{	m=8;	}
	if(m=='pk')
		{	m=1;	}
	
	if(m==1) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<span>&laquo;&laquo;</span>			<span>&laquo;</span>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" class=\"active\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\">8</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('d');return false;\">&raquo;</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('dk');return false;\">&raquo;&raquo;</a>"; }
	if(m==8) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('pk');return false;\">&laquo;&laquo;</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('p');return false;\">&laquo;</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\" class=\"active\">8</a>			<span>&raquo;</span>			<span>&raquo;&raquo;</span>"; };
	if(m>1 && m<8) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('pk');return false;\">&laquo;&laquo;</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('p');return false;\">&laquo;</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" class=\"active\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\">8</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('d');return false;\">&raquo;</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('dk');return false;\">&raquo;&raquo;</a>"; }

	for(p=1;p<9;p++){	document.getElementById('hp_nove_fotky_strankovani_id_'+p).className='';	}
	document.getElementById('hp_nove_fotky_strankovani_id_'+m).className='active';

	p_od = ((m-1)*7)+1;
	p_do = (((m-1)*7)+13);
	//alert('od: '+p_od+' | do:'+p_do);
	for(p=1;p<96;p++){	if(document.getElementById('hp_nove_fotky_id_'+p)) {document.getElementById('hp_nove_fotky_id_'+p).style.display='none';}	}
	for(px=p_od;px<p_do;px++){	document.getElementById('hp_nove_fotky_id_'+px).style.display='block';	}
	return false;
	
	/*
	if(m==1) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<span>&laquo;&laquo;</span>			<span>&laquo;</span>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" class=\"active\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\">8</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('d');return false;\">&raquo;</a>			<a href=\"#\" onclick=\"hp_nahodne_fotky_strankovani('dk');return false;\">&raquo;&raquo;</a>"; for(p=1;p<8;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='block';	};	for(p=8;p<57;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='none';	};	document.getElementById('hp_nove_fotky_strankovani_id_1').className='active'; }
		return false;
	if(m>1 && m<8) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('pk');return false;\">&laquo;&laquo;</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('p');return false;\">&laquo;</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\">8</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('d');return false;\">&raquo;</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('dk');return false;\">&raquo;&raquo;</a>";		var od_m=((m-1)*7)+1;	var do_m=((m-1)*7)+8;	for(p=od_m;p<do_m;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='block'; };	for(p=1;p<(od_m);p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='none';	};	for(p=do_m;p<57;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='none';	};	document.getElementById('hp_nove_fotky_strankovani_id_'+m).className='active'; };
		return false;
	if(m==8) 
		{ document.getElementById('typ_hp_fotky_str').innerHTML="<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('pk');return false;\">&laquo;&laquo;</a>			<a href=\"#\" id=\"\" onclick=\"hp_nahodne_fotky_strankovani('p');return false;\">&laquo;</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_1\" onclick=\"hp_nahodne_fotky_strankovani(1);return false;\">1</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_2\" onclick=\"hp_nahodne_fotky_strankovani(2);return false;\">2</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_3\" onclick=\"hp_nahodne_fotky_strankovani(3);return false;\">3</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_4\" onclick=\"hp_nahodne_fotky_strankovani(4);return false;\">4</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_5\" onclick=\"hp_nahodne_fotky_strankovani(5);return false;\">5</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_6\" onclick=\"hp_nahodne_fotky_strankovani(6);return false;\">6</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_7\" onclick=\"hp_nahodne_fotky_strankovani(7);return false;\">7</a>			<a href=\"#\" id=\"hp_nove_fotky_strankovani_id_8\" onclick=\"hp_nahodne_fotky_strankovani(8);return false;\">8</a>			<span>&raquo;</span>			<span>&raquo;&raquo;</span>";	for(p=50;p<57;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='block'; };		for(p=1;p<50;p++){	document.getElementById('hp_nove_fotky_id_'+p).style.display='none';	};	document.getElementById('hp_nove_fotky_strankovani_id_8').className='active'; };
		return false;
	*/
}

function ajax(url,metoda,id,vrat,loading,text)
	{
		var httpRequest;
		if (window.XMLHttpRequest) { httpRequest = new XMLHttpRequest(); if (httpRequest.overrideMimeType) { httpRequest.overrideMimeType('text/xml'); } } else if (window.ActiveXObject) { try { httpRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { httpRequest = new ActiveXObject("Microsoft.XMLHTTP");} catch (e) {} } }
		if (!httpRequest) { alert('Chyba, nemohu vytvořit spojení.'); return false; }
		httpRequest.onreadystatechange = function() { ajaxVysledek(httpRequest,id,vrat,loading); };
		httpRequest.open(metoda, url, true);
		if (metoda=='POST' || metoda=='post') { httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); if(text!='') { url=url.replace("zmena.php?", ""); httpRequest.send(url+'&text='+text); } else {url=url.replace("zmena.php?", ""); httpRequest.send(url);} } else { httpRequest.send(''); }
		// alert('URL: '+url);
		// alert('Posílaný text: '+text);
	}
function ajaxVysledek(httpRequest,id,vrat,loading)
	{
		if (httpRequest.readyState == 1 || httpRequest.readyState == 2 || httpRequest.readyState == 3) {
			if(id!='' && loading!='')
			{
				document.getElementById(id).innerHTML = '<strong>'+loading+'</strong>';
			}
		}
		if (httpRequest.readyState == 4) {
			if (httpRequest.status == 200) {
				// httpRequest.responseText;
				if(id!='' && vrat!='')
				{
					if(vrat!=1)
					{
						// alert('Vrácený text skriptem: '+vrat);
						document.getElementById(id).innerHTML = ajaxNahradZnaky(vrat);
					}
					else {
						// alert('Vrácený (posílaný) text: '+httpRequest.responseText);
						document.getElementById(id).innerHTML = ajaxNahradZnaky(httpRequest.responseText);
					}
				}
			} else {
				if(httpRequest.status!="0" && httpRequest.status!=NULL && httpRequest.status!=0)
				{ alert('['+httpRequest.status+'] Chyba serveru - zkuste to, prosím, později.'); }
				if(vrat==1){
					document.getElementById(id).innerHTML = '<span class=\'red\'>Chyba serveru, opakujte akci později.</span>';
				}
			}
		}
	}
	
function vlozit_citaci(text){
  document.getElementById('zprava').focus();
  document.getElementById('zprava').value = text;
}

function del()
{
  return confirm("Opravdu smazat?");
}
function potvrd(dotaz)
{
  return confirm(dotaz);
}


function randomProfiles(skip)
{	
	var url = "./ajax.query.php";
	
	$.get(url, { skip : skip },
  
  function(data)
  {
		$("#random-profiles").hide();
		$("#random-profiles").html(data);
		$("#random-profiles").fadeIn(1000);
  });
}

function userActivity()
{	
	var url = "./ajax.query.php";
	
	$.get(url, { 'action' : 'news' },
  
  function(data)
  {
		$("#hp-box").html(data);
  });
}

function userProfileActivity()
{	
	var url = "../ajax.query.php";
	
	$.get(url, { 'action' : 'news', 'profile' : 'true' },
  
  function(data)
  {
		$("#action-box").html(data);
  });
}

function closeInfoBox()
{
	$("#infobox").hide();
	$.cookie('close_infobox', 'true');
}

function odectiVterinu()
{
	var cVal = parseInt($("#sendTimeout").text());
	cVal--;
	if(cVal == 0)
		$("#timeoutInfo").hide();
	else
		$("#sendTimeout").text(cVal);
}