/**
 *  Major javascript-file for advancedsearchform.jsp, handles all init-methods, global parameters and onchangemethods.
 *
 */

// ---- constants & globals --------
var propertyCounty;
var propertyMaptype;
var propertyParish;
var propertyChooseParishArchive;
var propertyVillage;
var propertyTask;
var propertySeries;
var propertyPage;
var propertySearchHistory;
var propertySavedDocuments;
var propertyDescription;
var propertySignUpUrl;
var propertySignFullUrl;

var propertyGetSearchHistory;
var propertyGetSavedDocuments;
var propertyDeleteSavedDocument;
var propertyHistoryNotFound;
var propertySavedDocumentNotFound;
var propertySavedDocumentDeleted;
var propertyCommonSeries;
var propertyCommonCounty;
var propertyCommonPage;
var propertyCommonVillage;
var propertyGeneralError;
var propertySimpleSearch;
var propertySignUp;
var propertySignFull;
var propertyPulYear;
var propertyArchiveStartYear;
var propertyInstructions;
var propertyChooseVillage;
var propertyMunicipality;
var propertyErrorMunicipality;
var propertyErrorParish;
var browserName=navigator.appName;

// ---- / constants & globals --------


// ---- init-methods --------

function addLoadEvent(funcCall){//Eventhandlers for onload in bodytag
    var oldload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = funcCall;
    }
    else{
        window.onload = function(){
            if (oldload){
              oldload();
            }
            funcCall();
        }
    }
}

addLoadEvent(function(){
    init();//Init page using eventlistner
})

function init(){

  if (browserName=="Microsoft Internet Explorer"){//If explorer
      document.getElementById("digitalLMSDescriptionBottom").style.display="none";
  }
  else{
      document.getElementById("digitalLMSDescriptionBottom").style.display="none";
  }
  if (browserName=="Microsoft Internet Explorer"){//If explorer
  	if(document.getElementById("frREGDescriptionBottom")){
      document.getElementById("frREGDescriptionBottom").style.display="none";
	}
  }
  else{
  	if(document.getElementById("frREGDescriptionBottom")){
      document.getElementById("frREGDescriptionBottom").style.display="none";
	}
  }

  document.getElementById("countyLMSradio").checked=true;
  document.getElementById("archiveDescriptionLink").onclick=archiveDescriptionFunc;
  if(document.getElementById("searchTypeParish")){
    document.getElementById("searchTypeParish").style.display="none";//hide parish text
  }

  //add functions to events
  if(document.getElementById("historyId")){
    document.getElementById("historyId").ondblclick=doDblClickSearchHistoryFunc;
  }
  if(document.getElementById("savedId")){
    document.getElementById("savedId").ondblclick=doDblClickSavedDocumentFunc;
  }

  document.getElementById("countyLMS").onchange=fillParishLMSFunc;
  document.getElementById("mapType").onchange=setMaptypeCookieFunc;

  if(document.getElementById("countyLMSradio")){
    document.getElementById("countyLMSradio").onfocus=setMaptypeSelectedCookieFunc;
  }

  if(document.getElementById("maptypeLMSradio")){
    document.getElementById("maptypeLMSradio").onfocus=setMaptypeSelectedCookieFunc;
  }

  if(document.getElementById("scanned")){
    document.getElementById("scanned").onclick=setScannedCookieFunc;
  }
  
  if(document.getElementById("frSelected")){
    document.getElementById("frSelected").onclick=setFrSelectedCookieFunc;
  }

  if(document.getElementById("rbyselected")){
    document.getElementById("rbyselected").onclick=setRbyselectedCookieFunc;
  }

  if(document.getElementById("scanned")){
    if(getCookieWrapper("as", "scanned")=="true"){
      document.getElementById("scanned").checked=true;
    }
    else{
      document.getElementById("scanned").checked=false;
    }
  }
  
  if(document.getElementById("frSelected")){
    if(getCookieWrapper("as", "frSelected")=="true"){
      document.getElementById("frSelected").checked=true;
	  document.getElementById("frSelected").value="true";
    }
    else{
      document.getElementById("frSelected").checked=false;
	  document.getElementById("frSelected").value="false";
    }
  }

  if(document.getElementById("rbyselected")){
    if(getCookieWrapper("as", "rbyselected")=="true"){
      document.getElementById("rbyselected").checked=true;
      document.getElementById("rbyselected").value="true";
    }
    else{
      document.getElementById("rbyselected").checked=false;
      document.getElementById("rbyselected").value="false";
    }
  }

  document.getElementById("countyLMSDescriptionLink").onclick=countyLMSDescriptionFunc;
  document.getElementById("countyREGDescriptionLink").onclick=countyREGDescriptionFunc;

  document.getElementById("maptypeLMSDescriptionLink").onclick=maptypeLMSDescriptionFunc;

  document.getElementById("countyLMSradio").onclick=setMaptypeSelectedCookieFunc;
  document.getElementById("maptypeLMSradio").onclick=setMaptypeSelectedCookieFunc;

  document.getElementById("parish").onchange=fillVillagesLMSFunc;
  document.getElementById("parishLMSDescriptionLink").onclick=parishLMSDescriptionFunc;
  document.getElementById("village").onchange=allSelectedLMSFunc;
  document.getElementById("taskLMS").onclick=taskLMSFunc;
  document.getElementById("taskDescriptionLink").onclick=taskDescriptionFunc;
  document.getElementById("digitalLMSDescriptionLink").onclick=digitalLMSDescriptionFunc;
  
  if(document.getElementById("frREGDescriptionLink")){
  	document.getElementById("frREGDescriptionLink").onclick=frREGDescriptionFunc;
  }
  if(document.getElementById("rbyLMSDescriptionLink")){
    document.getElementById("rbyLMSDescriptionLink").onclick=rbyLMSDescriptionFunc;
  }

  document.getElementById("sendBtnLms").onclick=sendBtnLmsFunc;
  document.getElementById("countyREG").onchange=countyREGFunc;

  if(document.getElementById("municipalityParishREGDescriptionLink")){
    document.getElementById("municipalityParishREGDescriptionLink").onclick=municipalityParishREGDescriptionFunc;
  }

  if(document.getElementById("actVillageREGDescriptionLink")){
    document.getElementById("actVillageREGDescriptionLink").onclick=actVillageREGDescriptionFunc;
  }

  if(document.getElementById("actDescriptionRegLink")){
    document.getElementById("actDescriptionRegLink").onclick=actDescriptionRegFunc;
  }

  if(document.getElementById("villageLMSDescriptionLink")){
    document.getElementById("villageLMSDescriptionLink").onclick=villageLMSDescriptionFunc;
  }

  if(document.getElementById("searchTypeV") && document.getElementById("searchTypeD")){
    document.getElementById("searchTypeV").onclick=searchTypeVFunc;
    document.getElementById("searchTypeD").onclick=searchTypeDFunc;
  }

  if(document.getElementById("searchTypeM") && document.getElementById("searchTypeP")){
    document.getElementById("searchTypeM").onclick=searchTypeMFunc;
    document.getElementById("searchTypeP").onclick=searchTypePFunc;
  }


  document.getElementById("taskREG").onclick=taskREGFunc;
  document.getElementById("taskDescriptionRegLink").onclick=taskDescriptionRegFunc;

  document.getElementById("sendBtnReg").onclick=sendBtnRegFunc;
  document.getElementById("series").onclick=seriesFunc;
  document.getElementById("showHideSeriesInfoLink").onclick=showHideSeriesInfoFunc;
  document.getElementById("countyRAK").onclick=countyRAKFunc;
  document.getElementById("page").onclick=pageFunc;
  document.getElementById("sendBtnRak").onclick=sendBtnRakFunc;

  if(document.getElementById("searchHistoryBtn")){
    document.getElementById("searchHistoryBtn").onclick=searchhistoryFunc;
  }
  if(document.getElementById("savedDocumentBtn")){
    document.getElementById("savedDocumentBtn").onclick=saveddocumentFunc;
  }
  if(document.getElementById("savedDocumentDeleteBtn")){
    document.getElementById("savedDocumentDeleteBtn").onclick=savedDocumentDeleteBtnFunc;
  }
  if(document.getElementById("surveyorLink")){
    document.getElementById("surveyorLink").onclick=surveyorLinkFunc;
  }
  if(document.getElementById("archive")){
    document.getElementById("archive").onchange=archiveFunc;
  }
  if(document.getElementById("searchFormLMS")){
    document.getElementById("searchFormLMS").onsubmit=searchFormLMSFunc;
  }
  if(document.getElementById("searchFormREG")){
    document.getElementById("searchFormREG").onsubmit=searchFormREGFunc;
  }
  if(document.getElementById("searchFormRAK")){
    document.getElementById("searchFormRAK").onsubmit=searchFormRAKFunc;
  }


  setGlobals();//Call for globals
 

}

