function badge(kdo,game,badge)
{
	var xmlHttp;
	var data;
	try {
		xmlHttp=new XMLHttpRequest();  
	}
	  
	catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
		    try {
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {
				alert("Váš prohlížeč nepodporuje AJAX");
				return false;
			}   
		}  
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var x=document.getElementById("badges");
			x.innerHTML = xmlHttp.responseText;
		}
	}
	data = kdo+"@"+game+"@"+badge;
	xmlHttp.open("GET","/badge.php?data="+data,true);
	xmlHttp.send(null); 
  
}

function ajaxFunction()
{
	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("Váš prohlížeč nepodporuje AJAX");
				return false;
			}   
		}  
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var x=document.getElementById("autochat");
			x.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","/chatbox.php",true);
	xmlHttp.send(null); 
  
}

function obrBanner(id)
{
	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("Váš prohlížeč nepodporuje AJAX");
				return false;
			}   
		}  
	}
	xmlHttp.onreadystatechange=function() {
		if(xmlHttp.readyState==4) {
			var x=document.getElementById("obrbanner");
			x.innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET","/obrbanner.php?id="+id,true);
	xmlHttp.send(null); 
  
}

function runTimer() {
	window.setInterval("ajaxFunction()", 10000);	//tady se nastaví interval ve kterém se bude reloadovat stránka... 1000 = 1 sekunda
}

function vlozTag(tag)
{
switch (tag)
	{
	default:	vlozNaKurzor(' '+tag+' ',false,''); break;
	}
}

function vlozTag2(tag)
{
switch (tag)
	{
	default:	vlozNaKurzor2(' '+tag+' ',false,''); break;
	}
}

function vlozNaKurzor(text_pred, text_puvodni, text_za)
{
var textarea   = document.formkom.komentar;

if (typeof textarea.selectionStart != 'undefined')		// www Moz
	{
	var zacatek    = textarea.selectionStart;
	var konec      = textarea.selectionEnd;
	var text_stred = (text_puvodni) ? textarea.value.substring(zacatek, konec) : '';
	text_stred     = text_pred + text_stred + text_za;
	textarea.focus();
	textarea.value = textarea.value.substr(0,zacatek) + text_stred + textarea.value.substr(konec);
	textarea.selectionStart = zacatek + text_stred.length;	// nastav kurzor za vlozeny text
	textarea.selectionEnd   = zacatek + text_stred.length;
	}
else if (typeof document.selection != 'undefined')		// www IE
	{
	var text_stred = (text_puvodni) ? document.selection.createRange().text : '';
	text_stred     = text_pred + text_stred + text_za;
	textarea.focus();
	var oznaceni   = document.selection.createRange();
	oznaceni.text  = text_stred;
	oznaceni.select();					// nastav kurzor za vlozeny text
	}
else	{							// www ostatni
	var text_stred  = text_pred + text_za;
	textarea.focus();
	textarea.value += text_stred;				// pridej na konec
	}
}

function vlozNaKurzor2(text_pred, text_puvodni, text_za)
{
var textarea   = document.formkom.zvatlanec;

if (typeof textarea.selectionStart != 'undefined')		// www Moz
	{
	var zacatek    = textarea.selectionStart;
	var konec      = textarea.selectionEnd;
	var text_stred = (text_puvodni) ? textarea.value.substring(zacatek, konec) : '';
	text_stred     = text_pred + text_stred + text_za;
	textarea.focus();
	textarea.value = textarea.value.substr(0,zacatek) + text_stred + textarea.value.substr(konec);
	textarea.selectionStart = zacatek + text_stred.length;	// nastav kurzor za vlozeny text
	textarea.selectionEnd   = zacatek + text_stred.length;
	}
else if (typeof document.selection != 'undefined')		// www IE
	{
	var text_stred = (text_puvodni) ? document.selection.createRange().text : '';
	text_stred     = text_pred + text_stred + text_za;
	textarea.focus();
	var oznaceni   = document.selection.createRange();
	oznaceni.text  = text_stred;
	oznaceni.select();					// nastav kurzor za vlozeny text
	}
else	{							// www ostatni
	var text_stred  = text_pred + text_za;
	textarea.focus();
	textarea.value += text_stred;				// pridej na konec
	}
}

function forums(id,subid)
{
     var url = "/phor.php?idecko="+id;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(10,"diskuse_"+id+"_"+subid); } ;
        httpRequest.send(null);
      }
      else
      {

       document.getElementById("diskuse_"+id+"_"+subid).innerHTML = "Nahr&aacute;v&aacute;m data ....";
 
      }
}

function zobrazFormik2(id)
{
     var url = "/newtheme.php?idecko="+id;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(9,0); } ;
        httpRequest.send(null);
      }
      else
      {

       document.getElementById("zobrazFormik2").innerHTML = "";
 
      }
}

