
// VARIABLER

var ti_timeout	= 500;
var ti_closetimer	= 0;
var ti_dmenuitem	= 0;
var ti_pk	= 0;

function ti_mclose() { ti_dmenuitem.style.visibility = 'hidden'; ti_pk=0; }

function ti_mclosetime() { ti_closetimer = window.setTimeout(ti_mclose, ti_timeout); }

function ti_mcancelclosetime() {
	if(ti_closetimer)
	{	window.clearTimeout(ti_closetimer);
		ti_closetimer = 0;	}
}

function h(){  ti_mclosetime() }    

function ti(pk){
	tiGen(pk,550,530);
}

function tiGen(pk,width,height){
	ti_mcancelclosetime();
	if (!(ti_pk == pk)) {
//		width=550;
//		height=530;
		tip.style.width = width; 
		tip.style.height = height;
		html = "<iframe onmouseover=ti_mcancelclosetime(); onmouseout=ti_mclosetime(); frameborder=0 scrolling=no " +
				"style='position:absolute;border:2px solid #006838' width=" + width + " height=" + height + " src='/public/modul/pop.asp?ID=" + pk + "'></iframe>";
		tip.innerHTML = html;
		pos = getHeight()/2;
		//document.body.scrollTop
		tip.style.top = document.body.scrollTop+pos-(height/2);

		pos = getWidth()/2;
		tip.style.left = pos-100;
		tip.style.visibility = "visible";
		ti_dmenuitem = document.getElementById("tip");
		ti_pk = pk;
	}
}    

function getWidth() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myHeight = document.body.clientHeight;
  }
  return myHeight;
}

function focus_username( e ) {
	if ( e.value == '' )
	{
		e.value = 'Användar ID';
		document.login.pass.value = '        ';
		e.select();
		return false;
	}
	if ( e.value == 'Användar ID' )
	{
		e.value = '';
		return false;
	}
}
function focus_password( e ) {
	if ( e.value == '        ' )
	{
		e.value = '';
		return false;
	}
}

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id) {	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose() {
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime() {
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime() {
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = 0;
	}
}

// close layer when click-out
document.onclick = mclose;


