	// global value, defined without 'var' tag !
	currHighlightNo = 1;

	// for each new document reset currHighlightNo
	function resetCurrHighlight()
	{
		currHighlightNo = 1;
	}

	// when user see a document he may be want to see previous result list
	function getSearchList()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		parent.searchmain.location.href = "http://alt2.makrolog.de/cgi-bin/netisgate.exe?qtype=004" + 
          		      "&dbid=" + parent.searchmain.document.documentform.dbid.value +	
					  "&resNo=" + parent.searchmain.document.documentform.resno.value +
					  "&pageNo=" + parent.searchmain.document.documentform.pageno.value +
					  "&listType=" + parent.searchmain.document.documentform.listtype.value +
					  "&titleCount=" + parent.searchmain.document.documentform.titlecount.value;
         parent.searchbuttons.location.href = "SearchNav2.html"
	}

	function docFormFound()
	{
		alert( "docFormFound" );
                alert( parent.frames.length );
	
		for (i=0; i < parent.searchmain.document.forms.length; i++) 
		{
			if (parent.searchmain.document.forms[i].name == "documentform")
			{
				return 1;
			}
		}
		return 0;
	}

	function getDocument(docNo)
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		parent.searchmain.location.href = "http://alt2.makrolog.de/cgi-bin/netisgate.exe?qtype=003" + 
					  "&dbid=" + parent.searchmain.document.documentform.dbid.value +	
					  "&resNo=" + parent.searchmain.document.documentform.resno.value +
					  "&pageNo=" + parent.searchmain.document.documentform.pageno.value +
					  "&listType=" + parent.searchmain.document.documentform.listtype.value +
					  "&titleCount=" + parent.searchmain.document.documentform.titlecount.value +
					  "&docNo=" + docNo + "#HLN1";
		resetCurrHighlight();
	}
	
	function getPreviousDocument()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		var prevdocno = parseInt(parent.searchmain.document.documentform.docno.value) - 1;
		if(prevdocno>=0)
			getDocument(prevdocno);
		else
			alert("First document reached");
	}

	function getNextDocument()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		var nextdocno = parseInt(parent.searchmain.document.documentform.docno.value) + 1;
		if(nextdocno < parseInt(parent.searchmain.document.documentform.maxdocno.value))
			getDocument(nextdocno);
		else
			alert("Last document reached");
	}

	function getPreviousHighlight()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		if(currHighlightNo > 1)
		{
			var newLocation = parent.searchmain.location.href;
			var endLocation = newLocation.length, i;
			for(i=0; i < endLocation; i++)
			{
				if(newLocation.charAt(i)=="#")
					break;
			}
			parent.searchmain.location.href = newLocation.substring(0,i) + "#HLN" + --currHighlightNo;
		}
		else
		{
			alert("First highlight reached");
		}
	}

	function getNextHighlight()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		var max = parseInt(parent.searchmain.document.documentform.maxhighlightno.value); 
		if(currHighlightNo < max)
		{
			var newLocation = parent.searchmain.location.href;
			var endLocation = newLocation.length, i;
			for(i=0; i < endLocation; i++)
			{
				if(newLocation.charAt(i)=="#")
					break;
			}
			parent.searchmain.location.href = newLocation.substring(0,i) + "#HLN" + ++currHighlightNo;
		}
		else
		{
			alert("Last highlight reached");
		}
	}

	function getMentions()
	{
		if(!docFormFound())
		{
			alert("This button is enabled when any document is loaded");
			return;
		}

		parent.searchmain.location.href = "http://alt2.makrolog.de/cgi-bin/netisgate.exe?qtype=005" + 
					  "&dbid=" + parent.searchmain.document.documentform.dbid.value +	
					  "&resNo=" + parent.searchmain.document.documentform.resno.value +
					  "&pageNo=0" +
					  "&listType=" + parent.searchmain.document.documentform.listtype.value +
					  "&titleCount=" + parent.searchmain.document.documentform.titlecount.value +
					  "&docNo=" + parent.searchmain.document.documentform.docno.value;
        parent.searchbuttons.location.href = "SearchNav2.html"                      
	}

	function Submitted()
	{
         parent.searchbuttons.location.href = "SearchNav2.html"
	}

