var poy=-1;
var pox=-1;

function vytvorxmlhttp()
{
  var xmlHttp= false;
  
      if (window.ActiveXObject) 
          {xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");}
       else if (window.XMLHttpRequest) 
          {xmlHttp = new XMLHttpRequest();}
          else
          {window.alert("Nelze vytvořit")}
    return xmlHttp;
}

function MouseOver(id)
{
window.document.getElementById(id).style.display='block';
}

function MouseOut(id)
{
window.document.getElementById(id).style.display='none';
}

var dayarray=new Array("Neděle","Pondělí","Úterý","Středa","Čtvrtek","Pátek","Sobota")
var montharray=new Array("Leden","Únor","Březen","duben","Květen","Červen","Červenec","Srpen","Září","Říjen","Listopad","Prosinec")

function IdValue(id,val)
{
window.document.getElementById(id).value=val;
}

var cislo=0;

function IdValue2(id,vala,valb)
{
cislo=cislo+1;
val2="";
for(c=0;c!=cislo;c++)
{
val2=val2+vala+cislo+valb;
}
val=val2;
document.getElementById(id).innerHTML=val;
window.document.getElementById('cislo').value=cislo+1;
}

function IdValueP(id,val)
{
  var v = window.document.getElementById(id); 
	var add = val;
	v.focus();
	if (window.document.selection) {
		sel = window.document.selection.createRange();
		sel.text = add;
	} else if( v.selectionStart || v.selectionStart == "0" ) {
		var startPos = v.selectionStart;
		var endPos = v.selectionEnd;
		var len = v.value.length;
		v.value = v.value.substring(0, startPos) + add + v.value.substring(endPos, len);
	} else {
		v.value += add;
	}

}

function IdBlockNone(id)
{
window.document.getElementById(id).style.display=(window.document.getElementById(id).style.display=='block') ? 'none':'block';
}

function cas(id) {
rok = new Array("ledena", "února", "březena", "dubena", "května", "června", "července", "srpena", "září", "října", "listopadu", "prosince");
tyden = new Array("neděle", "pondělí", "úterý", "středa", "čtvrtek", "pátek", "sobota");
datum = new Date();
with(datum){
den = getDay();

d = getDate();
m = getMonth();
r = getYear();

h = getHours();
min = getMinutes();
s = getSeconds();
if (s<10)
s="0"+s;
if (min<10)
min="0"+min;
if (h<10)
h="0"+h;
if (d<10)
d="0"+d;
if (r<2000)
r+=1900;
}

window.document.getElementById("clock").innerHTML=tyden[den]+" "+d+"."+rok[m]+" "+r+" "+h+":"+min+":"+s;

window.setTimeout("cas()", 1000);
}

function OpenWindow(url,nazev,vyska,sirka,zhora,zleva,historie,vrchnilista,radeksadresou,stavovyradek,vybraneadresy,nabidkaprohlizece,posuvniky,zmenavelikosti)
{
window.open(url,nazev,"height="+vyska+"px, width="+sirka+"px, top="+zhora+"px, left="+zleva+"px, copyhistory="+historie+", toolbar="+vrchnilista+", location="+radeksadresou+", status="+stavovyradek+", directories="+vybraneadresy+", menubar="+nabidkaprohlizece+", scrollbars="+posuvniky+", resizable="+zmenavelikosti);
}

var posundown=0;
var posunx;
var posuny;
var posunid;
var px;
var py;

function xy(e){
var ev=(!e)?window.event:e;//IE:Moz
if (ev.pageX){//Moz
posunx=ev.pageX+window.pageXOffset;
posuny=ev.pageY+window.pageYOffset;
}
else if(ev.clientX){//IE
posunx=ev.clientX+document.body.scrollLeft;
posuny=ev.clientY+document.body.scrollTop;
}
else{return false}//old browsers
}

function xyWrite(id)
{
document.getElementById(id).innerHTML=' '+posunx+':'+posuny+' ';
}

function spustitposun(id,x,y) 
{
 posundown=1;
 posunid=id;
 px=x;
 py=y;
}

function posun() 
{
 if (posundown==1)
 { 
 window.document.getElementById(posunid).style.left=posunx-px;
 window.document.getElementById(posunid).style.top=posuny-py;
 if (posunid=='menu')
{
 poy=posuny-py;
 pox=posunx-px;
}
 }                                     
}

function ukoncitposun(url,xp,yp) 
{
 posundown=0;
 var ulozitposun=vytvorxmlhttp();
 if(ulozitposun.readyState==4 || ulozitposun.readyState==0)
  {
  x=posunx-xp;
  y=posuny-yp;
  ulozitposun.open("GET",url+'?top='+y+'&left='+x,true);
  }
 ulozitposun.send(null);
}

function usporadat(id,y,x) 
{ 
 window.document.getElementById(id).style.top=y;
 if (id=='menu')
{
 poy=y;
 pox=x;
}
 window.document.getElementById(id).style.left=x;
}

function usporadat2(id,y,x,url) 
{ 
 window.document.getElementById(id).style.top=y;
 if(id=='menu')
{
 poy=y;
 pox=x;
}
 window.document.getElementById(id).style.left=x;
 
 posundown=0;
 var ulozitposun=vytvorxmlhttp();
 if(ulozitposun.readyState==4 || ulozitposun.readyState==0)
  {
  ulozitposun.open("GET",url+'?top='+y+'&left='+x,true);
  }
 ulozitposun.send(null);                                     
}

function KonrolaFormulare(Form) {
    for( var i=0; i<Form.length; i++ ) {
     with(Form.elements[i]) { 
      if( type=="text" || type=="password" ) {
        if( name.indexOf("num")==0 ) {
            if( (value.length==0) || isNaN(parseInt(value)) ) {
                alert('V poli má být číselná hodnota"' + name.slice(3) + '".');
                focus();
                return false;        
            }
        } else {
            if( value.length==0) {
                alert('Pole nesmí být prázdné"' + name + '".');
                focus();
                return false;        
            }
        }
      }
     }
    }
    return true;
}

 //onSubmit="return Validate(this)"
 
function zkontroluj_email(adresa)
{
    re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,3}$/;
    return adresa.search(re) == 0;
}