function archiveDescriptionFunc(){
  showHide('archiveDescription');
}
function countyLMSradioFunc(){
  document.getElementById("sendBtnLmsSubmit").className  ="sendBtn-padding";//change classname for search and clear button
  document.getElementById("sendBtnLms").className  ="sendBtn";//change classname for search and clear button
  document.getElementById("li-checkbox").className  ="mapTypeExpand";
  document.getElementById("li-checkboxDesc").className  ="mapTypeExpand";
  document.getElementById("countyLMSLi").style.display="block";


  document.getElementById("maptypeLMSLi").style.display="none";
  document.getElementById("hideparish").style.display="block";
  document.getElementById("hidevillage").style.display="block";
  document.getElementById("hideyearminlms").style.display="block";
  document.getElementById("hideyearmaxlms").style.display="block";
  document.getElementById("hidesurveyor").style.display="block";
  document.getElementById("hidesurveyordescription").style.display="block";
  document.getElementById("hidetasklms").style.display="block";
  document.getElementById("hidetaskdescription").style.display="block";
  if(document.getElementById("openSearchLMSLi")){
    document.getElementById("openSearchLMSLi").style.display="block";
  }
}
function maptypeLMSradioFunc(){
  document.getElementById("sendBtnLmsSubmit").className  ="sendBtn-paddingUp";//change classname for search and clear button
  document.getElementById("sendBtnLms").className  ="sendBtnUp";//change classname for search and clear button
  document.getElementById("li-checkbox").className  ="mapTypeShrink";
  document.getElementById("li-checkboxDesc").className  ="mapTypeShrink";
  document.getElementById("countyLMSLi").style.display="none";
  document.getElementById("maptypeLMSLi").style.display="block";
  document.getElementById("hideparish").style.display="none";
  document.getElementById("parishLMSDescription").style.display="none";
  document.getElementById("hidevillage").style.display="none";
  document.getElementById("villageLMSDescription").style.display="none";
  document.getElementById("hideyearminlms").style.display="none";
  document.getElementById("hideyearmaxlms").style.display="none";
  document.getElementById("hidesurveyor").style.display="none";
  document.getElementById("hidesurveyordescription").style.display="none";
  document.getElementById("hidetasklms").style.display="none";
  document.getElementById("hidetaskdescription").style.display="none";
  if(document.getElementById("openSearchLMSLi")){
    document.getElementById("openSearchLMSLi").style.display="none";
  }
}


function fillParishLMSFunc(){
  hideReferensCheckbox();//hide referens checkbox
  fillParishLMS();
}
function countyLMSDescriptionFunc(){
  showHide('countyLMSDescription');
}
function countyREGDescriptionFunc(){
  showHide('countyREGDescription');
}
function maptypeLMSDescriptionFunc(){
  showHide('maptypeLMSDescription');
}
function fillVillagesLMSFunc(){
  hideReferensCheckbox();
  fillVillagesLMS();
}
function parishLMSDescriptionFunc(){
  showHide('parishLMSDescription');
}
function allSelectedLMSFunc(){
  if(document.getElementById("li-rby")){
    if(document.getElementById("village").selectedIndex==0){
      hideReferensCheckbox();
    }
    else{
      showReferensCheckbox();
    }
  }
  allSelectedLMS();
}
function villageLMSDescriptionFunc(){
  showHide('villageLMSDescription')
}
function taskLMSFunc(){
  setLMSTaskCookie();
}
function taskDescriptionFunc(){
  showHide('taskDescription');
}
function digitalLMSDescriptionFunc(){
  showHide('digitalLMSDescription');
}
function frREGDescriptionFunc(){
  showHide('frREGDescription');
}
function rbyLMSDescriptionFunc(){
  showHide('rbyLMSDescription');
}
function sendBtnLmsFunc(){
  clearLMSFields();
}
function countyREGFunc(){
  setREGCountyCookie();
  resetMunicipalityCookie();
  resetParishCookie();
  setMunParList();
}

