  var xmlHTTP;


function runClock() {
today = new Date();
hours = today.getHours();
minutes = today.getMinutes();
seconds = today.getSeconds();
day = today.getDate();
month = today.getMonth()+1;
year = today.getFullYear();
TimeValue = hours;
TimeValue += ((minutes < 10) ? ":0" : ":") + minutes;
TimeValue += ((seconds < 10) ? ":0" : ":") + seconds;

document.getElementById('hodiny').innerHTML = day + '.' + month + '.' + year + ' ' + TimeValue;
window.setTimeout("runClock()",1000);
}

function ShowMenu(){
  menuLeft = document.getElementById('DynMenu').style.left;
  menuLeftPosition = menuLeft.substr(0,menuLeft.length-2);
    if((menuLeftPosition<0)&&(document.getElementById('qMenuState').value == "hid")){
            if(menuLeftPosition <= -100) step = 10;
            if((menuLeftPosition >-100)&&(menuLeftPosition<=-60)) step = 6;
            if((menuLeftPosition >-60)&&(menuLeftPosition<=40)) step = 5;
            if((menuLeftPosition >-40)&&(menuLeftPosition<=10)) step = 3;
            if((menuLeftPosition >-10)&&(menuLeftPosition<=0)) step = 1;
            newMenuPos = eval(menuLeftPosition) + step;
            document.getElementById('DynMenu').style.left = newMenuPos.toString();
            setTimeout('ShowMenu()',10);
    }

  if(menuLeftPosition==0){ 
    document.getElementById('qMenuState').value = "vis";
  }
  

}

function HideMenu(){
  menuLeft = document.getElementById('DynMenu').style.left;
  menuLeftPosition = menuLeft.substr(0,menuLeft.length-2);
  qMState = document.getElementById('qMenuState').value;
    if((menuLeftPosition>-135)&&(qMState=='vis')) {
            if(menuLeftPosition >= -80) step = 10;
            if((menuLeftPosition <= -80)&&(menuLeftPosition>=-120)) step = 6;
            if((menuLeftPosition <= -120)&&(menuLeftPosition >=-135)) step = 1;
            newMenuPos = eval(menuLeftPosition) - step;
            document.getElementById('DynMenu').style.left = newMenuPos.toString();
            setTimeout('HideMenu()',10);
    }
  if(menuLeftPosition==-135){ 
    document.getElementById('qMenuState').value = "hid";
  }
  
}
function MoveMenu(topOff){
    menuTop = document.getElementById('DynMenu').style.top;
    menuTopPosition = menuTop.substr(0,menuTop.length-2);
    fromTop = document.body.scrollTop;
    if(menuTopPosition<(eval(fromTop)+topOff)) {
            offsetLength = (eval(fromTop)+topOff)-menuTopPosition;
            if(offsetLength >= 150) step = 10;
            if((offsetLength <150)&&(offsetLength>=120)) step = 8;
            if((offsetLength <120)&&(offsetLength>=80)) step = 6;
            if((offsetLength <80)&&(offsetLength>=40)) step = 4;
            if((offsetLength <40)&&(offsetLength>=10)) step = 2;
            if((offsetLength <10)&&(offsetLength>=0)) step = 1;
            newMenuPos = eval(menuTopPosition) + step;
            document.getElementById('DynMenu').style.top = newMenuPos.toString();
    }

    if(menuTopPosition>(eval(fromTop)+topOff)) {
            offsetLength = menuTopPosition-(eval(fromTop)+topOff);
            if(offsetLength >= 100) step = 10;
            if((offsetLength <100)&&(offsetLength>=80)) step = 8;
            if((offsetLength <80)&&(offsetLength>=60)) step = 6;
            if((offsetLength <60)&&(offsetLength>=40)) step = 4;
            if((offsetLength <40)&&(offsetLength>=10)) step = 2;
            if((offsetLength <10)&&(offsetLength>=0)) step = 1;
            newMenuPos = eval(menuTopPosition) - step;
            document.getElementById('DynMenu').style.top = newMenuPos.toString();
    }
     

    setTimeout('MoveMenu(300)',10)
}