function zkontroluj_formular(id)
{
  if (!zkontroluj_email(window.document.getElementById(id).value))
  {
    alert("Odesílatel nemá správně vyplněnou adresu!");
    window.document.getElementById(id).focus();
    return false;
  }
  return true;  
}

function PosuvneMenu(top,left)
{
if (poy>-1)
 window.document.getElementById('menu').style.posTop = window.document.body.scrollTop+poy;
else
 window.document.getElementById('menu').style.posTop = window.document.body.scrollTop+top;

if (pox>-1)
 window.document.getElementById('menu').style.posLeft = window.document.body.scrollLeft+pox;
else
 window.document.getElementById('menu').style.posLeft = window.document.body.scrollLeft+top;
}

function PoslatProm(url,id) 
{
 var poslat=vytvorxmlhttp();
 if(poslat.readyState==4 || poslat.readyState==0)
  {
  if (window.document.getElementById(id).value=='')
  {
  window.alert ("Pole je prázdné");
  }else{
  poslat.open("GET",url+'?'+id+'='+window.document.getElementById(id).value,true);
  window.document.getElementById(id).value='';
  window.alert("Změněno");
  } 
  }
 poslat.send(null);
}

function PoslatProm2(url,id) 
{
 var poslat=vytvorxmlhttp();
 if(poslat.readyState==4 || poslat.readyState==0)
  {
  if (window.document.getElementById(id).value=='')
  {
  window.alert ("Pole je prázdné");
  }else{
  poslat.open("GET",url+'?'+id+'='+window.document.getElementById(id).value,true);
  window.document.getElementById(id).value='';
  } 
  }
 poslat.send(null);
}

function PoslatProm3(url,id) 
{
 var poslat=vytvorxmlhttp();
 if(poslat.readyState==4 || poslat.readyState==0)
  {
  if (window.document.getElementById(id).checked==true)
  {
  poslat.open("GET",url+'?'+id+'=1',true);
  }else{
  poslat.open("GET",url+'?'+id+'=0',true);
  }
  window.alert("Změněno");
  } 
 poslat.send(null);
}