function showReferensCheckbox(){
  //show referens checkbox
  if(document.getElementById("li-rby")){
    if(document.getElementById("village").selectedIndex!=0){
      document.getElementById("li-rby").style.display="block";
    }
    else{
      document.getElementById("li-rby").style.display="none";
    }
  }

}

function hideReferensCheckbox(){
  //hide referens checkbox
  if(document.getElementById("li-rby")){
    document.getElementById("rbyselected").value="false";
    document.getElementById("rbyselected").checked=false;
    document.getElementById("li-rby").style.display="none";
  }
}

function setMunParList(){
  var county="";
  if(document.getElementById("countyREG") && document.getElementById("munParREG")){
    county=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].text;
    countyValue=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].value;
    if(countyValue==""){//if county is välj län then reset municipality/parish droplist
      DWRUtil.removeAllOptions("munParREG");
    }
    else{
      //set droplist for municipality or parish
      if(document.getElementById("searchTypeM") && document.getElementById("searchTypeM").checked==true){//fill municipality droplist
        SearchClass.getRegMunicipalitys(county,{callback:regMunicipalityReceiverFunc, errorHandler:majorErrorHandler});
      }
      else if(document.getElementById("searchTypeP") && document.getElementById("searchTypeP").checked==true){//fill parish droplist
        SearchClass.getRegParish(county,{callback:regParishReceiverFunc, errorHandler:majorErrorHandler});
      }
    }
  }
}

function countyREGDescriptionFunc(){
  showHide('countyREGDescription');
}
function parishREGDescriptionFunc(){
  showHide('parishREGDescription');
}
function municipalityParishREGDescriptionFunc(){
  showHide('municipalityParishREGDescription');
}
function actVillageREGDescriptionFunc(){
  showHide('actVillageREGDescription');
}

function actDescriptionRegFunc(){
  showHide('actDescriptionReg');
}



function searchTypeVFunc(){
  chooseSearchType('v');
}
function searchTypeDFunc(){
  chooseSearchType('d');
}

function searchTypeMFunc(){
  resetMunicipalityCookie();//reset municipality cookie when user click on municipality radio
  searchTypeCountyMunFunc();//set countylist and municipalitylist

  document.getElementById("searchTypeVillageStar").className  ="span-star-red";
  document.getElementById("searchTypeActStar").className  ="span-star-red";
}

function searchTypePFunc(){
  resetParishCookie();//reset parish cookie when user click on parish radio
  searchTypeCountyParFunc();//set countylist andparishlist

  document.getElementById("searchTypeVillageStar").className  ="span-star-white";
  document.getElementById("searchTypeActStar").className  ="span-star-white";
}

function resetMunicipalityCookie(){
  if(getCookieWrapper("as", "munParREG")!=null){
    deleteCookieWrapper("as","munParREG");
  }
}

function resetParishCookie(){
  if(getCookieWrapper("as", "munParREG")!=null){
    deleteCookieWrapper("as","munParREG");
  }
}

function searchTypeCountyMunFunc(){

  var county="";
  if(document.getElementById("countyREG")){
    county=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].text;
    countyValue=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].value;
    if(countyValue!=""){
       SearchClass.getRegMunicipalitys(county,{callback:regMunicipalityReceiverFunc, errorHandler:majorErrorHandler});
    }
    else{//if county is välj län then reset municipality/parish droplist
      DWRUtil.removeAllOptions("munParREG");
    }
  }
  chooseSearchType('m');
}



function searchTypeCountyParFunc(){
  var county="";
  if(document.getElementById("countyREG")){
    county=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].text;
    countyValue=document.getElementById("countyREG").options[document.getElementById("countyREG").selectedIndex].value;
    if(countyValue!=""){
       SearchClass.getRegParish(county,{callback:regParishReceiverFunc, errorHandler:majorErrorHandler});
    }
    else{//if county is välj län then reset municipality/parish droplist
      DWRUtil.removeAllOptions("munParREG");
    }
  }
  chooseSearchType('p');
}


function villageREGDescriptionFunc(){
  showHide('villageREGDescription');
}
function actREGDescriptionFunc(){
  showHide('actREGDescription');
}
function taskREGFunc(){
  setREGTaskCookie();
}
function taskDescriptionRegFunc(){
  showHide('taskDescriptionReg');
}
function actDescriptionRegFunc(){
  showHide('actDescriptionReg');
}
function sendBtnRegFunc(){
  clearREGFields();
}
function seriesFunc(){
  fillCountysRAK();
}
function showHideSeriesInfoFunc(){
  showHideSeriesInfo();
}
function countyRAKFunc(){
  fillPagesRAK();
}
function pageFunc(){
  allSelectedRAK();
}
function sendBtnRakFunc(){
  clearRAKFields();
}
function searchhistoryFunc(){
  setFormCookiesForSearchHistoryAndSavedActs();//set cookies in form before leaving the search via search history or saved act
  if(!validateHistory()){
    return false;
  }
}
function saveddocumentFunc(){
  setFormCookiesForSearchHistoryAndSavedActs();//set cookies in form before leaving the search via search history or saved act
  if(validateSavedDocument()){
	sendSavedAct();
  }
}
function doDblClickSavedDocumentFunc(){
  setFormCookiesForSearchHistoryAndSavedActs();//set cookies in form before leaving the search via search history or saved act
  if(validateSavedDocument()){
	sendSavedAct();
  }
}



function savedDocumentDeleteBtnFunc(){
  deleteSavedDocument();
}
function surveyorLinkFunc(){
  showHide('surveyorlmsdescription');
}
function archiveFunc(){
  switchPanes();
}
function searchFormLMSFunc(){
  if(validateLMS()){
    return true;
  }
  else{
    return false;
  }
}
function searchFormREGFunc(){
  return validateREG();
}
function searchFormRAKFunc(){
  return validateRAK();
}

function setFormCookiesForSearchHistoryAndSavedActs(){
  if(document.getElementById("user").value=="member"){
    if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="REG"){
      setREGTextCookies();
      createREGCookies();
    }
    else if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="LMS"){
      setLMSTextCookies();
      createLMSCookies();
    }
    else if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="RAK"){
      createRAKCookies();
    }
  }
}


/*function buildInstructions(){
  document.getElementById("instructionsAdvanceSearch").style.display="none";

  var div = document.getElementById("instructionsAdvanceSearch");
  var line1 = document.createElement("p");

  line1.appendChild(document.createTextNode(propertyInstructions));
  div.appendChild(line1);
}*/


