// JavaScript Document

	  function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function kontrola() {

mail = document.getElementById('zprava_mail').value;
mail1 = document.getElementById('zprava_mail');
vzkaz = document.getElementById('zprava').value;
vzkaz1 = document.getElementById('zprava');


if (vzkaz == "" && typ != 1) {
alert("Napište, prosím, nejdříve vzkaz... :)");
vzkaz1.focus();
return false;
}


else if (mail != "") {
if (window.RegExp)
{
re = new RegExp("^[^@]+@[^.]+\..+$");
if (!re.test(mail))
{
return confirm("Nevložili jste správnou mailovou adresu, nebudeme Vám moci odpovědět.\nChcete opravdu zprávu bez kontaktu odeslat?");
mail1.focus();
return false;
}
}
}



else
return true;
}


function kontrola2() {

mail = document.getElementById('novinky_mail').value;
mail1 = document.getElementById('novinky_mail');


if (mail != "") {
if (window.RegExp)
{
re = new RegExp("^[^@]+@[^.]+\..+$");
if (!re.test(mail))
{
alert("Napište, prosím, správnou mailovou adresu.");
mail1.focus();
return false;
}
}
}



else
return true;
}




/* Špičkový kód převzatý z play.cz pro otevření přehrávače jen jednou za hodinu napsal LJ
Připomínky, děkovné dopisy a gratulace směřujte na lukas zavináč vsevjednom.cz
Nebo čekujte můj web djlj.net */

function PlayRadio(bitrate,cesta) {

if((document.cookie.indexOf("player") == -1 && cesta=='/') || cesta!='/'){
window.open('http://www.freeradio.cz/web-player/' + bitrate + '', 'playradio', 'width=500,height=675,top='+((screen.availHeight-600)/2)+',left='+((screen.availWidth-500)/2)+',status=0,scrollbar=0');

var futdate = new Date();		//Get the current time and date
var expdate = futdate.getTime();  //Get the milliseconds since Jan 1, 1970
expdate += 3600*1000;  //expires in 1 hour(milliseconds)
futdate.setTime(expdate);

document.cookie="player=1; expires=" + futdate.toGMTString()+";";

window.focus();

}

}

function PlayStream(bitrate) {
window.open('http://www.freeradio.cz/web-player/' + bitrate + '', 'playstream', 'width=500,height=675,top='+((screen.availHeight-600)/2)+',left='+((screen.availWidth-500)/2)+',status=0,scrollbar=0');
var futdate = new Date();		//Get the current time and date
var expdate = futdate.getTime();  //Get the milliseconds since Jan 1, 1970
expdate += 3600*1000;  //expires in 1 hour(milliseconds)
futdate.setTime(expdate);

document.cookie="player=1; expires=" + futdate.toGMTString()+";";

window.focus();

}







/* Špičkový ajax kód pro posílání a vypisování vzkazů v chatu napsal LJ
Připomínky, děkovné dopisy a gratulace směřujte na lukas zavináč vsevjednom.cz
Pokud potebujete vytvořit netradiční, ale špičkový webový soft, nebojte se mě kontaktovat taky
Nebo čekujte můj web djlj.net */




function NatahniVzkazy(kam,pocet){

PosliDotaz('nactizpravy='+pocet+'&kam='+kam+'&blbost='+parseInt(new Date().getTime().toString().substring(0, 10)),kam);

}


function ZobrazUzivatele(kam){

PosliDotaz('zobrazuzivatele='+kam,kam);

}



function Login(){

if(document.getElementById("login").value==''){
alert('Vyplňte přezdívku');
document.getElementById("login").focus();
return false;
}

else if(document.getElementById("heslo").value==''){
alert('Vyplňte heslo');
document.getElementById("heslo").focus();
return false;
}



PosliDotaz('lognime='+document.getElementById("login").value+'&heslo='+document.getElementById("heslo").value, 'login');


}



function Logout(){

PosliDotaz('logout=1', 'logout');


}

function VlozJmeno(jmeno){

document.getElementById("chat_zprava").value=document.getElementById("chat_zprava").value + jmeno + ': ';
document.getElementById("chat_zprava").focus();

}

function UlozZpravu(){

if(document.getElementById("chat_zprava").value==''){
alert('Vyplňte zprávu');
document.getElementById("chat_zprava").focus();
return false;
}


PosliDotaz('zprava='+document.getElementById("chat_zprava").value);


}



function SmazZpravu(id){

PosliDotaz('smazzpravu='+id,'smaz');


}






