var SelRow=0;
var SelRowBC="";
var srl=6;
var smap= new Array("","","","");
var fieldName="";
var update=false;
var showDiID;
var field;
var vvDataTop=0;

function fldChkNumeric(){
	try{
		if(field!=null){
			var value = field.value;
			if(isNaN(value)){
				alert("Antal skall anges med siffror!");
				field.focus();
				return false;
			}
			if(parseInt(value)<1){
				alert("Antal skall vara storre an noll!");
				field.focus();
				return false;
			}
		}
		else{
			return true;
		}
	}
	catch(e){
		var info ="Tekniskt fel!\n\n";
		info += e.description;
		alert(info);
		return true;
	}
	return true;
}

function ei(idx){
	SelectRow(idx+1)
	var f=document.forms[0]
	var sid=idx*7

	actc=idx
	 /* f.txtExID.value=idx+1 */
	idx*=srl;

	//var exid = document.getElementById('txtExID');
	var exid = document.getElementById('txtExID');
	var inln = document.getElementById('txtInloggName');
	var los = document.getElementById('txtLosen');
	var nam = document.getElementById('txtUserName');

	exid.value=smap[0];
	inln.value=smap[1];
	los.value=smap[2];
	nam.value=smap[3];

	/*alert(exid.value);*/
}

function di(idx){
	SelectRow(idx+1);
	
	var strConf = "Ar du saker pa att du vill ta bort inloggnig for:\n";
	//"&#196;r du s&#228;ker p&#229; att du vill ta bort inloggning f&#246;r "

	if(!confirm(strConf+smap[3]+"?"))
		{SelectRow(-1);return;}

	var f=document.f;

	act="delinlogg.asp?exid="+smap[0];

	location=act;

	DeleteRow(idx+1);
}

function SelectRow(row)
{
	if(SelRow!=row)
	{
		var bar=document.getElementById('tblEXInloggs')
		if(SelRow>=0)
			bar.rows[SelRow].style.backgroundColor=SelRowBC
		if(row>=0)
		{
			SelRowBC=bar.rows[row].style.backgroundColor
			bar.rows[row].style.backgroundColor="#7A7AE5"
		}
		smap[0] = bar.rows[row].cells[0].innerHTML;
		smap[1] = bar.rows[row].cells[1].innerHTML;
		smap[2] = bar.rows[row].cells[2].innerHTML;
		smap[3] = bar.rows[row].cells[3].innerHTML;
		SelRow=row
	}
}

function DeleteRow(row)
{
	if(SelRow!=row)
	{
		var bar=document.getElementById('tblEXInloggs');
		var tblrow = bar.rows[row];
		
		bar.rows[row].remove(tblrow);

		SelRow=0;
	}
}

function topWindow(sPicPath)
{
	popup = window.open("/Script/showPic.asp?pic="+sPicPath, "", "height=100, width=100, resizable=yes, titlebar=no, directories=no, statusbar=no");
	//scrollbars=no, toolbar=no, menubar=no, location=no, titlebar=no, fullscreen=no
	//"height=250, width=700, resizable=yes, titlebar=no, directories=no, statusbar=no"
}

//Javascript från frmMain.aspx
var showDiID
var theForm = document.forms['CatalogForm'];

if (!theForm) {
	theForm = document.CatalogForm;
}

function fnShowDialog()
{
	showDiID = showModelessDialog("frmLoggin.aspx",window,"status:false;dialogWidth:350px;dialogHeight:250px");
}

function openLoggin()
{
	window.open("frmLoggin.aspx", "_blank", "height=250,width=350,status=yes,toolbar=no,menubar=no,location=no");
}


function clickIt(strClick)  
{
    /*txtOutput.value = window.event.srcElement.tagName;
    txtOutput1.value = window.event.srcElement.type;*/

    if ((window.event.srcElement.tagName) && ("IMG"))
	{
		if(!confirm("Har du klickat p&auml; img onClick? :-)" + strClick))
			{SelectRow(-1); return;}  
	}
}

function updatePage(){
	//alert("Focus har vi fått nu!!");
	if (update)
	{
		location.reload();
		update=false;
	}
	
	var e = document.getElementById("lblStat");
	e.value = "Detta funkar ju!!";
}

function setFieldFocus(){
    if(fieldName.length>0){
		var e = document.getElementById(fieldName);
		e.style.background="#F6EAEF";
        e.focus();
    }
}

function moveVVData(bodyScrollTop)
{
	var vvData = document.getElementById("vvData");
	
	if (bodyScrollTop > vvDataTop)
	{
		vvData.style.top = bodyScrollTop;
		//alert("bodyScrollTop="+bodyScrollTop+" "+"vvData.top="+vvData.top);
	}
	else
	{
		vvData.style.top = vvDataTop;
	}

	/*
	Lägg till i body-taggen
	onscroll="javascript:moveVVData(document.body.scrollTop);" 

	var stat = document.getElementById('txtPos');
	
	stat.value = bodyScrollTop + ":" + vvData.offsetTop + ":" + vvDataTop;
	*/

}