//document.include 'browsers.js';

//-----Browser check------------------------------;
var lfk = false;
function BrowserCheck() {
	var b = navigator.appName;
	
	if (b=="Netscape"){
		this.b = "ns";
	} else if (b=="Microsoft Internet Explorer") {
		this.b = "ie";
	} else {
		this.b = b;
	}
	
	this.v = parseInt(navigator.appVersion);

	if (this.b=="ns")
		this.ns = true;
	else
		this.ns = false;
		
		
	if (this.b=="ns" && this.v<4)
		this.ns3 = true;
	else
		this.ns3 = false;
		
	if (this.b=="ns" && this.v==4)
		this.ns4 = true;
	else
		this.ns4 = false;
	
	if (this.b=="ns" && this.v>=5)
		this.ns6 = true;
	else
		this.ns6 = false;
		
	if (this.b=="ie" && this.v>=4)
		this.ie = true;
	else
		this.ie = false;
	
	if (navigator.userAgent.indexOf('MSIE 4')>0)
		this.ie4 = true;
	else
		this.ie4 = false;
	
	if (navigator.userAgent.indexOf('MSIE 5')>0)
		this.ie5 = true;
	else
		this.ie5 = false;
	
	if ((this.b=="ie" && this.v>=6))
		this.ie6 = true;
	else
		this.ie6 = false;

	if (this.ie5) {
		this.v = 5;
	}
	
	if(this.ns6) {
		this.v = 6;
	}
	
	if (this.ns == true || this.ie == true)
		this.min = true;
	else
		this.min = false;
		
	//this.min = (this.ns||this.ie)
}


//----------------------------------------------;

chk = new BrowserCheck();
//----Gets window width and height---------------;
function getWindowSize(){
	if(chk.ie){
		WIDTH=document.body.clientWidth;
		HEIGHT=document.body.clientHeight;
	}
	if(chk.ns){
		WIDTH=window.innerWidth;
		HEIGHT=window.innerHeight;
	}
}
//----------------------------------------------;


//---- Mousemove handler------------------------;
function initMouse() {
	//document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	//document.onmouseup = mouseUp
	if (chk.ns4&&!chk.ns6) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}
//----------------------------------------------;


var noM=true;
var downX=null;
var downY=null;
var upX=null;
var upY=null;

function mouseDown(e) {
	if(chk.ns){
		downX=e.pageX;
		downY=e.pageY;
	}
	if(chk.ie){
		if(document.getElementById){
			offY=document.documentElement.scrollTop;
			offX=document.documentElement.scrollLeft;
		}
		else{
			offY=document.body.scrollTop;
			offX=document.body.scrollLeft;
		}
		downX=event.x+offX;
		downY=event.y+offY;
	}
	return true;
}


//-------------------------------------------------;

//-----Mousemove and delay dropdownhide handler;
function mouseMove(e){


	if(chk.ie){
		if(document.getElementById){
			offY=document.documentElement.scrollTop;
			offX=document.documentElement.scrollLeft;
		}
		else{
			offY=document.body.scrollTop;
			offX=document.body.scrollLeft;
		}
	}


	if(chk.ns){
		X=e.pageX;
		Y=e.pageY;
	} else {
		X=window.event.x;
		Y=window.event.y;
	}
	
	
	//------------------------------------------;
	if(limit != false && currentN != false){
		if(X > limit[1] || X < limit[3] || Y > limit[2] || Y < limit[0]){
			hidemen();
		}
	}
	//------------------------------------------;	
	
 //status = limit + ' ' + X + ' ' + Y;
}






var WIDTH=null;
var HEIGHT=null;
var down=null;
var up=null;
//====================================================================;
function getDivision(div,st){
	divLength=(div.length)-1;
	//------------------------------------------------;
	if(chk.ie){
		diV='document.all.'+div[divLength];
	}
	//------------------------------------------------;
	if(chk.ns6){
		diV='document.getElementById("'+div[divLength]+'")';
	}
	//------------------------------------------------;
	if(chk.ns4){
		for(var i=0;i<=divLength;i++){
			if(i==0){
				diV='document.layers.'+div[i];
			}
			else{
				diV=diV+'.document.layers.'+div[i];
			}
		}
	}
	//------------------------------------------------;
	if(st){
		return diV;
		return false;
	}
	//------------------------------------------------;
    diV=eval(diV);
    return diV;
}
//====================================================================;


//====================================================================;
function visibleDiv(num, visb){

	eval("divId = document.getElementById('" + divIDname + num + "')");
	//eval("divId = '" + divIDname + num + "'");
	eval("PosId = document.getElementById('" + posIDname + num + "')");
	//eval("PosId = '" + posIDname + num + "'");
		
	//object=getDivision(divId);
	//XPosAdjust = 2;
	//YPosAdjust = 14;

	//------------------------------------------------;
	if(chk.ie || chk.ns6){
		//document.getElementById(divId).style.left = 100;
		if(visb){
			//divId.style.visibility="visible";
			divId.style.left = (PosId.offsetLeft) + eval('XYPosAdjust' + num + '[0]');
			divId.style.top = (PosId.offsetTop) + eval('XYPosAdjust' + num + '[1]');
		}
		else{
			divId.style.left = -300;
		}
	}
}
//====================================================================;




//=======Låser fast en dropdown i visningsläge för tex. en input textruta i dropdownen ====;
function LockDD(lockState){

	lfk = lockState;
	//document.hiddvalues.hiddvalfield.value = lfk;
	
	if(lfk == false){
		document.onmousemove = mouseMove;
	}
	else{
		document.onmousemove = null;
	}
}

//==========================================================================================;





var IsInMenu;
var CountDown;
DDTimer = 0;
//-----Start stop delay count down-----;
function StartCounter(){
	CountDown = setInterval("CountDelay()",50);
}
function StopCounter(){

	clearInterval(CountDown);
	DDTimer = 0;
}
//-------------------------------------;

function hidemen(){
	//clearInterval(CountDown);
	//DDTimer = 0;
	visibleDiv([currentN],false);
}
function CountDelay(){
	DDTimer++;
	status = '\nDDTimer = ' + DDTimer;
	if(DDTimer == 10){
		hidemen();
	}
}

//-------------------------------------------------;



