function clearPages() {
	document.form1.txtDoRememberOrd3.value = ''; //is only used by ordAll
	document.form1.txtSearch.value = '';
	document.form1.iViewPage.value = '';
	var oColl = document.getElementsByName("TypOfOrgan");
	if (oColl.length > 0) {
		document.form1.txtTypAvOrgan.value = document.form1.TypAvOrgan.options[document.form1.TypAvOrgan.selectedIndex].text;
	}
	oColl = document.getElementsByName("note1");
	if (oColl.length > 0) {
		document.form1.txtKravdoc.value = document.form1.note1.options[document.form1.note1.selectedIndex].text;
	}
	document.form1.target = '_self';
	document.form1.action = 'index.asp';
	document.form1.submit();
}

function clearform(sLang, sMode) {
	window.location = "index.asp?lang=" + sLang + "&mode="+sMode;
}

function SetFocus() {
	if (document.form1.language.value=='') {
		document.form1.language.value = 'sv'
	}

	var oColl = document.getElementsByName("wild");
	if (oColl.length > 0) {
		document.form1.wild.focus()
	}
}

function submitForm() {
	document.form1.txtDoRememberOrd3.value = '';	// is only used by ordAll
	document.form1.ord3.value = '';			// reset this value - only used by shortcut search
	document.form1.txtSearch.value = 'search';
	document.form1.iViewPage.value = '1';

	var oColl = document.getElementsByName("TypOfOrgan");
	if (oColl.length > 0) {
		document.form1.txtTypAvOrgan.value = document.form1.TypAvOrgan.options[document.form1.TypAvOrgan.selectedIndex].text;
	}

	oColl = document.getElementsByName("note1");
	if (oColl.length > 0) {
		document.form1.txtKravdoc.value = document.form1.note1.options[document.form1.note1.selectedIndex].text;
	}
		
	document.form1.target = '_self';
	document.form1.action = 'index.asp';
	document.form1.submit();
}

function empty_ordAll() {
	//document.form1.ordAll.value='';
}

function changeSearchMode()
{
	//empty fields used by previous searchmode, otherwise new search may be affected
	//alert(document.form1.searchmode.value);

	if (document.form1.searchmode.value == 'TYPE') {
		if (document.form1.TypAvOrgan) {
			document.form1.TypAvOrgan.value='';
		}
	}

	if (document.form1.searchmode.value == 'ACKAREA') {
		if (document.form1.ordAll)
			document.form1.ordAll.value = '';	//kk 070313
		
		if (document.form1.ord1)
			document.form1.ord1.value = '';
		
		if (document.form1.ord2)
			document.form1.ord2.value = '';

		if (document.form1.note1)
			document.form1.note1.value = '';

		if (document.form1.note2)
			document.form1.note2.value = '';
	}

	if (document.form1.searchmode.value == 'FULLTEXT') {
		if (document.form1.wild)
			document.form1.wild.value='';
	}

	if (document.form1.searchmode.value == 'COMPACK') {
		if (document.form1.CompName)
			document.form1.CompName.value='';
		
		if (document.form1.AckIdnr)	
			document.form1.AckIdnr.value='';
	}
}

function searchShortcut(ord1, ord2, note1, note2, doRememberOrd3) {

	if(doRememberOrd3) { // only used by ordAll
		document.form1.txtDoRememberOrd3.value = '1';
	}
	
	changeSearchMode();
	document.form1.searchmode.value = 'ACKAREA';	// ok to use if both ord1 and ord2 are used
	//document.form1.searchmode.value = '';		// use if only ord2 is filled in (lists: ord1="" -> ord2="" -> >3000 hits)
	
	document.form1.ord1.value = ord1;
	document.form1.ord2.value = ord2;
	//ord3 is used as ord2 may be hidden (if ord1 is "")
	document.form1.ord3.value = ord2;

	if(note1) {
		document.form1.note1_shortcut.value = note1;
		// alert('Note1: ' + note1);
	}

	if(note2) {
		document.form1.note2_shortcut.value = note2;
		// alert('Note2: ' + note2);
	}

	document.form1.txtSearch.value = 'search';
	document.form1.iViewPage.value = '1';
	document.form1.target = '_self';
	document.form1.action = 'index.asp';
		
	document.form1.submit();
}