function PosliDotaz(url,co){


var httpRequest;

        if (typeof window.ActiveXObject != 'undefined')

        {

          httpRequest = new ActiveXObject("Microsoft.XMLHTTP");

        }

        else

        {

          httpRequest = new XMLHttpRequest();

        }


        httpRequest.onreadystatechange= function () {


  if (httpRequest.readyState == 4)
  {

    if(httpRequest.status == 200)
    {

	 if(co=='vzkazy' || co=='vzkazy1'){
	 document.getElementById(co).innerHTML=httpRequest.responseText;
	 }
	 else if(co=='login'){
	
    		if(httpRequest.responseText=='ok'){

    		document.getElementById("prezdivka").innerHTML=document.getElementById("login").value;
      		document.getElementById("logged").style.display='block';
      		document.getElementById("obrazek").style.display='none';
      		document.getElementById("logout").style.display='none';
		document.getElementById("chat_zprava").value='';
      		document.getElementById("chat_zprava").focus();
		NatahniVzkazy('vzkazy', 107);
		ZobrazUzivatele('vzkazy1');
    		}

		else{
		alert('Vaše uživatelské jméno nebo heslo bylo zadáno nesprávně.');
		}
	
	
	}
	 else if(co=='logout'){
	
    		if(httpRequest.responseText=='ok'){

   		document.getElementById("prezdivka").innerHTML='';
      		document.getElementById("logged").style.display='none';
      		document.getElementById("obrazek").style.display='block';
      		document.getElementById("logout").style.display='block';
		document.getElementById("chat_zprava").value='';
		ZobrazUzivatele('vzkazy1');
    		}

		else{
		alert('Chyba při odhlašování, prosím, zavřete okno prohlížeče.');
		}
	
	
	}
	else{
	      document.getElementById("chat_zprava").value='';
      document.getElementById("chat_zprava").focus();

	if(httpRequest.responseText=='spam'){
	alert('Jsme rádi, že píšete tak horlivě, ale posílat dvakrát stejnou zprávu za sebou není nutné.');
	}
	else{
  NatahniVzkazy('vzkazy', 107);
  }
	}

    }
    else
    {
	//
    }
  }

} ;
        httpRequest.open("POST", '/chat.php', true);
        httpRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        httpRequest.setRequestHeader("Content-length", url.length);
        httpRequest.setRequestHeader("Connection", "close");
        httpRequest.send(url);

}



function submitenter(e,id)
{
var keycode;
if (e) keycode = e.keyCode;


if (keycode == 13) 
   {
   if(id=='logged'){
   UlozZpravu();
   }
   else{
   Login();
   }
   return false;
   }
else
   return true;
}


function smajlik(smajlik) {

      text2 = smajlik+' ';
      text1 = document.getElementById('chat_zprava').value
      text2 = text1+' '+smajlik+' ';
      document.getElementById('chat_zprava').focus();
      document.getElementById('chat_zprava').value = text2;

} 



function registrace() {

mail = document.getElementById('email');
login = document.getElementById('login1');
heslo1 = document.getElementById('heslo1');
heslo2 = document.getElementById('heslo2');


if (mail.value == "") {
alert("Je třeba vložit správnou emailovou adresu");
mail.focus();
return false;
}
else{
if (window.RegExp)
{
re = new RegExp("^[^@]+@[^.]+\..+$");
if (!re.test(mail.value))
{
alert("Je třeba vložit správnou emailovou adresu");
mail.focus();
return false;
}
}
}


if (login.value == "" ) {
alert("Vyplňte přihlašovací jméno.");
login.focus();
return false;
}

else if (login.value.length < 4 ) {
alert("Přihlašovací jméno musí obsahovat minimálně 4 znaky.");
login.focus();
return false;
}

else if (heslo1.value == "" ) {
alert("Vyplňte přihlašovací heslo.");
heslo1.focus();
return false;
}

else if (heslo1.value.length < 4 ) {
alert("Přihlašovací heslo musí obsahovat minimálně 4 znaky.");
heslo1.focus();
return false;
}

else if (heslo2.value == "" ) {
alert("Vyplňte přihlašovací heslo.");
heslo2.focus();
return false;
}

else if (heslo1.value != heslo2.value ) {
alert("Hesla se neshodují.");
heslo2.focus();
return false;
}



else
return true;
}


function kontrola2() {

mail = document.getElementById('novinky_mail').value;
mail1 = document.getElementById('novinky_mail');


if (mail != "") {
if (window.RegExp)
{
re = new RegExp("^[^@]+@[^.]+\..+$");
if (!re.test(mail))
{
alert("Napište, prosím, správnou mailovou adresu.");
mail1.focus();
return false;
}
}
}



else
return true;
}




function cnt(){
	maxlen = 200;
	delka = document.getElementById('chat_zprava').value.length;
	zbyva=maxlen-delka;
	if(delka>maxlen){
	document.getElementById('zbyva-znaku').innerHTML='0 znaků';
	}
	else if(zbyva==1){
	document.getElementById('zbyva-znaku').innerHTML='1 znak';
	}
	else if(zbyva >= 2 && zbyva<= 4){
	document.getElementById('zbyva-znaku').innerHTML=zbyva+' znaky';
	}
	else{
	document.getElementById('zbyva-znaku').innerHTML=zbyva+' znaků';
	}

}



