/**
 *  File for printing resultlist for searching in LMS on searchResult.jsp
 *
 */
function lmsReceiverFunc(searchresult)
{
 //create and set values for parsing next hit in result
  var fmr=0,lastListhit=0, htmlTextALMS = "", htmlTextOMR = "", htmlTextVars = "", htmlTextDocumentAccessCode = "", htmlTextSOCN = "", htmlTextSBY = "", htmlTextB = "", htmlTextUARF = "", htmlText = "", htmlTextATGB = "";
  fmr = parseInt(document.getElementById('firstMatchToReturnLMS').value);

  if(fmr > (searchresult.totalMatches - (fmr + 10))){
    if(searchresult.totalMatches - fmr >= 10){
      lastListhit = fmr + 10 - 1;
    }
    else{lastListhit = searchresult.totalMatches; }
  }
  else{lastListhit = fmr+9;}

  if(searchresult.totalMatches==0){
    fmr=0;
  }

  //deletes loading-image
  while (document.getElementById("LMShits").childNodes.length > 0)
    document.getElementById("LMShits").removeChild(document.getElementById("LMShits").firstChild);

  //adds header for LMS
  var tbod=document.getElementById("LMShits");
  var trow = document.createElement("tr");
  var th1 = document.createElement("th");
  if(document.getElementById("user").value=="member"){
    th1.setAttribute("colSpan", "4");
  }
  else{th1.setAttribute("colSpan", "3");}
  th1.appendChild(document.createTextNode(propertyLMSName));
  if(fmr>0){
    var span = document.createElement("span");
    if(searchresult.totalMatches>10)
      span.appendChild(document.createTextNode(" "+fmr + "-" + (lastListhit) + " "+propertyTotal+" " + searchresult.totalMatches+" "+propertyHits));
    else if(searchresult.totalMatches==1)
      span.appendChild(document.createTextNode(" "+searchresult.totalMatches+" "+propertyHit));
    else
      span.appendChild(document.createTextNode(" "+searchresult.totalMatches+" "+propertyHits));
    th1.appendChild(span);
   }
  trow.appendChild(th1);
  tbod.appendChild(trow);

   var linkInfo = document.createElement("a");
      linkInfo.setAttribute("href", "javascript:showHideLMSInfo();");
       var imgInfo = document.createElement("img");
      imgInfo.src="../images/info.gif";
      imgInfo.alt=propertyHelptext;
      imgInfo.title=propertyHelptext;
      linkInfo.appendChild(imgInfo);
      th1.appendChild(linkInfo);
      trow.appendChild(th1);
      tbod.appendChild(trow);


    var trowInfo = document.createElement("tr");
    trowInfo.setAttribute("id","lmsInfo");
     trowInfo.className='descriptionHidden';
    var tdInfo = document.createElement("td");
	 tdInfo.setAttribute("id","lmsInfoTD");
    if(document.getElementById("user").value=="member"){
      tdInfo.setAttribute("colSpan", "4");
    }
    else{tdInfo.setAttribute("colSpan", "3");}
     var spanInfo = document.createElement("span");
     spanInfo.appendChild(document.createTextNode(propertyLMSDescription));
     tdInfo.appendChild(spanInfo);
     trowInfo.appendChild(tdInfo);
     tbod.appendChild(trowInfo);

  if(fmr==0){
    tbod.appendChild(createInfoRow(propertyNoHits));
  }else if(fmr > 0 && searchresult.documents.length == 0){
    tbod.appendChild(createInfoRow(propertyToManyHits));
  } else{
  //parsing hits and adding rows to table
  
  for(var i=0; i<searchresult.documents.length; i++)
  {
    var nbOfImages=0;
    htmlTextSOCN="";
    htmlTextSBY="";
    htmlTextATGB="";
    htmlTextUARF="";
    htmlTextVars="";
    htmlTextALMS="";
    htmlTextOMR="";

    	for(var l=0; l<searchresult.documents[i].paragraphGroups.length; l++){
      		if(searchresult.documents[i].paragraphGroups[l].name == "LSB"){
        		for(var m=0; m<searchresult.documents[i].paragraphGroups[l].paragraphs.length; m++){
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "SOCN"){
						htmlTextSOCN=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "SBY"){
						htmlTextSBY=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
				}
			}

			if(searchresult.documents[i].paragraphGroups[l].name == "ATG"){
        		for(var m=0; m<searchresult.documents[i].paragraphGroups[l].paragraphs.length; m++){
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "ATGBESK"){
						htmlTextATGB=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
				}
			}

		}
		   
    	for(var j=0; j<searchresult.documents[i].paragraphs.length; j++)
    	{
        	if(searchresult.documents[i].paragraphs[j].name == "ANBI"){
          		nbOfImages=searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "UARF"){
          		htmlTextUARF = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "BASE"){
          		htmlTextBase = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "KTUN"){
          		htmlTextKtun = searchresult.documents[i].paragraphs[j].text;
        	}
			if(searchresult.documents[i].paragraphs[j].name == "ALMS"){
          		htmlTextALMS = searchresult.documents[i].paragraphs[j].text;
        	}
			if(searchresult.documents[i].paragraphs[j].name == "OMR"){
          		htmlTextOMR = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "ARTA"){
          		htmlTextARTA = searchresult.documents[i].paragraphs[j].text;
        	}
   	 	}

    //create and adds table cells with values
     var trow = document.createElement("tr");

    //adds column with link to map
    var td1 = document.createElement("td");
    //create base text for first column in search result list
    var txt = createDocumentLinkText(htmlTextSOCN, htmlTextSBY, htmlTextOMR, htmlTextALMS);
     if(nbOfImages>0){
        var images="";
        if(nbOfImages=="1")
          images=propertyImage;
        else
         images=propertyImages;
       var link = document.createElement("a");
        link.setAttribute("href", "show.html?showmap=true&archive=LMS&nbOfImages="+nbOfImages+"&sd_base="+htmlTextBase+"&sd_ktun="+htmlTextKtun);
       if(document.getElementById("user").value=="member"){
         link.appendChild(document.createTextNode(txt+" ("+nbOfImages+" "+images+")"));
       }
       else{
        link.appendChild(document.createTextNode(txt));
       }
       td1.appendChild(link);
       trow.appendChild(td1);
     }
     else{
        td1.appendChild(document.createTextNode(txt));
        trow.appendChild(td1);
     }

      //adds column with task
     var td2 = document.createElement("td");

     if(htmlTextATGB!="")
      td2.appendChild(document.createTextNode(htmlTextATGB));
     else
      td2.appendChild(document.createTextNode("-"));
     trow.appendChild(td2);

     //adds column with year
     var td3 = document.createElement("td");
     if(htmlTextUARF!="")
      td3.appendChild(document.createTextNode(htmlTextUARF));
     else
      td3.appendChild(document.createTextNode("-"));
     trow.appendChild(td3);

      //adds forth column for member users

      if(document.getElementById("user").value=="member"){
           var td4 = document.createElement("td");
           var link2 = document.createElement("a");
           link2.setAttribute("href", "show.html?showmap=false&archive=LMS&nbOfImages="+nbOfImages+"&sd_base="+htmlTextBase+"&sd_ktun="+htmlTextKtun);
           link2.appendChild(document.createTextNode("Info"));
           td4.appendChild(link2);
           trow.appendChild(td4);
      }
     tbod.appendChild(trow);
   }

   //Next hit in searchresultlist
   var l=1;
   var bolForegaende=false;
   var current=0;
   var htmlTextF="";

  trow = document.createElement("tr");
  td1 = document.createElement("td");
  if(document.getElementById("user").value=="member"){
   td1.setAttribute("colSpan", "4");
   }
   else{td1.setAttribute("colSpan", "3");}
  td1.className='pages';


   if( Math.ceil(fmr/10)  > 10+1){//sets start-value for l in for-loop
   l = Math.ceil(fmr/10) - 10;
 }

 if(lastListhit>=10){//Dont write any numbers if lastListhit>=10

 for(l; l<=(Math.ceil(searchresult.totalMatches/10)); l++){
    if((l*(10-1)) > searchresult.totalMatches+10 || (l >= Math.ceil(fmr/10) + 10))
    {
      break;
    }
    else{
      if(((l*10) >= fmr) && ((l*10)<= fmr+10)){
        if(parseInt(searchresult.totalMatches)!=10){
          var strongele = document.createElement("strong");  //create link with number
          strongele.appendChild(document.createTextNode(parseInt(l)));
          td1.appendChild(strongele);
        }
        current=l;
      }
      else{
        var link = document.createElement("a");  //create link with number
        link.setAttribute("href", "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS="+parseInt(((l*10)+1)-10)+"&firstMatchToReturnRAK="+document.getElementById('firstMatchToReturnRAK').value+"&firstMatchToReturnREG="+document.getElementById('firstMatchToReturnREG').value+"&yMin="+document.getElementById('yMin').value+"&xMin="+document.getElementById('xMin').value+"&yMax="+document.getElementById('yMax').value+"&xMax="+document.getElementById('xMax').value);
        link.appendChild(document.createTextNode(parseInt(l)));
        td1.appendChild(link);
      }
    }
  }

  if((l-1)!=current || lastListhit<searchresult.totalMatches){
    var link = document.createElement("a");  //create link with next
     var linkLast = document.createElement("a");  //create link with next
     var last=searchresult.totalMatches;
     //calculate
     last=calculateLast(last);

    link.setAttribute("href", "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS="+parseInt(fmr+10)+"&firstMatchToReturnREG="+document.getElementById('firstMatchToReturnREG').value+"&firstMatchToReturnRAK="+document.getElementById('firstMatchToReturnRAK').value+"&yMin="+document.getElementById('yMin').value+"&xMin="+document.getElementById('xMin').value+"&yMax="+document.getElementById('yMax').value+"&xMax="+document.getElementById('xMax').value);
    link.appendChild(document.createTextNode(propertyNext));

    linkLast.setAttribute("href", "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS="+last+"&firstMatchToReturnREG="+document.getElementById('firstMatchToReturnREG').value+"&firstMatchToReturnRAK="+document.getElementById('firstMatchToReturnRAK').value+"&yMin="+document.getElementById('yMin').value+"&xMin="+document.getElementById('xMin').value+"&yMax="+document.getElementById('yMax').value+"&xMax="+document.getElementById('xMax').value);
    linkLast.appendChild(document.createTextNode(propertyLast));

    td1.appendChild(link);
    td1.appendChild(linkLast);

  }
  if(current>1){
    //create link with previous
    var linkPrevious = document.createElement("a");
    linkPrevious.setAttribute("href", "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS="+parseInt(fmr-10)+"&firstMatchToReturnREG="+document.getElementById('firstMatchToReturnREG').value+"&firstMatchToReturnRAK="+document.getElementById('firstMatchToReturnRAK').value+"&yMin="+document.getElementById('yMin').value+"&xMin="+document.getElementById('xMin').value+"&yMax="+document.getElementById('yMax').value+"&xMax="+document.getElementById('xMax').value);
    linkPrevious.appendChild(document.createTextNode(propertyPrevious));
    td1.insertBefore(linkPrevious,td1.firstChild);
    //create link with first
    var linkFirst = document.createElement("a");
    linkFirst.setAttribute("href", "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS=1&firstMatchToReturnREG="+document.getElementById('firstMatchToReturnREG').value+"&firstMatchToReturnRAK="+document.getElementById('firstMatchToReturnRAK').value+"&yMin="+document.getElementById('yMin').value+"&xMin="+document.getElementById('xMin').value+"&yMax="+document.getElementById('yMax').value+"&xMax="+document.getElementById('xMax').value);
    linkFirst.appendChild(document.createTextNode(propertyFirst));
    td1.insertBefore(linkFirst,td1.firstChild);
  }
  }

   if(lastListhit>=10 && (searchresult.totalMatches <10 || searchresult.totalMatches >10)){
    trow.appendChild(td1);
    tbod.appendChild(trow);
  }
  }
}