function zobrazFormik(id)
{
     var url = "/ohraniform.php?idecko="+id;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(8,0); } ;
        httpRequest.send(null);
      }
      else
      {

       document.getElementById("zobrazFormik").innerHTML = "";
 
      }
}

function quickClanek(kam)
{
     var url = "/arts.php?kam="+kam;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(7,kam); } ;
        httpRequest.send(null);
      }
      else
      {

        document.getElementById("quickClanky").innerHTML = "Nahr&aacute;v&aacute;m data ....";
 
      }
}



function quickMenu(id)
{
     var url = "/newsky.php?idecko="+id;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        httpRequest.onreadystatechange= function () {processRequest(3,0); } ;
        httpRequest.send(null);
      }
      else
      {

        document.getElementById("quickMenu").innerHTML = "";
        
      }
}

function vyberClanek(id,ids,cif)
{
     var url = "/seznam.php?id="+ids+"&strana="+id+"&cifra="+cif;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("GET", url, true);
        
        httpRequest.onreadystatechange= function () {processRequest(1,0); } ;
        httpRequest.send(null);
      }
      else
      {

        document.getElementById("mistoZobrazeni2").innerHTML = "";
        
      }
}

function zapisZaznam(co)
{
     var url = "/chatbox.php?obsah="+ document.getElementById("zvatlanec").value+"&co="+co;

     if (url != 0)
     {
        if (window.ActiveXObject)
        {
          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        {
          httpRequest = new XMLHttpRequest();
        }
        httpRequest.open("POST", url, true);
        httpRequest.onreadystatechange= function () {processRequest(2,0); } ;
 		httpRequest.setRequestHeader("Content-Type", "text/html; charset=utf-8");
        httpRequest.send(null);
      }
      else
      {

        document.getElementById("vykriky").innerHTML = "";
        
      }
}

function processRequest(id,dal)
{
  if (httpRequest.readyState == 4)
  {
    if(httpRequest.status == 200)
    {
     if (id==1) var mistoZobrazeni = document.getElementById("mistoZobrazeni2");
     if (id==2) var mistoZobrazeni = document.getElementById("vykriky");
     if (id==3) var mistoZobrazeni = document.getElementById("quickMenu");
     if (id==4) var mistoZobrazeni = document.getElementById("seznamher");
     if (id==5) var mistoZobrazeni = document.getElementById("bigscreen");
     if (id==6) var kam = "bigshot["+dal+"]";
     if (id==6) var mistoZobrazeni = document.getElementById(kam);
     if (id==7) var mistoZobrazeni = document.getElementById("quickClanky");
	 if (id==8) var mistoZobrazeni = document.getElementById("zobrazFormik");     
	 if (id==9) var mistoZobrazeni = document.getElementById("zobrazFormik2");
	 if (id==10) var mistoZobrazeni=document.getElementById(dal);
     mistoZobrazeni.innerHTML = "";
     if (id==2) document.getElementById("zvatlanec").value = "";
	 if (id==10) document.getElementById(dal).value="Nahr&aacute;v&aacute;m data ...";
      mistoZobrazeni.innerHTML = httpRequest.responseText;

    }
    else
    {
        alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
    }
  }
}

function registr(formular)	{
 	if (formular.usname.value=="")
	    {
	        alert("Vyplňte prosím přihlašovací jméno!");
	        formular.usname.focus();
	        return false;
	    }
		else if (formular.psw.value=="")
	    {
	        alert("Vyplňte prosím heslo!");
	        formular.psw.focus();
	        return false;
	    }
		else if (formular.psw2.value=="")
	    {
	        alert("Vyplňte prosím heslo pro ověření");
	        formular.psw2.focus();
	        return false;
	    }
	    else if (formular.psw.value != formular.psw2.value)
	    {
	    	alert("Nebyla nalezena shoda hesel!");
	    	formular.psw2.value="";
	    	formular.psw2.focus();
	    	return false;
	    }
		else if (formular.jmeno.value=="")
	    {
	        alert("Vyplňte prosím Vaše jméno!");
	        formular.jmeno.focus();
	        return false;
	    }
		else if (formular.prijmeni.value=="")
	    {
	        alert("Vyplňte prosím Vaše příjmení!");
	        formular.prijmeni.focus();
	        return false;
	    }

	    else if (formular.email.value=="")
	    {
	        alert("Vyplňte prosím adresu elektronické pošty!");
	        formular.email.focus();
	        return false;
	    }
	    else if (window.RegExp)
	    {
	        re = new RegExp("^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$");
	        if (!re.test(formular.email.value))
	        {
	            alert("Zadaná adresa není správnou adresou elektronické pošty!");
	            formular.email.focus();
       		    return false;
	        }
			} 
			    else 
			        return true;
			}

	