function printselected() {
	document.form1.target = '_blank';
	document.form1.action = 'listCompanys.asp';
	document.form1.submit();
	document.form1.target = '_self';
	document.form1.action = 'index.asp';
}

function OpenPrintHelp() {
	var sLink = 'PrintHelp.asp?lang=' + document.form1.language.value;
	var sSize = 'dialogHeight:420px; dialogWidth:660px; center:yes; resizable:yes; scroll:yes; titlebar:no; toolbars:no; menubar:no; status:no; help:no; unadorned:yes';
	showModalDialog(sLink,'',sSize);
}

function OpenAckstdHelp(){
	var sLink = 'AckstdHelp.asp?lang=' + document.form1.language.value;
	var sSize = 'dialogHeight:420px; dialogWidth:660px; center:yes; resizable:yes; scroll:yes; titlebar:no; toolbars:no; menubar:no; status:no; help:no; unadorned:yes';
	showModalDialog(sLink,'',sSize);
}

function OpenFTHelp() {
	var sLink = 'FullTextHelp.asp?lang=' + document.form1.language.value;
	var sSize = 'dialogHeight:420px; dialogWidth:660px; center:yes; resizable:yes; scroll:yes; titlebar:no; toolbars:no; menubar:no; status:no; help:no; unadorned:yes';
	showModalDialog(sLink,'',sSize);
}

function opendocument(sId, iAdrId, sAckId) {
	if (sId==0 & iAdrId==0) {
		var sLink = 'geoHelp.asp?id='+sId+'&adrId='+iAdrId+'&lang='+document.form1.language.value;
	}
	else {
		var sLink = 'listCompany.asp?id='+sId+'&adrId='+iAdrId+'&sAck='+sAckId+'&lang='+document.form1.language.value;
	}
	var sSize = 'dialogHeight:420px; dialogWidth:660px; center:yes; resizable:yes; scroll:yes; titlebar:no; toolbars:no; menubar:no; status:no; help:no; unadorned:yes';
	showModalDialog(sLink,'',sSize);
}

var tempObj;
var gridClickBgColor = '#ffffff';
function bgChange(sSelId) {
	if (tempObj!="" && eval('document.all.tr'+tempObj)){
		eval('document.all.tr'+tempObj+'.style.background = "'+gridClickBgColor+'";');
		eval('document.all.trSpacetop'+tempObj+'.style.background = "'+gridClickBgColor+'";');
		eval('document.all.trSpacebottom'+tempObj+'.style.background = "'+gridClickBgColor+'";');
	}
	eval('document.all.tr'+sSelId+'.style.background = "#efefef";');
	eval('document.all.trSpacetop'+sSelId+'.style.background = "#efefef";');
	eval('document.all.trSpacebottom'+sSelId+'.style.background = "#efefef";');
	tempObj=sSelId;
}

var doNotCloseList = false;
var doShowList = true;
function hideMenuListLayer() {
	if (doNotCloseList == false) {
		if (tempObj!="" && eval('document.all.tr'+tempObj)){
			eval('document.all.tr'+tempObj+'.style.background = "#ffffff";');
			eval('document.all.trSpacetop'+tempObj+'.style.background = "#ffffff";');
			eval('document.all.trSpacebottom'+tempObj+'.style.background = "#ffffff";');			
		}
	}
	else {
		doNotCloseList = false;
	}
}

function showMenuListLayer(doItOrNot) {
	doShowList = doItOrNot;
}

function showFuncList(sId, sAck, iMal, sAckId) {
	if(doShowList && (window.event.srcElement.id.substring(0,4) != 'href')) {
		doNotCloseList = true;
		bgChange(sId);
		opendocument(sAck,iMal,sAckId);
	}
	else {
		doShowList = true;
	}
}

var selectedStatus = false;
function selectAll(iTotRows) {
	if (selectedStatus)
		selectedStatus = false;
	else
		selectedStatus = true;
	for(var i=1; i<=iTotRows; i++) {
		eval("document.form1.print"+i+".checked=" + selectedStatus + ";");
	}
}