function lmsReceiverFuncAdvanced(searchresult)
{
 //create and set values for parsing next hit in result
 var mapTypeValue="", mapTypeSelectedValue="";

 if(document.getElementById("mapType") && document.getElementById("mapTypeSelected")){
    mapTypeValue=document.getElementById("mapType").value;
    mapTypeSelectedValue=document.getElementById("mapTypeSelected").value;
 }

  var fmr=0,lastListhit=0, htmlTextALMS = "", htmlTextARTA = "", htmlTextOMR = "", htmlTextBase = "", htmlTextKtun = "", htmlTextDocumentAccessCode = "", htmlTextSOCN = "", htmlTextSBY = "", htmlTextATGB = "", htmlTextUARF = "", htmlText = "";
  fmr = parseInt(document.getElementById('firstMatchToReturnLMS').value);

  if(fmr > (searchresult.totalMatches - (fmr + 10))){
    if(searchresult.totalMatches - fmr >= 10){
      lastListhit = fmr + 10 - 1;
    }
    else{lastListhit = searchresult.totalMatches; }
  }
  else{lastListhit = fmr+9;}

  if(searchresult.totalMatches==0){
    fmr=0;
  }

  //deletes loading-image
  while (document.getElementById("LMShits").childNodes.length > 0)
  document.getElementById("LMShits").removeChild(document.getElementById("LMShits").firstChild);

  //adds header for LMS
  var tbod=document.getElementById("LMShits");
  var trow = document.createElement("tr");
  var th1 = document.createElement("th");
  if(document.getElementById("user").value=="member"){
    th1.setAttribute("colSpan", "4");
  }
  //else{th1.setAttribute("colSpan", "4");}
  else{th1.setAttribute("colSpan", "3");}
  th1.appendChild(document.createTextNode(propertyLMSName));
  if(fmr>0){
    var span = document.createElement("span");
    if(searchresult.totalMatches>10)
      span.appendChild(document.createTextNode(" "+fmr + "-" + (lastListhit) + " "+propertyTotal+" " + searchresult.totalMatches+" "+propertyHits));
    else if(searchresult.totalMatches==1)
      span.appendChild(document.createTextNode(" "+searchresult.totalMatches+" "+propertyHit));
    else
      span.appendChild(document.createTextNode(" "+searchresult.totalMatches+" "+propertyHits));
    th1.appendChild(span);
    }
  trow.appendChild(th1);
  tbod.appendChild(trow);

  if(fmr==0){
    tbod.appendChild(createInfoRow(propertyNoHits));
  }else if(fmr > 0 && searchresult.documents.length == 0){
    tbod.appendChild(createInfoRow(propertyToManyHits));
  }else{
  //parsing hits and adding rows to table


  for(var i=0; i<searchresult.documents.length; i++)
  {
    var nbOfImages=0;
    htmlTextSOCN="";
    htmlTextSBY="";
    htmlTextVars="";
    htmlTextUARF="";
    htmlTextATGB="";
    htmlTextALMS="";
    htmlTextOMR="";
    htmlTextARTA="";
	
	

    	for(var l=0; l<searchresult.documents[i].paragraphGroups.length; l++){
      		if(searchresult.documents[i].paragraphGroups[l].name == "LSB"){
        		for(var m=0; m<searchresult.documents[i].paragraphGroups[l].paragraphs.length; m++){
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "SOCN"){
						htmlTextSOCN=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "SBY"){
						htmlTextSBY=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
				}
			}

			if(searchresult.documents[i].paragraphGroups[l].name == "ATG"){
        		for(var m=0; m<searchresult.documents[i].paragraphGroups[l].paragraphs.length; m++){
					if(searchresult.documents[i].paragraphGroups[l].paragraphs[m].name == "ATGBESK"){
						htmlTextATGB=searchresult.documents[i].paragraphGroups[l].paragraphs[m].text;
					}
				}
			}
			
		}
		   
    	for(var j=0; j<searchresult.documents[i].paragraphs.length; j++)
    	{
        	if(searchresult.documents[i].paragraphs[j].name == "ANBI"){
          		nbOfImages=searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "UARF"){
          		htmlTextUARF = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "BASE"){
          		htmlTextBase = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "KTUN"){
          		htmlTextKtun = searchresult.documents[i].paragraphs[j].text;
        	}
			if(searchresult.documents[i].paragraphs[j].name == "ALMS"){
          		htmlTextALMS = searchresult.documents[i].paragraphs[j].text;
        	}
			if(searchresult.documents[i].paragraphs[j].name == "OMR"){
          		htmlTextOMR = searchresult.documents[i].paragraphs[j].text;
        	}
        	if(searchresult.documents[i].paragraphs[j].name == "ARTA"){
          		htmlTextARTA = searchresult.documents[i].paragraphs[j].text;
        	}
   	 	}
	

    //create and adds table cells with values
    var trow = document.createElement("tr");

    //creates column with link to map
    var td1 = document.createElement("td");
    //create base text for first column in search result list

    var txt = createDocumentLinkText(htmlTextSOCN, htmlTextSBY, htmlTextOMR, htmlTextALMS);
      if(nbOfImages>0){ //if act is scanned
        var images="";
        if(nbOfImages=="1")
          images=propertyImage;
        else
         images=propertyImages;
           var link = document.createElement("a");
	
           link.setAttribute("href", "show.html?showmap=true&mapTypeSelected="+mapTypeSelectedValue+"&mapType="+mapTypeValue+"&archive=LMS&nbOfImages="+nbOfImages+"&sd_base="+htmlTextBase+"&sd_ktun="+htmlTextKtun);
           if(document.getElementById("user").value=="member"){
            link.appendChild(document.createTextNode(txt+" ("+nbOfImages+" "+images+")"));
           }
           else{
            link.appendChild(document.createTextNode(txt));
           }

           td1.appendChild(link);
           trow.appendChild(td1);
      }
      else{
	td1.appendChild(document.createTextNode(txt));
	trow.appendChild(td1);
      }

     //adds column with task
     var td2 = document.createElement("td");
     if(htmlTextATGB!="")
      td2.appendChild(document.createTextNode(htmlTextATGB));
     else
      td2.appendChild(document.createTextNode("-"));
     trow.appendChild(td2);

      //adds column with year
     var td3 = document.createElement("td");

     td3.appendChild(document.createTextNode(createDocumentYearText(htmlTextUARF, htmlTextARTA)));
     trow.appendChild(td3);

     //adds forth column for member with link to text
     if(document.getElementById("user").value=="member"){
     var td5 = document.createElement("td");
         // if(nbOfImages>0){ //if act is scanned
           var link = document.createElement("a");
           link.setAttribute("href", "show.html?showmap=false&mapTypeSelected="+mapTypeSelectedValue+"&mapType="+mapTypeValue+"&archive=LMS&nbOfImages="+nbOfImages+"&sd_base="+htmlTextBase+"&sd_ktun="+htmlTextKtun);
		   link.appendChild(document.createTextNode("Info"));
           td5.appendChild(link);
           trow.appendChild(td5);
      //}
     // else{
           // td4.appendChild(document.createTextNode("Info"));
           // trow.appendChild(td4);
     // }
     }

      tbod.appendChild(trow);
   }

   //Next hit in searchresultlist
   var l=1;
   var bolForegaende=false;
   var current=0;
   var htmlTextF="";

  trow = document.createElement("tr");
  td1 = document.createElement("td");
  if(document.getElementById("user").value=="member"){
    td1.setAttribute("colSpan", "4");
  }
  //else{td1.setAttribute("colSpan", "4");}
  else{td1.setAttribute("colSpan", "3");}
  td1.className='pages';

   if( Math.ceil(fmr/10)  > 10+1){//sets start-value for l in for-loop
   l = Math.ceil(fmr/10) - 10;
 }
 if(lastListhit>=10){//Dont write any numbers if lastListhit>=10

 for(l; l<=(Math.ceil(searchresult.totalMatches/10)); l++){

    if((l*(10-1)) > searchresult.totalMatches+10 || (l >= Math.ceil(fmr/10) + 10))
    {
      break;
    }
    else{
      if(((l*10) >= fmr) && ((l*10)<= fmr+10)){
        var strongele = document.createElement("strong");  //create link with number
        strongele.appendChild(document.createTextNode(parseInt(l)));
        td1.appendChild(strongele);
        current=l;
      }
      else{
        var link = document.createElement("a");  //create link with number
        if(document.getElementById('historyId') != null && document.getElementById('historyId').value.length > 0){
	  link.setAttribute("href", createLmsLnkHistory(parseInt(((l*10)+1)-10)));
	}else{
	  link.setAttribute("href", createLmsLnk(parseInt(((l*10)+1)-10), mapTypeSelectedValue, mapTypeValue));
	}
        link.appendChild(document.createTextNode(parseInt(l)));
        td1.appendChild(link);
      }
    }
  }

  if((l-1)!=current || lastListhit<searchresult.totalMatches){
    var link = document.createElement("a");  //create link with next
    var linkLast = document.createElement("a");  //create link with next
    var last=searchresult.totalMatches;
    //calculate
    last=calculateLast(last);
    if(document.getElementById('historyId') != null && document.getElementById('historyId').value.length > 0){
	link.setAttribute("href", createLmsLnkHistory(parseInt(fmr+10)));
    }else{
	link.setAttribute("href", createLmsLnk(parseInt(fmr+10), mapTypeSelectedValue, mapTypeValue));
    }
    link.appendChild(document.createTextNode(propertyNext));
    if(document.getElementById('historyId') != null && document.getElementById('historyId').value.length > 0){
	linkLast.setAttribute("href", createLmsLnkHistory(last));
    }else{
	linkLast.setAttribute("href", createLmsLnk(last, mapTypeSelectedValue, mapTypeValue));
    }
    linkLast.appendChild(document.createTextNode(propertyLast));

    td1.appendChild(link);
    td1.appendChild(linkLast);
  }
  if(current>1){
    var linkPrevious = document.createElement("a");  //create link with previous
    var linkFirst = document.createElement("a");  //create link with first
    if(document.getElementById('historyId') != null && document.getElementById('historyId').value.length > 0){
      linkPrevious.setAttribute("href", createLmsLnkHistory(parseInt(fmr-10)));
      linkFirst.setAttribute("href", createLmsLnkHistory(1));
    }else{
      linkPrevious.setAttribute("href", createLmsLnk(parseInt(fmr-10), mapTypeSelectedValue, mapTypeValue));
      linkFirst.setAttribute("href", createLmsLnk(1, mapTypeSelectedValue, mapTypeValue));
    }
    linkPrevious.appendChild(document.createTextNode(propertyPrevious));
    linkFirst.appendChild(document.createTextNode(propertyFirst));
    td1.insertBefore(linkPrevious,td1.firstChild);
    td1.insertBefore(linkFirst,td1.firstChild);
  }
}

  if(lastListhit>=10 && (searchresult.totalMatches <10 || searchresult.totalMatches >10)){
    trow.appendChild(td1);
    tbod.appendChild(trow);
  }
  }
}