function fillMunPar(){
  if(getCookieWrapper("as", "searchTypeM")=="m"){
    searchTypeCountyMunFunc();
    chooseSearchType("m");
    document.getElementById("searchTypeM").checked="true";
    document.getElementById("searchTypeVillageStar").className  ="span-star-red";
    document.getElementById("searchTypeActStar").className  ="span-star-red";
  }
  else if(getCookieWrapper("as", "searchTypeP")=="p"){
    searchTypeCountyParFunc();
    chooseSearchType("p");
    document.getElementById("searchTypeP").checked="true";
    document.getElementById("searchTypeVillageStar").className  ="span-star-white";
    document.getElementById("searchTypeActStar").className  ="span-star-white";
  }

}

function fillLists(){

  //alert(getCookieValue("as", "yearto"));//test for cookievalues
  //setCookieValue("as", "yearfrom", "1987")
  //setGlobals(); //sets global propertys
  if(document.getElementById("user").value!="member"){
    chooseSearchType("v");//Set village to default
      if(getCookieWrapper("as", "searchTypeV")=="v"){
        document.getElementById("searchTypeV").checked="true";
        chooseSearchType("v");
      }
      else if(getCookieWrapper("as", "searchTypeD")=="d"){
        document.getElementById("searchTypeD").checked="true";
        chooseSearchType("d");
      }
  }

  if(getCookieWrapper("as", "archive")!=null){ //if cookie exists
    document.getElementById("archive").selectedIndex=getCookieWrapper("as", "archive");
  }

  hideAndShow(); //sets panels and fetches searchhistory and saved document



}

function hideAndShow(){

        if(document.getElementById("user").value=="member"){
          DWRUtil.removeAllOptions("historyId");
          DWRUtil.addOptions("historyId", [propertyGetSearchHistory]);
          DWRUtil.removeAllOptions("savedId");
          DWRUtil.addOptions("savedId", [propertyGetSavedDocuments]);
        }
        var historyid = document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value;

        if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="REG"){
		document.getElementById("searchFormLMS").style.display = "none";
                document.getElementById("searchFormRAK").style.display = "none";
		document.getElementById("searchFormREG").style.display = "block";

                //fill droplists
                SearchClass.getRegTasks({callback:regTasksReceiverFunc, errorHandler:regTasksErrorHandler});
                SearchClass.getRegCountys({callback:regCountyReceiverFunc, errorHandler:majorErrorHandler});

                //set text-values
                if(getCookieWrapper("as", "openSearchREG")!=null)
                  document.getElementById("openSearchREG").value=getCookieWrapper("as", "openSearchREG");
                if(getCookieWrapper("as", "yearMinREG")!=null)
                  document.getElementById("yearMinREG").value=getCookieWrapper("as", "yearMinREG");
                if(getCookieWrapper("as", "yearMaxREG")!=null)
                  document.getElementById("yearMaxREG").value=getCookieWrapper("as", "yearMaxREG");
                if(getCookieWrapper("as", "document")!=null){
                  if(document.getElementById("document")){
                    document.getElementById("document").value=getCookieWrapper("as", "document");
                  }
                }

                if(document.getElementById("user").value=="member"){
                  //get search-history
                  SearchHistoryClass.getAllSearchHistory(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:searchHistoryREGReceiverFunc, errorHandler:searchHistoryErrorHandler});

                  //get saved documents
                  SavedDocumentClass.getAllSavedDocument(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:savedDocumentReceiverFunc, errorHandler:savedDocumentErrorHandler});
                }
	}
	else if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="LMS"){
		document.getElementById("searchFormREG").style.display = "none";
                document.getElementById("searchFormRAK").style.display = "none";
		document.getElementById("searchFormLMS").style.display = "block";

                //fill droplists
                SearchClass.getLmsCpvCountys({callback:lmsCountysReceiverFunc, errorHandler:majorErrorHandler});
                SearchClass.getLmsTasks({callback:lmsTasksReceiverFunc, errorHandler:lmsTasksErrorHandler});
                SearchClass.getLmsMapTypes({callback:lmsMapTypesReceiverFunc, errorHandler:lmsTasksErrorHandler});

                //set text-values
                if(getCookieWrapper("as", "yearMinLMS")!=null)
                 document.getElementById("yearMinLMS").value=getCookieWrapper("as", "yearMinLMS");
                if(getCookieWrapper("as", "yearMaxLMS")!=null)
                  document.getElementById("yearMaxLMS").value=getCookieWrapper("as", "yearMaxLMS");
                if(getCookieWrapper("as", "surveyor")!=null)
                  document.getElementById("surveyor").value =getCookieWrapper("as", "surveyor");
                if(getCookieWrapper("as", "scanned")==true)
                  document.getElementById("scanned").checked=getCookieWrapper("as", "scanned");
				if(getCookieWrapper("as", "frSelected")==true)
                  document.getElementById("frSelected").checked=getCookieWrapper("as", "frSelected");
                if(document.getElementById("rbyselected")){
                  if(getCookieWrapper("as", "rbyselected")==true){
                    document.getElementById("rbyselected").checked=getCookieWrapper("as", "rbyselected");
                  }

                }
				
                if(document.getElementById("user").value=="member"){
                  //get search-history
                  SearchHistoryClass.getAllSearchHistory(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:searchHistoryLMSReceiverFunc, errorHandler:searchHistoryErrorHandler});

                  //get saved documents
                  SavedDocumentClass.getAllSavedDocument(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:savedDocumentReceiverFunc, errorHandler:savedDocumentErrorHandler});

                  //set text-value for only members
                  if(getCookieWrapper("as", "openSearchLMS")!=null)
                     document.getElementById("openSearchLMS").value=getCookieWrapper("as", "openSearchLMS");
                }

	}
        else if(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value=="RAK"){
                document.getElementById("searchFormREG").style.display = "none";
                document.getElementById("searchFormLMS").style.display = "none";
		document.getElementById("searchFormRAK").style.display = "block";

                //fill drop-lists
                SearchClass.getRakScpSeries({callback:rakSeriesReceiverFunc, errorHandler:majorErrorHandler});

                //get search-history
                if(document.getElementById("user").value=="member"){
                  //fyll searchhistory-listan
                  SearchHistoryClass.getAllSearchHistory(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:searchHistoryRAKReceiverFunc, errorHandler:searchHistoryErrorHandler});
                  //get saved documents
                  SavedDocumentClass.getAllSavedDocument(document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value, {callback:savedDocumentReceiverFunc, errorHandler:savedDocumentErrorHandler});
                }
        }
         if(document.getElementById("user").value=="member"){
           //set archive in history-form
            document.getElementById("archive2").value= document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value;
           //set archive in saveddocument-form
           document.getElementById("archive3").value= document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value;

         }
         //resets colors and texts that might have been changed in validation
         unColorAllElements();
         setInformationMessage();
}