function ShowParty(id){
	if(document.getElementById('partyAc').value!="c"){
	if((document.getElementById('ps').value == id)||(document.getElementById('ps').value=="")){
	document.getElementById('ps').value = id;
    partyW = document.getElementById('p'+id).style.width;
    partyWidth = partyW.substr(0,partyW.length-2);
    if(eval(partyWidth)<=0){
		if(navigator.appName == "Microsoft Internet Explorer"){
			document.getElementById('p'+id).style.left = document.getElementById('party').offsetParent.offsetLeft+((document.body.offsetWidth/2)-353)+111;
			document.getElementById('p'+id).style.top = 171+ document.getElementById('pb'+id).offsetTop;
		}else{
			document.getElementById('p'+id).style.left = document.getElementById('party').offsetParent.offsetLeft+((document.body.offsetWidth/2)-353)+129;
			document.getElementById('p'+id).style.top = 166+ document.getElementById('pb'+id).offsetTop;
		}
		 document.getElementById('p'+id).style.display = 'block';
    }
    
           if(eval(partyWidth) <= 150) step = 10;
            if((eval(partyWidth)>150)&&(eval(partyWidth)<=180)) step = 9;
            if((eval(partyWidth) >180)&&(eval(partyWidth)<=200)) step = 7;
            if((eval(partyWidth) >200)&&(eval(partyWidth)<=220)) step = 4;
            if((eval(partyWidth) >220)&&(eval(partyWidth)<=240)) step = 2;
            if((eval(partyWidth) >240)&&(eval(partyWidth)<=250)) step = 1;
            
    if(eval(partyWidth)<250){
    	document.getElementById('partyAc').value = "s";
    	partyWidth = eval(partyWidth) + step;
		document.getElementById('p'+id).style.width = partyWidth.toString();
	    setTimeout('ShowParty('+id+')',10);
    }

    if(eval(partyWidth)>=250){
    	document.getElementById('po'+id).style.display = 'block';
    	document.getElementById('partyAc').value = "";

    }else{
    	document.getElementById('po'+id).style.display = 'none';
    }

	}else{
		document.getElementById('closeRequest').value = id;
		CloseParty(document.getElementById('ps').value);
	}
	}
}

function CloseParty(id){
	if(document.getElementById('partyAc').value!="s"){
	document.getElementById('po'+id).style.display = 'none';
    partyW = document.getElementById('p'+id).style.width;
    partyWidth = partyW.substr(0,partyW.length-2);
    if(eval(partyWidth)<=0){
		document.getElementById('p'+id).style.display = 'none';
     	document.getElementById('partyAc').value = "";

    }
    
           if(eval(partyWidth) >= 100) step = 10;
            if((eval(partyWidth)<100)&&(eval(partyWidth)>=70)) step = 9;
            if((eval(partyWidth) <70)&&(eval(partyWidth)>=50)) step = 7;
            if((eval(partyWidth) <50)&&(eval(partyWidth)>=30)) step = 4;
            if((eval(partyWidth) <30)&&(eval(partyWidth)>=10)) step = 2;
            if((eval(partyWidth) <10)&&(eval(partyWidth)>=0)) step = 1;
            
    if(eval(partyWidth)>0){
    	partyWidth = eval(partyWidth) - step;
		document.getElementById('p'+id).style.width = partyWidth.toString();
	    setTimeout('CloseParty('+id+')',10);
      	document.getElementById('partyAc').value = "c";

    }else{
    		document.getElementById('ps').value = "";
    		if(document.getElementById('closeRequest').value!=""){
    			fromId = document.getElementById('closeRequest').value;
    			document.getElementById('closeRequest').value = "";
    			ShowParty(fromId);
    		}
    }
	}

}
    function CreateXMLHttpRequest(){
     xmlHTTP = (window.XMLHttpRequest ? new XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));      
    }
    
    function hlasovat(odpoved){
      CreateXMLHttpRequest();
      xmlHTTP.onreadystatechange = zobrazAnketu;
      xmlHTTP.open("GET", "anketa-req.php?o="+odpoved,true);
      xmlHTTP.send(null);
    }
    
    function zobrazAnketu(){
      if(xmlHTTP.readyState == 4){
        if(xmlHTTP.status == 200){
          document.getElementById('anketa').innerHTML = xmlHTTP.responseText;
        }
      }
    }
    
function HideLogError(x){
  if(x==0){
    window.setTimeout("HideLogError('1')",2000);
  }else{
    document.getElementById('loginError').style.display = "none";
  }
  
}

