


var ie=document.all;
var nn6=document.getElementById&&!document.all;
var isdrag=false;
var y,x,xx,yy,tx,ty;
var dobj;

function f_movemouse(e)
{
  if (isdrag)
  {
    s=dobj.id;
    snum=s.charAt(s.length-1);
    yy  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    xx  = nn6 ? tx + e.clientX - x : tx + event.clientX - x;

    fW = document.body.clientWidth;
    fH = document.body.clientHeight;
    oW = dobj.clientWidth;
    oH = dobj.clientHeight;

    if (yy>=fH-oH) yy=fH-oH;
    if (xx>=fW-oW) xx=fW-oW;

    if (xx<0) xx=0;
    if (yy<0) yy=0;

    dobj.style.top=yy+"px";    
    dobj.style.left=xx+"px";
    
    if (document.selection)
     if ((document.selection.type != 'None')) {
      document.selection.clear();
      document.selection.empty();
     }

    try {
     var sel = window.getSelection();
     sel.removeAllRanges();
    } catch (ex) {}
    
    return false; 
  } 
  else
  {
    yy  = nn6 ? e.clientY : event.clientY ;
    xx  = nn6 ? e.clientX : event.clientX ;
//    return false;
  }
}

function f_selectmouse(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";

  while ( (fobj.tagName != topelement && fobj.className != "dragme"  && fobj.tagName != "TEXTAREA" && fobj.tagName != "INPUT"  && fobj.tagName != "SELECT" ) )
  {
    fobj = nn6 ? fobj.parentNode : fobj.parentElement;
  }
  
  if ( fobj.tagName=="INPUT" )   return true;
  if ( fobj.tagName=="TEXTAREA" )   return true;  
  if ( fobj.tagName=="SELECT" )   return true;    

  if ( fobj.className=="dragme" )
  {
    isdrag = true;
    dobj = fobj;
    
    tx=-10000;
    x=-10000;

    tx = dobj.offsetLeft;
    x = nn6 ? e.clientX : event.clientX;
  
    ty = dobj.offsetTop;
    y = nn6 ? e.clientY : event.clientY;


    document.onmousemove=f_movemouse;
    // return false;
  }
}

 document.onmousemove=f_movemouse;
 document.onmousedown=f_selectmouse;
 document.onmouseup=new Function("isdrag=false");


function hidehints(show)
{
 var n=0;
 for (n=1; n<7; n++)
  {
   s="hint"+n;
   document.getElementById(s).style.display='none';
  }
 s="hint"+show;
 if (show!=0)
  document.getElementById(s).style.display='block';
 if (ie) 
  {
   correctPNG(); 
  } 
}


function sethint(id,txt)
{
 document.getElementById(id).innerHTML=txt;
}

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

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


function puthintundermouse(id)
{
 x=document.getElementById(id);
 x.style.left=(xx+30)+'px;';
 x.style.top=(yy-30)+'px;';
}



function showpopuppic(src)
{
 sethint("datapopup","<img src="+src+"><br><a href=javascript:hide('popup');>Close</a>");
 show("popup");
}


function showtime(num,dx)
{
 var CurTime=new Date();
 var h=CurTime.getHours();
 var m=CurTime.getMinutes();
 var x=Math.floor(m/10);
 var y=m%10; 
 
 h=h+dx;
 if (h>23) h=h-24;
 if (h<0) h=h+24;
  
 document.getElementById('clock'+num).innerHTML=h+":"+x+y;
 setTimeout("showtime("+num+","+dx+")",2000);
}