function setGlobals(){

  //set globalpropertys already available in jsp-page
  propertyCounty = document.getElementById("countyLMS").options[0].text;
  propertyParish =document.getElementById("parish").options[0].text;
  propertyVillage=document.getElementById("village").options[0].text;
  propertyTask=document.getElementById("taskLMS").options[0].text;
  propertySeries=document.getElementById("series").options[0].text;
  propertyPage=document.getElementById("page").options[0].text;
  propertyDescription=document.getElementById("infoContainer").innerHTML;
  if(document.getElementById("user").value=="member"){
    propertyGetSearchHistory =document.getElementById("historyId").options[0].text;
    propertyGetSavedDocuments =document.getElementById("savedId").options[0].text;
  }


  //fetch rest of globalpropertys from ajaxfacade
  var params= new Array(24);
  params[0] ="advancedSearchForm.history.choose";
  params[1] ="advancedSearchForm.saveddocument.choose";
  params[2] ="advancedSearchForm.saveddocument.delete";
  params[3] ="advancedSearchForm.history.get.notfound";
  params[4] ="advancedSearchForm.saveddocument.get.notfound";
  params[5] ="advancedSearchForm.saveddocument.delete.success";
  params[6] ="common.serie";
  params[7] ="common.county";
  params[8] ="common.page";
  params[9] ="common.village.act";
  params[10] ="advancedSearchForm.error.validation.general";
  params[11] ="common.search.simple";
  params[12] ="common.signup";
  params[13] ="common.signfull";
  params[14] ="pul.year";
  params[15] ="archive.startYear";
  params[16] ="menu.url.signup";
  params[17] ="advancedSearchForm.description";
  params[18] ="advancedSearchForm.mapType";
  params[19] ="advancedSearchForm.lms.choose.village";
  params[20] ="common.choose.municipality";
  params[21] ="common.choose.parish";
  params[22] ="common.municipality";
  params[23] ="common.parish";
  params[24] ="advancedSearchForm.reg.chooseparisharchive";
  PropertyClass.getPropertyValues(params,{callback:setGlobalsReceiverFunc, errorHandler:majorErrorHandler});

}

// ---- / init-methods --------

// ---- onchange-methods --------

function sendSavedAct(){
    //document.getElementById('saveddocument').submit();
	var archive = document.getElementById("archive").options[document.getElementById("archive").selectedIndex].value;
	var documentAccessCode = document.getElementById("savedId").options[document.getElementById("savedId").selectedIndex].value;
	
	var temp = documentAccessCode.split(":");
	var sd_base = temp[0];
	var sd_ktun = temp[1];
	document.location.href="show.html?sd_base="+sd_base+"&sd_ktun="+sd_ktun+"&archive="+archive+"&showmap=true";
}

function switchPanes(){
  setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
  setLMSTextCookies();
  setREGTextCookies();
  hideAndShow();
}

function fillParishLMS(){

  deleteLMSCookies();//deletes cookies so that no value will be preselected
  setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
  setLMSTextCookies();
  if(document.getElementById("countyLMS").selectedIndex!=0){
     setCookieWrapper("as", "", document.getElementById("countyLMS").selectedIndex);
     SearchClass.getLmsCpvParish(document.getElementById("countyLMS").options[document.getElementById("countyLMS").selectedIndex].value,{callback:lmsParishReceiverFunc, errorHandler:majorErrorHandler});
  }
  else{
      DWRUtil.removeAllOptions("parish");
      addOptionsDefault("parish", [propertyParish]);
      DWRUtil.removeAllOptions("village");
      addOptionsDefault("village", [propertyVillage]);
  }
}
function fillVillagesLMS(){

  //if(document.getElementById("parish").selectedIndex==0){
    deleteLMSCookies();//deletes cookies so that no value will be preselected
    deleteVillage();//reset dropdownlist for village
  //}
  if(document.getElementById("parish").selectedIndex!=0){
    //deleteLMSCookies();//deletes cookies so that no value will be preselected
    setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
    setCookieWrapper("as", "countyLMS", document.getElementById("countyLMS").selectedIndex);
    setLMSTextCookies();

    if(document.getElementById("parish").selectedIndex!=0){
        setCookieWrapper("as", "parish", document.getElementById("parish").selectedIndex);
        SearchClass.getLmsCpvVillages(document.getElementById("countyLMS").options[document.getElementById("countyLMS").selectedIndex].value, document.getElementById("parish").options[document.getElementById("parish").selectedIndex].value,{callback:lmsVillageReceiverFunc, errorHandler:majorErrorHandler});
    }
  }
  else{
   DWRUtil.removeAllOptions("village");
   addOptionsDefault("village", [propertyVillage]);
  }
}
function allSelectedLMS(){

  if(document.getElementById("village").selectedIndex==0){
    deleteLMSCookies();//deletes cookies so that no value will be preselected
  }
  if(document.getElementById("village").selectedIndex!=0){
    setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
    setCookieWrapper("as", "countyLMS", document.getElementById("countyLMS").selectedIndex);
    setCookieWrapper("as", "parish", document.getElementById("parish").selectedIndex);
    setCookieWrapper("as", "village", document.getElementById("village").selectedIndex);
  }
}
function fillCountysRAK(){
  deleteRAKCookies();//deletes cookies so that no value will be preselected
  setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);

   if(document.getElementById("series").selectedIndex!=0){
     setCookieWrapper("as", "series", document.getElementById("series").selectedIndex);
    SearchClass.getRakScpCountys(document.getElementById("series").options[document.getElementById("series").selectedIndex].value,{callback:rakCountysReceiverFunc, errorHandler:majorErrorHandler});
 }
  else{
      DWRUtil.removeAllOptions("countyRAK");
      addOptionsDefault("countyRAK", [propertyCounty]);
      DWRUtil.removeAllOptions("page");
      addOptionsDefault("page", [propertyPage]);
  }
}
function fillPagesRAK(){
  deleteRAKCookies();//deletes cookies so that no value will be preselected
  setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
  if(document.getElementById("series").selectedIndex!=0)
    setCookieWrapper("as", "series", document.getElementById("series").selectedIndex);
  if(document.getElementById("countyRAK").selectedIndex!=0){
    setCookieWrapper("as", "countyRAK", document.getElementById("countyRAK").selectedIndex);
    SearchClass.getRakScpPages(document.getElementById("series").options[document.getElementById("series").selectedIndex].value, document.getElementById("countyRAK").options[document.getElementById("countyRAK").selectedIndex].value,{callback:rakPagesReceiverFunc, errorHandler:majorErrorHandler});
 }
 else{
    DWRUtil.removeAllOptions("page");
    addOptionsDefault("page", [propertyPage]);
 }
}
function allSelectedRAK(){
  deleteRAKCookies();
  setCookieWrapper("as", "archive", document.getElementById("archive").selectedIndex);
  if(document.getElementById("series").selectedIndex!=0)
    setCookieWrapper("as", "series", document.getElementById("series").selectedIndex);
  if(document.getElementById("countyRAK").selectedIndex!=0)
    setCookieWrapper("as", "countyRAK", document.getElementById("countyRAK").selectedIndex);
  if(document.getElementById("page").selectedIndex!=0)
    setCookieWrapper("as", "page", document.getElementById("page").selectedIndex);
}