function createLmsLnkHistory(firstMatchToReturn){
  return "searchresult.html?archive="+document.getElementById('archive').value+"&firstMatchToReturnLMS="+firstMatchToReturn+"&historyId="+document.getElementById('historyId').value;
}

function createLmsLnk(firstMatchToReturn, mapTypeSelectedValue, mapTypeValue){
  return "searchresult.html?archive="+document.getElementById('archive').value+"&mapTypeSelected="+mapTypeSelectedValue+"&mapType="+mapTypeValue+"&firstMatchToReturnLMS="+firstMatchToReturn+"&countyLMS="+document.getElementById("county").value+"&parish="+document.getElementById("parish").value+"&village="+document.getElementById("settlement").value+"&openSearchLMS="+document.getElementById("openSearch").value+"&taskLMS="+document.getElementById("task").value+"&surveyor="+document.getElementById("surveyor").value+"&yearMinLMS="+document.getElementById("yearMin").value+"&yearMaxLMS="+document.getElementById("yearMax").value+"&scanned="+document.getElementById("scanned").value+"&rbyselected="+document.getElementById("rbyselected").value;
}

function createDocumentLinkText(socn, sby, omr, alms){
  var txt = '';
  if(socn != '' && sby != ''){
    txt = socn + ' ' + sby;
  }else if(omr != ''){
    txt = omr;
  }else{
    txt = alms;
  }
  return txt;
}

function createDocumentYearText(uarf, arta){
  var txt = '';
  if(uarf != ''){
    txt = uarf;
  }else if(arta != ''){
    txt = arta;
  }else{
    txt = '-';
  }
  return txt;
}
