function showAdvancedPane(val){var frameSize="";var istyleSheet="";var newHref="";var newLinkText="";var ClearFieldsLinkHref="";var ClearFieldsLinkText="";flipImage(val);document.forms[0].hdnAdvancedSearch.value=val;if(val=='on'){frameSize="335,*";istyleSheet=1;newHref="JavaScript:showAdvancedPane('off');";newLinkText="Close Advanced Search";AdvancedControlsVisible('block');ClearFieldsLinkHref="javascript: ClearAdvancedFields();";ClearFieldsLinkText="Clear Fields"}else if(val=='off'){ClearErrorMessage();frameSize="175,*";istyleSheet=0;newHref="JavaScript:showAdvancedPane('on');";AdvancedControlsVisible('none');newLinkText="Open Advanced Search";ClearFieldsLinkHref="";ClearFieldsLinkText=""}parent.top.document.getElementById("SearchAndResults").rows=frameSize;if(document.links.length>0){if(document.getElementById){document.getElementById('AdvancedHyperlink').href=newHref;document.getElementById('AdvancedHyperlink').innerHTML=newLinkText;document.getElementById('clrAFields').href=ClearFieldsLinkHref;document.getElementById('clrAFields').innerHTML=ClearFieldsLinkText}}else if(document.all){document.all[id].href=newHref}}function ReturnPressed(TheSearchType,e){var e;var code;if(!e){e=window.event}if(e.keyCode){code=e.keyCode}if(e.which){code=e.which}if(code==13){if(TheSearchType.indexOf('County')>=0){TheSearchType='CountySearch'}else if(TheSearchType.indexOf('Catchment')>=0){TheSearchType='CatchmentSearch'}else if(TheSearchType.indexOf('NGR')>=0){TheSearchType='NGRSearch'}if(TheSearchType=='NGRSearch'){if(document.forms[0].hdnAdvancedSearch.value=='on'){document.getElementById('AdvancedNGRSearchButton').click();}else{document.getElementById('BasicNGRSearchButton').click();}return false}else if(TheSearchType=='CountySearch'){ResetTown();if(document.forms[0].hdnAdvancedSearch.value=='on'){document.getElementById('AdvancedCountySearchButton').click();}else{document.getElementById('BasicCountySearchButton').click();}return false}else{if(document.forms[0].hdnAdvancedSearch.value=='on'){document.getElementById('AdvancedCatchmentSearchButton').click();}else{document.getElementById('BasicCatchmentSearchButton').click();}return false}}else{return true}}function ClearCountyFieldsOnKeyUp(event){var e;var code;var EventSource;if(!e){e=window.event}if(e.keyCode){code=e.keyCode}if(e.which){code=e.which}if(e.target){EventSource=e.target.name}if(e.srcElement){EventSource=e.srcElement.name}if(code!=13){if(EventSource=="Street"){document.forms[0].hdnSearchType.value='CountySearch';ResetTownland();}if(EventSource=="TownlandTextBox"){document.forms[0].hdnSearchType.value='CountySearch';ResetTown();}}}function CreateTownlandLink(){if(navigator.appName.indexOf("Microsoft")!=-1){var xMax=screen.width}else{if(navigator.appName.indexOf("Microsoft")==-1){var xMax=window.outerWidth}else var xMax=640}var xOffset=(xMax-420);var CountyID=document.forms[0].County.value;var TownLandName=document.forms[0].TownlandTextBox.value;var Parameters="SelectTownland.aspx?CountyID="+CountyID+"&TownlandName="+TownLandName;var WindowObjectReference=open(Parameters,"","width=400,height=350,left="+xOffset+",top=10,scrollbars=no");}function CreateRiverLink(e){if(!e)var e=window.event;var code;if(e.keyCode)code=e.keyCode;if(e.which)code=e.which;if(navigator.appName.indexOf("Microsoft")!=-1){var xMax=screen.width}else{if(navigator.appName.indexOf("Microsoft")==-1){var xMax=window.outerWidth}else var xMax=640}var xOffset=(xMax-420);if(navigator.appName.indexOf("Microsoft")==-1){if(e.target.type=='RiverPopup'||e.target.type=='image'){var CatchmentID=document.forms[0].Catchment.value;var RiverName=document.forms[0].River.value;var Parameters="SelectRiver.aspx?CatchmentID="+CatchmentID+"&RiverName="+RiverName;var WindowObjectReference=open(Parameters,"","width=400,height=350,left="+xOffset+",top=10,scrollbars=no");return false}}else{var CatchmentID=document.forms[0].Catchment.value;var RiverName=document.forms[0].River.value;var Parameters="SelectRiver.aspx?CatchmentID="+CatchmentID+"&RiverName="+RiverName;var WindowObjectReference=open(Parameters,"","width=400,height=350,left="+xOffset+",top=10,scrollbars=no");return false}}function CreateStreetLink(){if(navigator.appName.indexOf("Microsoft")!=-1){var xMax=screen.width}else{if(navigator.appName.indexOf("Microsoft")==-1){var xMax=window.outerWidth}else{var xMax=640}}var xOffset=(xMax-420);var CountyID=document.forms[0].County.value;var TownID=document.forms[0].Town.value;var StreetName=document.forms[0].Street.value;var Parameters="SelectStreet.aspx?CountyID="+CountyID+"&TownID="+TownID+"&StreetName="+StreetName;var WindowObjectReference=open(Parameters,"","width=400,height=350,left="+xOffset+",top=10,scrollbars=no");}function ClientValidateCounty(){document.forms[0].hdnSearchType.value='CountySearch';var ResultLbl=document.getElementById('ValidationResult');if(document.forms[0].County.value=="-1"){ResultLbl.innerHTML="Select a county";ResetTownland();return false}if(!ValidateText(document.getElementById('TownlandTextBox'))){ResultLbl.innerHTML="Invalid Townland Text";return false}if(document.forms[0].hdnAdvancedSearch.value=='on'){var AdvancedValidationError=ValidateSearchPanelAdvancedFields("County");if(AdvancedValidationError!=""){ResultLbl.innerHTML=AdvancedValidationError;return false}if((isNaN(document.getElementById('CountyBuffer').value))||(document.getElementById('CountyBuffer').value<0)||(document.getElementById('CountyBuffer').value>10)){ResultLbl.innerHTML="Invalid Buffer value";return false}if((document.getElementById('CountyBuffer').value!='')&&(document.forms[0].Town.value=="-1")&&(document.forms[0].TownlandTextBox.value=="")){ResultLbl.innerHTML="Select a town or townland";return false}}ResultLbl.value="";ResetCatchmentFields();ResetNGRFields();}function cancelLink(){return false}function doNotLink(){}function DisableCountyFields(){document.forms[0].County.value=-1;document.forms[0].Town.value=-1;document.forms[0].Town.disabled=true;document.forms[0].Town.style.backgroundColor='D4D0C8';document.getElementById('TownlandPopup').disabled=true;document.getElementById('TownlandPopup').onclick="javascript: cancelLink()";document.getElementById('TownlandPopup').href='javascript: doNotLink()';document.getElementById('TownlandPopup').innerHTML="<img title='Opens Pop-Up Window to Select Townland' alt='Opens Pop-Up Window to Select Townland' border='0' src='../Resources/Images/PopupSearchButtonDisabled.gif'>";document.forms[0].TownlandTextBox.style.backgroundColor='D4D0C8';document.forms[0].TownlandTextBox.disabled=true;document.getElementById('TownlandPopup').disabled=true;document.forms[0].Street.value="";document.forms[0].Street.disabled=true;document.forms[0].Street.style.backgroundColor='D4D0C8';document.getElementById('StreetPopup').disabled=true;document.getElementById('StreetPopup').onclick="javascript: cancelLink()";document.getElementById('StreetPopup').href='javascript: doNotLink()';document.getElementById('StreetPopup').innerHTML="<img title='Opens Pop-Up Window to Select Street' alt='Opens Pop-Up Window to Select Street' border='0' src='../Resources/Images/PopupSearchButtonDisabled.gif'>";document.getElementById('CountyBuffer').value=''}function DisableNGRFields(){document.forms[0].NGREast.value="";document.forms[0].NGRNorth.value="";document.forms[0].NGREast.style.backgroundColor='D4D0C8';document.forms[0].NGREast.disabled=true;document.forms[0].NGRNorth.style.backgroundColor='D4D0C8';document.forms[0].NGRNorth.disabled=true;DisableSearchPanelAdvancedFields('NGR',true);}function DropDownChange(TheChangedDropDown){ClearErrorMessage();document.forms[0].hdnSearchType.value=TheChangedDropDown;if(TheChangedDropDown=='CountySearch'){ResetTownland();document.forms[0].Street.value='';if(document.forms[0].County.value=="-1"){DisableCountyFields();return false}else{document.forms[0].Street.disabled=false;document.forms[0].Street.value='';if(document.forms[0].StreetID!=null)document.forms[0].StreetID.value='';if(document.forms[0].StreetVerified!=null)document.forms[0].StreetVerified.value="";ResetCatchmentFields();ResetNGRFields();document.forms[0].TownlandTextBox.disabled=false;document.forms[0].submit();}}else if(TheChangedDropDown=='CatchmentSearch'){ChangeCatchmentRiver();DisableNGRFields();}else if(TheChangedDropDown=='NGRSearch'){if(document.forms[0].NGRDropdown.value=="-"){DisableNGRFields();return false}else{document.forms[0].NGREast.style.backgroundColor='FFFFFF';document.forms[0].NGREast.disabled=false;document.forms[0].NGRNorth.style.backgroundColor='FFFFFF';document.forms[0].NGRNorth.disabled=false;DisableSearchPanelAdvancedFields('NGR',false);}ResetCountyFields();ResetCatchmentFields();}}function ChangeCatchmentRiver(){document.forms[0].hdnSearchType.value='CatchmentSearch';document.forms[0].RiverID.value='';if(document.forms[0].Catchment.value=="-1"){return false}else{document.forms[0].River.value='';ResetCountyFields();ResetNGRFields();DisableSearchPanelAdvancedFields('Catchment',false);}}function ClientValidateCatchment(){document.forms[0].hdnSearchType.value='CatchmentSearch';var ResultLbl=document.getElementById('ValidationResult');if(!ValidateText(document.getElementById('River'))){ResultLbl.innerHTML="Invalid River Text";return false}if((document.forms[0].Catchment.value=="-1")&&(document.forms[0].River.value=="")){ResultLbl.innerHTML="Select a Catchment or River";return false}else{if(document.forms[0].hdnAdvancedSearch.value=='on'){var AdvancedValidationError=ValidateSearchPanelAdvancedFields("Catchment");if(AdvancedValidationError!=""){ResultLbl.innerHTML=AdvancedValidationError;return false}}ResultLbl.value="";ResetCountyFields();ResetNGRFields();}}function ClientValidateNGR(){document.forms[0].hdnSearchType.value='NGRSearch';var ResultLbl=document.getElementById('ValidationResult');var NGREast=document.forms[0].NGREast.value;var NGRNorth=document.forms[0].NGRNorth.value;if(document.forms[0].NGRDropdown.value=="-"){ResultLbl.innerHTML="Select an NGR";return false}else if((NGREast=='')&&(NGRNorth=='')){ResultLbl.innerHTML="Enter digits for NGR East & North";return false}else if((NGREast=='')||(!IsNumeric(NGREast))){ResultLbl.innerHTML="Enter a number for East";return false}else if((NGRNorth=='')||(!IsNumeric(NGRNorth))){ResultLbl.innerHTML="Enter a number for North";return false}else if(NGRNorth.length!=NGREast.length){ResultLbl.innerHTML="Use equal no. of digits";return false}else{if(document.forms[0].hdnAdvancedSearch.value=='on'){var AdvancedValidationError=ValidateSearchPanelAdvancedFields("NGR");if(AdvancedValidationError!=""){ResultLbl.innerHTML=AdvancedValidationError;return false}}ResultLbl.value="";ResetCountyFields();ResetCatchmentFields();}}function IsNumeric(sText){var ValidChars="0123456789";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++){Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1){IsNumber=false}}return IsNumber}function flipImage(val){if(document.images){if(val=='on'){document.images['AdvancedSearch'].src='../Resources/Images/AdvancedSearchOff.gif'}else if(val=='off'){document.images['AdvancedSearch'].src='../Resources/Images/AdvancedSearchOn.gif'}}}function AdvancedControlsVisible(Visibility){var ndTargetLayer=document.getElementById('AdvancedCountySearch');ndTargetLayer.style.display=Visibility;var ndTargetLayer=document.getElementById('AdvancedCatchmentSearch');ndTargetLayer.style.display=Visibility;var ndTargetLayer=document.getElementById('AdvancedNGRSearch');ndTargetLayer.style.display=Visibility;if(Visibility=='block'){var ndTargetLayer=document.getElementById('BasicCountySearchButton');ndTargetLayer.style.display='none';var ndTargetLayer=document.getElementById('BasicCatchmentSearchButton');ndTargetLayer.style.display='none';var ndTargetLayer=document.getElementById('BasicNGRSearchButton');ndTargetLayer.style.display='none'}else{var ndTargetLayer=document.getElementById('BasicCountySearchButton');ndTargetLayer.style.display='inline';var ndTargetLayer=document.getElementById('BasicCatchmentSearchButton');ndTargetLayer.style.display='inline';var ndTargetLayer=document.getElementById('BasicNGRSearchButton');ndTargetLayer.style.display='inline'}}function toggleLayerDisplay(sDivID){var ndTargetLayer=document.getElementById(sDivID);if(ndTargetLayer.style.display=='none'){ndTargetLayer.style.display='block'}else{ndTargetLayer.style.display='none'}}function AdvancedControlVisible(sDivID,Visibility){var ndTargetLayer=document.getElementById(sDivID);ndTargetLayer.style.display=Visibility}function PopupPicker(ctl,w,h){var PopupWindow=null;var settings='width='+w+',height='+h+',location=no,directories=no, menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no, dependent=no';PopupWindow=open('Calender.aspx?Ctl='+ctl,'DatePicker',settings);PopupWindow.focus();return false}function DisableSearchPanelAdvancedFields(PanelName,Disabled){DateFormatString='DD/MM/YYYY';document.getElementById(PanelName+'QC').disabled=Disabled;document.getElementById(PanelName+'From_DateField').disabled=Disabled;document.getElementById(PanelName+'From_DateField').value=DateFormatString;document.getElementById(PanelName+'To_DateField').disabled=Disabled;document.getElementById(PanelName+'To_DateField').value=DateFormatString;document.getElementById(PanelName+'From_CalenderImage').disabled=Disabled;document.getElementById(PanelName+'To_CalenderImage').disabled=Disabled;if(Disabled){document.getElementById(PanelName+'To_CalenderImage').src='../Resources/Images/CalenderDisabled.gif';document.getElementById(PanelName+'From_CalenderImage').src='../Resources/Images/CalenderDisabled.gif';document.getElementById(PanelName+'QC').style.backgroundColor='D4D0C8';document.getElementById(PanelName+'From_DateField').style.backgroundColor='D4D0C8';document.getElementById(PanelName+'To_DateField').style.backgroundColor='D4D0C8'}else{document.getElementById(PanelName+'To_CalenderImage').src='../Resources/Images/Calender.gif';document.getElementById(PanelName+'From_CalenderImage').src='../Resources/Images/Calender.gif';document.getElementById(PanelName+'QC').style.backgroundColor='FFFFFF';document.getElementById(PanelName+'From_DateField').style.backgroundColor='FFFFFF';document.getElementById(PanelName+'To_DateField').style.backgroundColor='FFFFFF'}if(PanelName=="County"){var BufferTextBox=document.getElementById('CountyBuffer');BufferTextBox.disabled=Disabled;BufferTextBox.style.backgroundColor='D4D0C8'}}function ValidateSearchPanelAdvancedFields(PanelName){var DateError="";DateError=CheckDateField(document.getElementById(PanelName+'From_DateField'));if(DateError!=""){return"Invalid From Date"}DateError=CheckDateField(document.getElementById(PanelName+'To_DateField'));if(DateError!=""){return"Invalid To Date"}return DateRangeCheck(document.getElementById(PanelName+'From_DateField'),document.getElementById(PanelName+'To_DateField'));}function ValidateText(field){var valid="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ()[]-,/'. ";var temp;for(var i=0;i<field.value.length;i++){temp=field.value.substring(i,i+1);if(valid.indexOf(temp)==-1){return false}}return true}function StreetTextChanged(){ClearErrorMessage();document.forms[0].StreetID.value='';document.forms[0].StreetVerified.value=""}function RiverTextChanged(){ClearErrorMessage();if(document.forms[0].River.value==''){document.forms[0].RiverID.value='';document.forms[0].RiverVerified.value='false'}else if(document.forms[0].RiverVerified.value!='true'){document.forms[0].hdnSearchType.value='CatchmentSearch';DisableSearchPanelAdvancedFields('Catchment',false);document.forms[0].RiverID.value=''}else{document.forms[0].hdnSearchType.value='CatchmentSearch';DisableSearchPanelAdvancedFields('Catchment',false);document.forms[0].RiverVerified.value=''}}function ResetTownland(){ClearErrorMessage();document.forms[0].TownlandTextBox.value='';document.forms[0].TownlandID.value='';document.forms[0].TownlandVerified.value='false'}function ResetTown(){ClearErrorMessage();if(document.forms[0].TownlandTextBox.value==''){document.forms[0].TownlandID.value='';document.forms[0].TownlandVerified.value='false'}else if(document.forms[0].TownlandVerified.value!='true'){document.forms[0].Town.value=-1;document.forms[0].Street.value="";document.forms[0].TownlandID.value=''}else{document.forms[0].Town.value=-1;document.forms[0].Street.value="";document.forms[0].TownlandVerified.value=''}}function ResetCountyFields(){ResetTownland();DisableCountyFields();ResetSearchPanelAdvancedFields('County');DisableSearchPanelAdvancedFields('County',true);}function ResetCatchmentFields(){document.forms[0].Catchment.value=-1;document.forms[0].River.value='';ResetSearchPanelAdvancedFields('Catchment');DisableSearchPanelAdvancedFields('Catchment',true);}function ResetNGRFields(){document.forms[0].NGRDropdown.value="-";document.forms[0].NGREast.value="";document.forms[0].NGRNorth.value="";ResetSearchPanelAdvancedFields('NGR');}function ResetSearchPanelAdvancedFields(PanelName){document.getElementById(PanelName+'QC').value=-1;document.getElementById(PanelName+'From_DateField').value='';document.getElementById(PanelName+'To_DateField').value=''}function TownChanged(){ClearErrorMessage();document.forms[0].Street.value='';document.forms[0].StreetID.value='';document.forms[0].StreetVerified.value="";ResetTownland();return false}function ClearErrorMessage(){errText=document.getElementById("ValidationResult").innerHTML;if(errText!=""){document.getElementById("ValidationResult").innerHTML=""}}function ClearAdvancedFields(){var searchType=document.forms[0].hdnSearchType.value;switch(searchType){case"CountySearch":document.forms[0].CountyQC.selectedIndex=0;document.forms[0].CountyFrom_DateField.value="DD/MM/YYYY";document.forms[0].CountyTo_DateField.value="DD/MM/YYYY";document.forms[0].CountyBuffer.value="";break;case"CatchmentSearch":document.forms[0].CatchmentQC.selectedIndex=0;document.forms[0].CatchmentFrom_DateField.value="DD/MM/YYYY";document.forms[0].CatchmentTo_DateField.value="DD/MM/YYYY";break;case"NGRSearch":document.forms[0].NGRQC.selectedIndex=0;document.forms[0].NGRFrom_DateField.value="DD/MM/YYYY";document.forms[0].NGRTo_DateField.value="DD/MM/YYYY";break;default:break}ClearErrorMessage();}function setTowns(){var SelectedCounty;var CountyDropDown=document.forms[0].County;if(CountyDropDown.selectedIndex==0){DisableCountyFields();DisableSearchPanelAdvancedFields('County',true);}else{document.forms[0].hdnSearchType.value="CountySearch";document.forms[0].TownlandTextBox.text="";document.forms[0].TownlandTextBox.value="";document.forms[0].TownlandVerified.value=false;document.forms[0].TownlandID.value="";document.forms[0].Town.enabled=true;document.forms[0].Town.disabled=false;document.forms[0].Town.style.background="#FFFFFF";document.forms[0].TownlandTextBox.enabled=true;document.forms[0].TownlandTextBox.disabled=false;document.forms[0].TownlandTextBox.style.background="#FFFFFF";document.forms[0].Street.enabled=true;document.forms[0].Street.disabled=false;document.forms[0].Street.style.background="#FFFFFF";document.forms[0].Street.text="";document.forms[0].Street.value="";document.forms[0].StreetVerified.value=false;document.forms[0].StreetID.value="";var townlandpopuplink=document.getElementById("TownlandPopup");townlandpopuplink.innerHTML='<img title="Opens Pop-Up Window to Select Townland" src="../Resources/Images/PopupSearchButton.gif" alt="" border="0" />';townlandpopuplink.onclick="javascript: CreateTownlandLink()";townlandpopuplink.href='javascript: CreateTownlandLink()';var streetpopuplink=document.getElementById("StreetPopup");streetpopuplink.innerHTML='<img title="Opens Pop-Up Window to Select Street" src="../Resources/Images/PopupSearchButton.gif" alt="" border="0" />';streetpopuplink.onclick="javascript: CreateStreetLink()";streetpopuplink.href='javascript: CreateStreetLink()';document.forms[0].Catchment.selectedIndex=0;document.forms[0].River.text="";document.forms[0].River.value="";DisableSearchPanelAdvancedFields('County',false);document.forms[0].CountyBuffer.enabled=true;document.forms[0].CountyBuffer.disabled=false;document.forms[0].CountyBuffer.style.background="#FFFFFF";DisableSearchPanelAdvancedFields('Catchment',true);DisableSearchPanelAdvancedFields('NGR',true);var townArray=eval(CountyDropDown.options[CountyDropDown.selectedIndex].text+"TownArray");document.forms[0].Town.length=0;var selectOption=new Option("Select",-1,true,true);document.forms[0].Town.options[0]=selectOption;for(x=0;x<townArray.length;x++){var tmpOption=new Option(townArray[x].substring(townArray[x].indexOf('|')+1,townArray[x].length),townArray[x].substring(0,townArray[x].indexOf('|')),false,false);document.forms[0].Town.options[document.forms[0].Town.length]=tmpOption}}return false}