function deleteSavedDocument(){
  if(validateSavedDocument()){

    //deletes the selected document in saved document list
    SavedDocumentClass.deleteSavedDocument(document.getElementById("savedId").options[document.getElementById("savedId").selectedIndex].value, document.getElementById("archive3").value, {callback:savedDocumentDeletedReceiverFunc, errorHandler:savedDocumentErrorHandler});
    DWRUtil.removeAllOptions("savedId");
    DWRUtil.addOptions("savedId", [propertyDeleteSavedDocument]);


  }

}
function showHideArchiveInfo(){
  showHide("archiveDescription");
}
function showHideSeriesInfo(){
  showHide("seriesDescription");
}

function doDblClickSearchHistoryFunc(){
  setFormCookiesForSearchHistoryAndSavedActs();//set cookies in form before leaving the search via search history or saved act
  if(validateHistory()){
    document.getElementById('searchhistory').submit();
  }
}


// ---- / onchange-methods --------

// ---- AJAX-reciever methods --------

function regCountyReceiverFunc(data){
  DWRUtil.removeAllOptions("countyREG");
  addOptionsDefault("countyREG", [propertyCounty]);
  addOptionsTasks("countyREG",data); //todo other method for this
  if(getCookieWrapper("as", "countyREG")!=null){
      document.getElementById("countyREG").selectedIndex=getCookieWrapper("as", "countyREG");
   }

  if(document.getElementById("munParREG") && getCookieWrapper("as", "munParREG")!=null){//only if cookie is set
    fillMunPar();//fill municipality or parish list
  }
}

function regMunicipalityReceiverFunc(data){
  DWRUtil.removeAllOptions("munParREG");
  addOptionsDefault("munParREG", [propertyMunicipality]);
  addOptionsMun("munParREG",data); //todo other method for this
  if(getCookieWrapper("as", "munParREG")!=null && getCookieWrapper("as", "munParREG")!="-1"){
      document.getElementById("munParREG").selectedIndex=getCookieWrapper("as", "munParREG");
   }
}

function regParishReceiverFunc(data){
  DWRUtil.removeAllOptions("munParREG");
  addOptionsDefault("munParREG", [propertyChooseParishArchive]);
  addOptionsPar("munParREG",data); //todo other method for this
  if(getCookieWrapper("as", "munParREG")!=null && getCookieWrapper("as", "munParREG")!="-1"){
      document.getElementById("munParREG").selectedIndex=getCookieWrapper("as", "munParREG");
   }
}

function lmsTasksReceiverFunc(data){
  DWRUtil.removeAllOptions("taskLMS");
  addOptionsDefault("taskLMS", [propertyTask]);
  addOptionsTasks("taskLMS",data);
  document.getElementById('taskLMS').disabled=false;
  if(getCookieWrapper("as", "taskLMS")!=null){
    document.getElementById("taskLMS").selectedIndex=getCookieWrapper("as", "taskLMS");
  }
}
function regTasksReceiverFunc(data){
  DWRUtil.removeAllOptions("taskREG");
  addOptionsDefault("taskREG", [propertyTask]);
  addOptionsTasks("taskREG",data);
  document.getElementById('taskREG').disabled=false;
  if(getCookieWrapper("as", "taskREG")!=null){
      document.getElementById("taskREG").selectedIndex=getCookieWrapper("as", "taskREG");
   }
}
function lmsCountysReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("countyLMS");
  addOptionsDefault("countyLMS", [propertyCounty]);
  DWRUtil.removeAllOptions("parish");
  addOptionsDefault("parish", [propertyParish]);
  DWRUtil.removeAllOptions("village");
  addOptionsDefault("village", [propertyVillage]);
  addOptionsLMSCounty("countyLMS",searchresult);
  if(getCookieWrapper("as", "countyLMS")!=null){
    document.getElementById("countyLMS").selectedIndex=getCookieWrapper("as", "countyLMS");
    SearchClass.getLmsCpvParish(document.getElementById("countyLMS").options[document.getElementById("countyLMS").selectedIndex].value,{callback:lmsParishReceiverFunc, errorHandler:majorErrorHandler});
  }
}


function lmsMapTypesReceiverFunc(searchresult){

  DWRUtil.removeAllOptions("mapType");
  addOptionsDefault("mapType", [propertyMaptype]);

  addOptionsLMSMapType("mapType",searchresult);

  if(getCookieWrapper("as", "mapType")!=null){
    document.getElementById("mapType").selectedIndex=getCookieWrapper("as", "mapType");
  }
  else{
    setMaptypeCookieFunc();
    document.getElementById("mapType").selectedIndex=0;
  }


    if(getCookieWrapper("as", "mapTypeSelected")!=null){

      if(getCookieWrapper("as", "mapTypeSelected")=="true"){
        document.getElementById("maptypeLMSradio").checked=true;
		setMaptypeSelectedCookieFunc();

        if (browserName=="Microsoft Internet Explorer"){//If explorer
          document.getElementById("digitalLMSDescriptionBottom").style.display="block";
        }
        else{
          document.getElementById("digitalLMSDescriptionBottom").style.display="none";
        }
		if (browserName=="Microsoft Internet Explorer"){//If explorer
          document.getElementById("frREGDescriptionBottom").style.display="block";
        }
        else{
          document.getElementById("frREGDescriptionBottom").style.display="none";
        }
        maptypeLMSradioFunc();
      }
      else if(getCookieWrapper("as", "mapTypeSelected")=="false"){
        document.getElementById("countyLMSradio").checked=true;
        countyLMSradioFunc();
      }
   }
   else{//if first time site loads and no cookies are set
    setCookieWrapper("as", "mapTypeSelected", "false");
    document.getElementById("countyLMSradio").checked=true;
    countyLMSradioFunc();
   }
     
}


