if(document.getElementById&&!document.all){
    var nn6=document.getElementById&&!document.all;
}else{
    var nn6 = false;
}
var isdrag=false;
var x=0,y=0;
var dobj;
var  visible_foto = false;

function movemouse(e)
{
        if (isdrag){
            dobj.style.left = nn6 ? e.clientX + x : event.clientX + x;
            dobj.style.top = nn6 ? e.clientY + y : event.clientY + y;
            return false;
        }
    }

   function cleanup(e) {
      document.onmousemove=null;
      document.onmouseup=null;
      isdrag=false;
   }
function selectmouse(e)
{
var fobj = nn6 ? e.target : event.srcElement;
var topelement = nn6 ? "HTML" : "BODY";
if(fobj.className=="setmoveable"){
    while (fobj.tagName != topelement && fobj.className != "moveable")
    {
        fobj = nn6 ? fobj.parentNode : fobj.parentElement;
    }
    if (fobj.className=="moveable")
    {
        isdrag = true;
        dobj = fobj;
        tx = parseInt(dobj.style.left+0,10);
        ty = parseInt(dobj.style.top+0,10);
        x = nn6 ? tx-e.clientX : tx-event.clientX;
        y = nn6 ? ty-e.clientY : ty-event.clientY;
        document.onmousemove=movemouse;
        document.onmouseup=cleanup;
    return false;
    }
}
else if (fobj.className=="formmove")
{
    while (fobj.tagName != topelement && fobj.className != "moveform")
    {
        fobj = nn6 ? fobj.parentNode : fobj.parentElement;
    }
    if (fobj.className=="moveform")
    {
        isdrag = true;
        dobj = fobj;
        tx = parseInt(dobj.style.left+0,10);
        ty = parseInt(dobj.style.top+0,10);
        x = nn6 ? tx-e.clientX : tx-event.clientX;
        y = nn6 ? ty-e.clientY : ty-event.clientY;
        document.onmousemove=movemouse;
        document.onmouseup=cleanup;
    return false;
    }
}
}
document.onmousedown=selectmouse;



function getObj(name) {
  if (document.getElementById) return document.getElementById(name);
  else if (document.all) return document.all[name];
  else if (document.layers) return document.layers[name];
  else return false;
}

function hide_form()
{
itm = getObj("loginform");
if (itm)	
	{
	itm.style.display="none";
	}

}

function show_loginforms(cursor)
{
var x = 0;
var y = 0;
var itm = null;
if(!cursor) var cursor = window.event;
if (cursor.pageX || cursor.pageY) {
    x = cursor.pageX;
    y = cursor.pageY;
  }
  else if (cursor.clientX || cursor.clientY) {
    x = cursor.clientX + document.body.scrollLeft;
    y = cursor.clientY + document.body.scrollTop;
  }
x = x - 230;
y = y - 70;
itm = getObj("loginform");
if (itm)	
	{
	if (itm.style.top == "0px")
	{
	itm.style.left=""+x+"px";
	itm.style.top=""+y+"px";
	}
	itm.style.display="";
	document.login_form.login.select();
	document.login_form.login.focus(); 
	}
}

  function getPageSize() {
            var xScroll, yScroll;
            if (window.innerHeight && window.scrollMaxY) {  
                xScroll = window.innerWidth + window.scrollMaxX;
                yScroll = window.innerHeight + window.scrollMaxY;
            } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
                xScroll = document.body.scrollWidth;
                yScroll = document.body.scrollHeight;
            } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
                xScroll = document.body.offsetWidth;
                yScroll = document.body.offsetHeight;
            }
            var windowWidth, windowHeight;
            if (self.innerHeight) { // all except Explorer
                if(document.documentElement.clientWidth){
                    windowWidth = document.documentElement.clientWidth; 
                } else {
                    windowWidth = self.innerWidth;
                }
                windowHeight = self.innerHeight;
            } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowWidth = document.documentElement.clientWidth;
                windowHeight = document.documentElement.clientHeight;
            } else if (document.body) { // other Explorers
                windowWidth = document.body.clientWidth;
                windowHeight = document.body.clientHeight;
            }   
            // for small pages with total height less then height of the viewport
            if(yScroll < windowHeight){
                pageHeight = windowHeight;
            } else { 
                pageHeight = yScroll;
            }
            // for small pages with total width less then width of the viewport
            if(xScroll < windowWidth){  
                pageWidth = xScroll;        
            } else {
                pageWidth = windowWidth;
            }
            arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
            return arrayPageSize;
        }

function show_foto(imgurl){
var arrPageSizes = getPageSize();
itm = getObj("darkBackgroundLayer");
itm.style.display="";
itm.style.width=arrPageSizes[0];
itm.style.height=arrPageSizes[1];
itm = getObj("winfoto");
itm.innerHTML='<table bgcolor="#D3D3D3"><tr><td align="right" class="setmoveable"><a href="javascript:hide_foto();"><img border="0" src="img/close.gif" alt="close"></a></td></tr><tr><td><a href="javascript:hide_foto();"><img border="0" src="'+imgurl+'"></a></td></tr></table>';
x = document.body.scrollLeft + 50;
y = document.body.scrollTop + 10;
if (itm.style.top=="0px")
{
itm.style.left=""+x+"px";
}
itm.style.top=""+y+"px";
visible_foto = true;
}

function hide_foto()
{
itm = getObj("winfoto");
itm.innerHTML='';
itm = getObj("darkBackgroundLayer");
itm.style.display="none";
visible_foto = false;
}

function place()
{
if (getObj("winfoto"))
moving();
}

function moving()
{
if (visible_foto)
{
x = document.body.scrollLeft + 50;
y = document.body.scrollTop + 10;
itm.style.left=""+x+"px";
itm.style.top=""+y+"px";
}
setTimeout('moving()',15);
}