function PoslatProm4(url) 
{
 var poslat=vytvorxmlhttp();
 if(poslat.readyState==4 || poslat.readyState==0)
  {
  poslat.open("GET",url,true);
  } 
 poslat.send(null);
}

function Inicializace()
{
xHttp = vytvorxmlhttp();
xHttp.open("GET", 'chat.php', true); 
xHttp.onreadystatechange = function()
{ 
if (xHttp.readyState == 4 && xHttp.status == 200) 
{
window.document.getElementById("div_chat").innerHTML=xHttp.responseText;
if(xHttp.responseText=="")
{
window.close();
} 
}
} 
 
xHttp.send(null);

xHttp2 = vytvorxmlhttp();
xHttp2.open("GET", 'chat3.php', true); 
xHttp2.onreadystatechange = function()
{ 
if (xHttp2.readyState == 4 && xHttp2.status == 200) 
{
window.document.getElementById("div_online").innerHTML=xHttp2.responseText;
if(xHttp2.responseText=="")
{
window.close();
} 
}
} 
 
xHttp2.send(null);

window.setTimeout("Inicializace()", 5000);
}


function PosuvnyObjekt(id,y,x)
{
 window.document.getElementById(id).style.posBottom = -window.document.body.scrollTop+y;
 window.document.getElementById(id).style.posLeft = window.document.body.scrollLeft+x;
}

function PosuvnyObjekt2(id,y,x)
{
 window.document.getElementById(id).style.posTop = window.document.body.scrollTop+y;
 window.document.getElementById(id).style.posLeft = window.document.body.scrollLeft+x;
}

function video(video)
{
var s1 = new SWFObject("player-viral.swf","ply","500","400","9","#804000");
 	  s1.addParam("allowfullscreen","true");
	  s1.addVariable('displayheight','1000');
		s1.addVariable('frontcolor','0x000000');
    s1.addVariable('backcolor','0x804000');
    s1.addVariable('lightcolor','0x666666');
	  s1.addVariable('screencolor','0x804000');
    s1.addVariable('displayheight','500');
		s1.addParam("allownetworking","all");
		s1.addParam("allowscriptaccess","always");
		s1.addVariable('file',video);    
		s1.addVariable('image','http://usr.bandzone.cz/band/an/analnivytok/gallery/profile.default/354864.jpg');
		s1.addVariable('logo','');
		s1.addVariable('autostart','true');
		s1.write("container");
}

function maxarea(id,id2,cislo,cislo2)
{
 area = document.getElementById(id);
 alength = area.value.length;
 window.document.getElementById(id2).innerHTML="Znaků : " + cislo + " / " + alength;
 
 if(alength > cislo){
		area.value = area.value.substr(0,cislo);
		document.getElementById(id2).innerHTML="max";
	} else {
		document.getElementById(id2).innerHTML="Znaků : " + cislo + " / " + alength;
	}
}

function mail_vse(form)
{
for(var i = 0; i < document.getElementById(form).elements.length; i++) {
    if(document.getElementById(form).elements[i].type == "checkbox")
      document.getElementById(form).elements[i].checked = true;
  }
}

function mail_nic(form)
{
for(var i = 0; i < document.getElementById(form).elements.length; i++) {
    if(document.getElementById(form).elements[i].type == "checkbox")
      document.getElementById(form).elements[i].checked = false;
  }
}

function mail_prehodit(form)
{
for(var i = 0; i < document.getElementById(form).elements.length; i++) {
    if(document.getElementById(form).elements[i].type == "checkbox" && document.getElementById(form).elements[i].checked==true)
      document.getElementById(form).elements[i].checked = false;
    else
      document.getElementById(form).elements[i].checked = true;
  }
}

function mail_prectene(form)
{
for(var i = 0; i < document.getElementById(form).elements.length; i++)
{
 if(document.getElementById(form).elements[i].id>0)
  document.getElementById(form).elements[i].checked = true;
}
}

window.document.onmousemove=xy;