function setMaptypeCookieFunc(){
  setCookieWrapper("as", "mapType", document.getElementById("mapType").selectedIndex);
}

function setMaptypeSelectedCookieFunc(){

  if(document.getElementById("countyLMSradio").checked==true){
    showReferensCheckbox();
    setCookieWrapper("as", "mapTypeSelected", "false");
    countyLMSradioFunc();
    if (browserName=="Microsoft Internet Explorer"){//If explorer
      document.getElementById("digitalLMSDescriptionBottom").style.display="none";
    }
    else{
      document.getElementById("digitalLMSDescriptionBottom").style.display="none";
    }
	if (browserName=="Microsoft Internet Explorer"){//If explorer
      document.getElementById("frREGDescriptionBottom").style.display="none";
    }
    else{
		if(document.getElementById("frREGDescriptionBottom")){
      		document.getElementById("frREGDescriptionBottom").style.display="none";
		}
    }
  }

  if(document.getElementById("maptypeLMSradio").checked==true){
    hideReferensCheckbox();
    setCookieWrapper("as", "mapTypeSelected", "true");
    maptypeLMSradioFunc();
    if (browserName=="Microsoft Internet Explorer"){//If explorer
      document.getElementById("digitalLMSDescriptionBottom").style.display="block";
    }
    else{
      document.getElementById("digitalLMSDescriptionBottom").style.display="none";
    }
	if (browserName=="Microsoft Internet Explorer"){//If explorer
      document.getElementById("frREGDescriptionBottom").style.display="block";
    }
    else{
	  if(document.getElementById("frREGDescriptionBottom")){
      	document.getElementById("frREGDescriptionBottom").style.display="none";
	  }
    }
  }
}

function setScannedCookieFunc(){
  if(document.getElementById("scanned").checked==true){
    setCookieWrapper("as", "scanned", "true");
  }
  else{
    setCookieWrapper("as", "scanned", "false");
  }
}

function setFrSelectedCookieFunc(){
  if(document.getElementById("frSelected") && document.getElementById("frSelected").checked==true){
    setCookieWrapper("as", "frSelected", "true");
	document.getElementById("frSelected").value="true";
  }
  else{
    setCookieWrapper("as", "frSelected", "false");
	document.getElementById("frSelected").value="false";
  }
}


function setRbyselectedCookieFunc(){
  if(document.getElementById("rbyselected") && document.getElementById("rbyselected").checked==true){
    setCookieWrapper("as", "rbyselected", "true");
    document.getElementById("rbyselected").value="true";
  }
  else{
    setCookieWrapper("as", "rbyselected", "false");
    document.getElementById("rbyselected").value="false";
  }
}


function lmsParishReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("parish");
  addOptionsDefault("parish", [propertyParish]);
  DWRUtil.removeAllOptions("village");
  addOptionsDefault("village", [propertyVillage]);
  addOptionsLMSParishVillage("parish",searchresult);
  if(getCookieWrapper("as", "parish")!=null){
    document.getElementById("parish").selectedIndex=getCookieWrapper("as", "parish");
    SearchClass.getLmsCpvVillages(document.getElementById("countyLMS").options[document.getElementById("countyLMS").selectedIndex].value, document.getElementById("parish").options[document.getElementById("parish").selectedIndex].value,{callback:lmsVillageReceiverFunc, errorHandler:majorErrorHandler});
  }
}
function lmsVillageReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("village");
  addOptionsDefault("village", [propertyVillage]);
  addOptionsLMSParishVillage("village",searchresult);
  if(getCookieWrapper("as", "village")!=null){
    document.getElementById("village").selectedIndex=getCookieWrapper("as", "village");
    if(!document.getElementById("maptypeLMSradio").checked){
      showReferensCheckbox();
    }
  }
}
function rakSeriesReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("series");
  addOptionsDefault("series", [propertySeries]);
  DWRUtil.removeAllOptions("countyRAK");
  addOptionsDefault("countyRAK", [propertyCounty]);
  DWRUtil.removeAllOptions("page");
  addOptionsDefault("page", [propertyPage]);
  addOptionsRAKSeries("series",searchresult);

  if(getCookieWrapper("as", "series")!=null){
    document.getElementById("series").selectedIndex=getCookieWrapper("as", "series");
    SearchClass.getRakScpCountys(document.getElementById("series").options[document.getElementById("series").selectedIndex].value,{callback:rakCountysReceiverFunc, errorHandler:majorErrorHandler});
  }
}
function rakCountysReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("countyRAK");
  addOptionsDefault("countyRAK", [propertyCounty]);
  DWRUtil.removeAllOptions("page");
  addOptionsDefault("page", [propertyPage]);
  addOptionsRAKCountys("countyRAK",searchresult);
  if(getCookieWrapper("as", "countyRAK")!=null){
      document.getElementById("countyRAK").selectedIndex=getCookieWrapper("as", "countyRAK");
      SearchClass.getRakScpPages(document.getElementById("series").options[document.getElementById("series").selectedIndex].value, document.getElementById("countyRAK").options[document.getElementById("countyRAK").selectedIndex].value,{callback:rakPagesReceiverFunc, errorHandler:majorErrorHandler});
    }
}
function rakPagesReceiverFunc(searchresult){
  DWRUtil.removeAllOptions("page");
  addOptionsDefault("page", [propertyPage]);
  addOptionsRAKPages("page",searchresult);
  if(getCookieWrapper("as", "countyRAK")!=null){
      document.getElementById("page").selectedIndex=getCookieWrapper("as", "page");
    }
}

