var beh = 0;
var draha = 0;
var v_x = 0;
var v_y = 0;
var poc = 0;

function motorsipka()
{  
    var obj = document.getElementById("table_select_1");
    //document.write("w_c=" + obj.clientWidth + "<br />");
    //document.write("w_o=" + obj.offsetWidth + "<br />"); 
    //document.write("w_s=" + obj.scrollWidth);
    
    var obj1 = document.getElementById("strednipole");
    
    var tab0 = "";
    tab0 = "<table style=\"width:" + obj.clientWidth + "\"><tr>\n";
    tab0 += "<td style='width:40%'>" + obj1.innerHTML + "</td>";
    tab0 += "<td valign='bottom' id='tdmsipka' style='width:60%; overflow:hidden'><div id='msipka' style='";    
    tab0 += "position:relative; width: 100%;";
    tab0 += "height: 50px;";
    tab0 += "margin-left: -65px;";
    tab0 += "border-bottom-style: double;";
    tab0 += "border-bottom-color: red;";
    tab0 += "border-bottom-width: 3px;";
    tab0 += "border-right-style: double;";
    tab0 += "border-right-color: red;";
    tab0 += "border-right-width: 3px;";     
    tab0 += "'>";    
    tab0 += "</div>";
               
    tab0 += "</td>";    
    tab0 += "</tr></table>\n<div id='log'></div>";
    
    obj1.innerHTML = tab0;
    
    
    draha = document.getElementById("msipka").clientWidth;        
    var t = setTimeout("vzruch('start')", 2000);
}



function vzruch(stav)
{
if(stav == "start")
{   
    var obj = document.createElement('div');
    obj.setAttribute('id', 'msipka_vzruch');
    obj.style.position = "absolute";
    obj.style.bottom = "-2px";
    obj.style.right = draha + "px";
    obj.style.width = "10px";
    obj.style.height = "10px";
    obj.style.borderBottomStyle = "solid";
    obj.style.borderBottomWidth = "1px";
    document.getElementById("msipka").appendChild(obj);
    stav = "hor";
    
}
if(stav == "hor")
{

    v_x = 1 * document.getElementById("msipka_vzruch").style.right.replace("px","");    
    if((v_x > 0) && (beh < 200))
    {
        beh += 1;                 
        if(v_x > 10) v_x -= 10;
        else v_x = 0;                         
        var t = setTimeout("set_x('msipka_vzruch', " + v_x + ")",15);
    }
    else
    {
        draha = document.getElementById("msipka").clientHeight;
        var obj = document.getElementById("msipka_vzruch");
        obj.style.width = "1px";
        obj.style.height = "10px";
        obj.style.right = (obj.style.right.replace("px","") - 2) + "px";
        obj.style.borderBottomStyle = "none";
        obj.style.borderBottomWidth = "0px";
        obj.style.borderRightStyle = "solid";
        obj.style.borderRightWidth = "1px";         
        vzruch("ver");
    } 
}
if(stav == "ver")
{   
    v_y = 1 * document.getElementById("msipka_vzruch").style.bottom.replace("px","");     
    if((v_y < draha) && (beh < 200))
    {     
        beh += 1;                 
        if(v_y < (draha - 20)) v_y += 10;
        else v_y = draha;                         
        var t = setTimeout("set_y('msipka_vzruch', " + v_y + ")",15);
    } 
    else
    {
        document.getElementById("msipka").removeChild(document.getElementById("msipka_vzruch"));
        poc += 1;
        if(poc < 3)
        {
            draha = document.getElementById("msipka").clientWidth;
            beh = 0;        
            var t = setTimeout("vzruch('start')", 3000);            
        }

    }
}
} 


function set_x(id,poloha)
{
     document.getElementById(id).style.right = poloha + "px";                
     vzruch("hor");
}

function set_y(id,poloha)
{
     document.getElementById(id).style.bottom = poloha + "px";                
     vzruch("ver"); 
}

function pripis(text)
{
    document.getElementById("log").innerHTML += text;
}

function alrt()
{
    alert("ahoj");
}


function kill_sipka()
{        
    try{         
        document.getElementById("tdmsipka").removeChild(document.getElementById("msipka"));
    }
    catch(err){}      
}