function searchHistoryRAKReceiverFunc(data){
      if(data!=null && data.length>0){
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertySearchHistory]);
        addOptionsRAKHistory("historyId", data);
        document.getElementById("historyId").disabled=false;
        document.getElementById("searchHistoryBtn").disabled=false;
      }
      else{
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertyHistoryNotFound]);
        document.getElementById("historyId").disabled=true;
        document.getElementById("searchHistoryBtn").disabled=true;
      }
}
function searchHistoryLMSReceiverFunc(data){
      if(data!=null && data.length>0){
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertySearchHistory]);
        addOptionsLMSHistory("historyId", data);
        document.getElementById("historyId").disabled=false;
        document.getElementById("searchHistoryBtn").disabled=false;
      }
      else{
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertyHistoryNotFound]);
        document.getElementById("historyId").disabled=true;
        document.getElementById("searchHistoryBtn").disabled=true;
      }
}
function searchHistoryREGReceiverFunc(data){
      if(data!=null && data.length>0){
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertySearchHistory]);
        addOptionsREGHistory("historyId", data);
        document.getElementById("historyId").disabled=false;
        document.getElementById("searchHistoryBtn").disabled=false;
      }
      else{
        DWRUtil.removeAllOptions("historyId");
        DWRUtil.addOptions("historyId", [propertyHistoryNotFound]);
        document.getElementById("historyId").disabled=true;
        document.getElementById("searchHistoryBtn").disabled=true;
      }
}
function savedDocumentReceiverFunc(data){
       if(data!=null && data.length>0){
        DWRUtil.removeAllOptions("savedId");
        DWRUtil.addOptions("savedId", [propertySavedDocuments]);
        addOptionsSavedDocument("savedId", data);
        document.getElementById("savedId").disabled=false;
        document.getElementById("savedDocumentBtn").disabled=false;
        document.getElementById("savedDocumentDeleteBtn").disabled=false;
       }
      else{
        DWRUtil.removeAllOptions("savedId");
        DWRUtil.addOptions("savedId", [propertySavedDocumentNotFound]);
        document.getElementById("savedId").disabled=true;
        document.getElementById("savedDocumentBtn").disabled=true;
        document.getElementById("savedDocumentDeleteBtn").disabled=true;
      }
}

function deleteVillage(){
  var ele=document.getElementById('village');
  while (ele.childNodes.length > 1){
    ele.removeChild(ele.firstChild); //remove original text
  }
  document.getElementById("village").options[document.getElementById("village").selectedIndex].text=propertyChooseVillage;
}

function savedDocumentDeletedReceiverFunc(data){
      var ele=document.getElementById('infoContainer');
      while (ele.childNodes.length > 0)
         ele.removeChild(ele.firstChild); //remove original text

    var img = document.createElement("img");
     img.src="../images/info.gif";
     img.alt="";
     ele.appendChild(img); //add info image

      ele.appendChild(document.createTextNode(propertySavedDocumentDeleted)); //sets info-message text

      //animera meddelandet
      alternateSetColor(0);
      ele.style.border="1px solid #00f";
      ele.style.padding="10px";

       if(data!=null && data.length>0){
        DWRUtil.removeAllOptions("savedId");
        DWRUtil.addOptions("savedId", ['V\u00E4lj sparad akt']);
        addOptionsSavedDocument("savedId", data);
        document.getElementById("savedDocumentBtn").disabled=false;
        document.getElementById("savedDocumentDeleteBtn").disabled=false;
      }
      else{
        DWRUtil.removeAllOptions("savedId");
        DWRUtil.addOptions("savedId", [propertySavedDocumentNotFound]);
        document.getElementById("savedDocumentBtn").disabled=true;
        document.getElementById("savedDocumentDeleteBtn").disabled=true;
        document.getElementById("savedId").disabled=true;
      }
}

function setGlobalsReceiverFunc(data){
  propertySearchHistory=data[0];
  propertySavedDocuments=data[1];
  propertyDeleteSavedDocument=data[2];
  propertyHistoryNotFound=data[3];
  propertySavedDocumentNotFound=data[4];
  propertySavedDocumentDeleted=data[5];
  propertyCommonSeries=data[6];
  propertyCommonCounty=data[7];
  propertyCommonPage=data[8];
  propertyCommonVillage=data[9];
  propertyGeneralError=data[10];
  propertySimpleSearch=data[11];
  propertySignUp=data[12];
  propertySignFull=data[13];
  propertyPulYear=data[14];
  propertyArchiveStartYear=data[15];
  propertySignUpUrl=data[16];
  propertyInstructions=data[17];
  propertyMaptype=data[18];
  propertyChooseVillage=data[19];
  propertyMunicipality=data[20];
  propertyParish=data[21];
  propertyErrorMunicipality=data[22];
  propertyErrorParish=data[23];
  propertyChooseParishArchive=data[24];

  //buildInstructions();
  fillLists();
  externalLinks();
}


// ---- / AJAX-reciever methods --------

// ----  error-methods --------

function majorErrorHandler(errorString, exception) {
  var ele=document.getElementById('infoContainer');
  while (ele.childNodes.length > 0)
     ele.removeChild(ele.firstChild); //remove original text

  var img = document.createElement("img");
  img.src="../images/error.gif";
  img.alt="";
  ele.appendChild(img); //add warning image

  ele.appendChild(document.createTextNode(exception.msg)); //sets error-message text

  //lägger in länk till enkel sökning
  var link = document.createElement("a");
  link.setAttribute("href", "search.html");
  link.appendChild(document.createTextNode(propertySimpleSearch));
  ele.appendChild(link);

  //animera meddelandet
  setColor(0);
  ele.style.border="1px solid #f00";
  ele.style.padding="10px";

  disableAllElements();
}
function searchHistoryErrorHandler(errorString, exception) {
  DWRUtil.removeAllOptions("historyId");
  DWRUtil.addOptions("historyId", [exception.msg]); //sets error-message text
  //disables elements
  document.getElementById("historyId").disabled=true;
  document.getElementById("searchHistoryBtn").disabled=true;
}
function savedDocumentErrorHandler(errorString, exception) {
  DWRUtil.removeAllOptions("savedId");
  DWRUtil.addOptions("savedId", [exception.msg]); //sets error-message text
  //disables elements
  document.getElementById("savedDocumentBtn").disabled=true;
  document.getElementById("savedDocumentDeleteBtn").disabled=true;

}
function regTasksErrorHandler(errorString, exception) {
  DWRUtil.removeAllOptions("taskREG");
  DWRUtil.addOptions("taskREG", [exception.msg]); //sets error-message text
  document.getElementById('taskREG').disabled=true;
}
function lmsTasksErrorHandler(errorString, exception) {
  DWRUtil.removeAllOptions("taskLMS");
  DWRUtil.addOptions("taskLMS", [exception.msg]); //sets error-message text
  document.getElementById('taskLMS').disabled=true;
}


// ---- / error-methods --------

