
		function weatherAction(rowval,ledname)
		{
			var peril = document.NGWFORM.perilname.value; // Peril name from the form
			var default_recommand =	 new String(document.NGWFORM.recvalue.value); // Default recommand string from the form.
			var defaultrecommand_for_row = default_recommand.charAt(rowval); // Default recommand for the selected row.
			var selected_action = new String(ledname); //ledname of the action selected by the user.
			var ledname_check; // convert the integer default recommandation(given by procedure) to char. 
			var message = "";
			var message1 = "";

			switch(defaultrecommand_for_row)
			{
				case '0': ledname_check = 'a';
						  break;	
						 
				case '1': ledname_check = 'b';
						  break;	

				case '2': ledname_check = 'c';
						  break;	

				case '9': ledname_check = 'b';
						  break;	
			}

			var userledname = selected_action.charAt(4); // Last character of the led name user selected.

		    if(ledname_check == 'a')
		    {
		   		message = " Repudiate";					
		    }	

		    if(ledname_check == 'b')
		    {
		   		message =  " Refer";					
		    }	

		    if(ledname_check == 'c')
		    {
		   		message =  " Accept";					
		    }

		    if(userledname == 'a')
		    {
		   		message1 = " Repudiate";					
		    }	

		    if(userledname == 'b')
		    {
		   		message1 =  " Refer";					
		    }	

		    if(userledname == 'c')
		    {
		   		message1 =  " Accept";					
		    }

   
			if(userledname == ledname_check)
			{
			   if(confirm("Do you wish to"+message+" this claim against this date?") == true)
			   {
					document.location.href='ngwWeatherAction.jsp?PARAM=0000000000000000000000000000002002&peril='+peril+'&id='+rowval+'&recon='+ledname;
			   }
			   else
			   {
			        defaultLED[rowval] = "led"+rowval+ledname_check;                         //change the default led in the array
		   		    rLED();
			   }
			}
			else
			{
				if(confirm("Do you really wish to override WeatherNet's recommendation of" +message+ " with " + message1+ "?") == true)
				{
					document.location.href='ngwWeatherAction.jsp?PARAM=0000000000000000000000000000002002&peril='+peril+'&id='+rowval+'&recon='+ledname;
			    }
			    else
			    {
				     defaultLED[rowval] = "led"+rowval+ledname_check;                         //change the default led in the array
					 rLED();
			    }
			}
				
//			document.location.href='ngwWeatherAction.jsp?PARAM=0000000000000000000000000000002002&peril='+peril+'&id='+rowval+'&recon='+ledname;
		}

		function weatherData(num,peril)
		{
			var newlossdate="";
			if(num == 1)
			{
				newlossdate = document.NGWFORM.prev7.value;
			}
			if(num == 2)
			{
				newlossdate = document.NGWFORM.prev1.value;
			}
			if(num == 3)
			{
				newlossdate = document.NGWFORM.next1.value;
			}

			if(num == 4)
			{
				newlossdate = document.NGWFORM.next7.value;
			}

			document.location.href = 'ngwWeatherData.jsp?PARAM=0000000000000000000000002002&peril='+peril+'&WDATE='+newlossdate;
		}
		
		function ngwFormValidation() // VALIDATION FORM MANDATORY FIELDS ON THE FORM.
		{
			var formated_value="";
			var m_formvalue = "";

    

			m_formvalue = removeExtraSpaces(document.NGWFORM.strclaimref.value);
			document.NGWFORM.strclaimref.value = m_formvalue; 			
			if(document.NGWFORM.strclaimref.value != "")
			{
				if(checkSpaces(document.NGWFORM.strclaimref.value) == true)
				{
					document.NGWFORM.strclaimref.value = "";
				}
				formated_value = removeExtraSpaces(document.NGWFORM.strclaimref.value);
				document.NGWFORM.strclaimref.value = formated_value;
			}


			if(document.NGWFORM.strpostcode.value == "" || checkSpaces(document.NGWFORM.strpostcode.value) == true)
			{
				alert("Please enter the postcode of the claim");
				document.NGWFORM.strpostcode.focus();
				return;
			}
                        changeCaseNoStrip(document.NGWFORM.strpostcode.value);

			m_formvalue = removeExtraSpaces(document.NGWFORM.strdistrict.value);
			document.NGWFORM.strdistrict.value = m_formvalue; 			
			if(document.NGWFORM.strdistrict.value == "")
			{
				alert("Please enter the postcode district of the claim");
				document.NGWFORM.strdistrict.focus();
				return;
			}
			else
			{
				changeCase(document.NGWFORM.strdistrict);
			}

			m_formvalue = removeExtraSpaces(document.NGWFORM.strsector.value);
			document.NGWFORM.strsector.value = m_formvalue; 			
			if(document.NGWFORM.strsector.value != "")
			{
				if(checkSpaces(document.NGWFORM.strsector.value) == true)
				{
					document.NGWFORM.strsector.value = "";
				}
				else
				{	
					var sectorval = removeExtraSpaces(document.NGWFORM.strsector.value);
					if(sectorval == 'N/A' || sectorval == 'n/a')
					{
						document.NGWFORM.strsector.value = sectorval;
					}
					else
					{
						if(sectorvalidate(document.NGWFORM.strsector) != true)
						{
							document.NGWFORM.strsector.focus();
							return;
						}
					}
				}
			}

			m_formvalue = removeExtraSpaces(document.NGWFORM.strlossdate.value);
			document.NGWFORM.strlossdate.value = m_formvalue; 			

			if(document.NGWFORM.strlossdate.value == "")
			{
				alert("Please enter the Loss Date for the search");
				document.NGWFORM.strlossdate.focus(); 
				return; 
			}
			else
			{
			    if(dateCheckQueryInput(document.NGWFORM.strlossdate.value) == false)
				{
					document.NGWFORM.strlossdate.focus(); 
					return;
				}
				checkPreDate(document.NGWFORM.strlossdate.value);
//				if(document.NGWFORM.orccheck.value == 1)
//				{
//					return;
//				}
			}

			m_formvalue = removeExtraSpaces(document.NGWFORM.strclaimvalue.value);
			document.NGWFORM.strclaimvalue.value = m_formvalue; 			
			if(document.NGWFORM.strclaimvalue.value != "")
			{
				if(checkSpaces(document.NGWFORM.strclaimvalue.value) == true)
				{
					document.NGWFORM.strclaimvalue.value = "";
				}
				else
				{
					var strclaimval1 =  removeExtraSpaces(document.NGWFORM.strclaimvalue.value);	
					if(strclaimval1 == 'n/a' || strclaimval1 == 'N/A')
					{
						document.NGWFORM.strclaimvalue.value = strclaimval1;
					}
					else
					{
						if(claimval_validate(strclaimval1) == false)
						{
							document.NGWFORM.strclaimvalue.value = strclaimval1;
							document.NGWFORM.strclaimvalue.focus();
							return;
						}
					}
				}
			}

			m_formvalue = removeExtraSpaces(document.NGWFORM.strclaimref.value);
			if(m_formvalue == "")
			{
				if(confirm("Are you sure you have no claim reference for this claim?") != true)
				{
					document.NGWFORM.strclaimref.focus();
					return;						
				}					
			}				
			m_formvalue = removeExtraSpaces(document.NGWFORM.strsector.value);
			if(m_formvalue == "")
			{
				if(confirm("Are you sure you have no sector for this claim?") != true)
				{
					document.NGWFORM.strsector.focus();
					return;						
				}					
			}				
			m_formvalue = removeExtraSpaces(document.NGWFORM.strclaimvalue.value);
			if(m_formvalue == "")
			{
				if(confirm("Are you sure you have no value or estimate for this claim?") != true)
				{
					document.NGWFORM.strclaimvalue.focus();
					return;						
				}					
			}				

                        var linkObj = document.getElementById('formvalidation');
                        linkObj.href = "#";
			// Code which converts the entered date into dd/mm/yyyy(i.e if dd=x it changes to 0x
			// and if mm=x	changes to 0x.

			var loss_date1 = new String(document.NGWFORM.strlossdate.value)
			loss_date = loss_date1.split("/");
			var loss_day = new String(loss_date[0]);
			var loss_month = new String(loss_date[1]);
			var loss_year = new String(loss_date[2]);

			if(loss_day.length == 1)
			{
				loss_day = "0"+loss_day;
			}
	
			if(loss_month.length == 1)
			{
				loss_month = "0"+loss_month;
			}
			document.NGWFORM.strlossdate.value = loss_day+"/"+loss_month+"/"+loss_year;
			document.NGWFORM.submit();
	}
	

		function ngwLoginValidation() // VALIDATION FORM MANDATORY FIELDS ON THE FORM.
		{
			if(document.NGWFORM.userid.value == "")
			{
				alert("Please enter the Username");
				document.NGWFORM.userid.focus();
				return;
			}

			if(document.NGWFORM.password.value == "")
			{
				alert("Please enter the Password");
				document.NGWFORM.password.focus();
				return;
			}

			document.NGWFORM.submit();
	   
		}

		function changeCase(fieldObj) // REMOVE SPACES AND CHANGE TO UPPERCASE.
		{
			var spacecount = 0;
			var fvalue = new String(fieldObj.value);
			var strformatted  = new String();
			if(fieldObj.value != "")
			{
				for(var i=0;i<=fvalue.length - 1;i++)
				{
					if(fvalue.charAt(i) == " ")
					{
						spacecount++;
					}
					else
					{
						strformatted = strformatted + fvalue.charAt(i);
					}	 
				}
				if(spacecount == fvalue.length)
				{
					fieldObj.value = "";
					return;
				}	
			}
			fieldObj.value = strformatted.toUpperCase();			
		}

                function changeCaseNoStrip(fieldObj) // CHANGE TO UPPERCASE.
		{
			var spacecount = 0;
			var fvalue = new String(fieldObj.value);
			fieldObj.value = fvalue.toUpperCase();			
		}
		function clearForm()   //CLEAR ALL THE FORM FIELDS.
		{
		    var tot = document.NGWFORM.elements.length;

			for(var i=0;i<=tot-1;i++) 
			{
				if(document.NGWFORM.elements[i].type == "checkbox") 
			 	{
					document.NGWFORM.elements[i].checked=false;
				} 
		
			   	if(document.NGWFORM.elements[i].type == "select-one")
				{
					var namec = document.NGWFORM.elements[i].name;
					eval('document.NGWFORM.'+namec+'[0].selected=true');
				} 

			    if(document.NGWFORM.elements[i].type == "text")
			    {		
			   		document.NGWFORM.elements[i].value="";
	    	    }

			}		  
			document.NGWFORM.elements[0].focus();
		}

		function sectorvalidate(sector)
		{
//		if(document.NGWFORM.orc.value == 0) //CHECKS IF SECTOR VALIDATION IS OK.
//		{

			changeCase(sector);
			var strsec = new String(sector.value);

			if(strsec.length > 3)
			{
				alert("Postcode Sectors are always a number, followed by 2 letters" +"\n"+
					  "Please enter a valid Sector or clear the field");

				//THIS FIELD(ORC) ON THE FORM IS USED TO STOP THE LOOP IN VALIDATION
				//WHEN USER TAB FROM SECTOR FIELD. THE 'orc' FIELD IS SET TO 1
				//WHICH AVOID CALLING LOSSDATE VALIDATION IF SECTOR VALIDATION IS FAILED.
				//YOU CAN SEE IN FUNCTION 'checkLossDate()' THE CONDITION IS CHECKED
				//THIS IS DUE TO BUG ON NETSCAPE ONBLUR EVENT.

				document.NGWFORM.orc.value = 1;  
//				document.NGWFORM.strsector.focus();
				return false;
			}
			else
			{
				document.NGWFORM.orc.value = 0;
			}

			if(isNaN(strsec.charAt(0)) == true)
			{
				alert("Postcode Sectors are always a number, followed by 2 letters" +"\n"+
					  "Please enter a valid Sector or clear the field");

				//THIS FIELD(ORC) ON THE FORM IS USED TO STOP THE LOOP IN VALIDATION
				//WHEN USER TAB FROM SECTOR FIELD. THE 'orc' FIELD IS SET TO 1
				//WHICH AVOID CALLING LOSSDATE VALIDATION IF SECTOR VALIDATION IS FAILED.
				//YOU CAN SEE IN FUNCTION 'checkLossDate()' THE CONDITION IS CHECKED
				//THIS IS DUE TO BUG ON NETSCAPE ONBLUR EVENT.

				document.NGWFORM.orc.value = 1;  
//				document.NGWFORM.strsector.focus();
				return false;
			}
			else
			{
				document.NGWFORM.orc.value = 0;
			}

			if(isNaN(strsec.charAt(1)) == false || isNaN(strsec.charAt(2)) == false)
			{
				alert("Postcode Sectors are always a number, followed by 2 letters" +"\n"+
					  "Please enter a valid Sector or clear the field");

				//THIS FIELD(ORC) ON THE FORM IS USED TO STOP THE LOOP IN VALIDATION
				//WHEN USER TAB FROM SECTOR FIELD. THE 'orc' FIELD IS SET TO 1
				//WHICH AVOID CALLING LOSSDATE VALIDATION IF SECTOR VALIDATION IS FAILED.
				//YOU CAN SEE IN FUNCTION 'checkLossDate()' THE CONDITION IS CHECKED
				//THIS IS DUE TO BUG ON NETSCAPE ONBLUR EVENT.

				document.NGWFORM.orc.value = 1;  
//				document.NGWFORM.strsector.focus();
				return false;
			}
			else
			{
				document.NGWFORM.orc.value = 0;
			}

			return true;
//		}
		}

		function lossdatevalidate(lossdate)
		{
			if(lossdate != "")
			{
				if(dateCheck(lossdate) == false)
				{
					document.NGWFORM.strlossdate.focus();
					return;
				}
			}
		}

		function claimval_validate(clvalue)
		{
			if(clvalue != "")
			{
				if(isNaN(clvalue) == true)
				{
					alert("Claim value must be number");
					document.NGWFORM.strclaimvalue.focus();
					return false;
				}
				if(clvalue < 10 || clvalue > 9999999 )
				{
					alert("The value of claim must lie in the range £10...£9,999,999");
					document.NGWFORM.strclaimvalue.focus();
					return false;
				}

				if(clvalue > 9999)
				{
					if(confirm("Claim value is £10,000 or more, is the claim value correct?") == false)
					{
						document.NGWFORM.strclaimvalue.focus();
						return false;
					}
				}
			}
		}


		function dateCheck(loss_date) // VALIDATES LOSS DATE ENTERED ON THE FORM
		{
			// STRING TO GET THE TODAY DATE FROM THE HTMLL FORM

			var today_form = document.NGWFORM.strtoday.value; 

			if(isValidDate(loss_date) == false)
			{
				document.NGWFORM.strlossdate.focus();
				return false;
			}

			today_date = new Date(); // TODAYS DATE
			lossdate = new Date();   // DATE OBJECT USE TO SET USER ENTERED LOSS DATE 
								     // FOR DATE VALIDATION.	
			date_limit = new Date();
			date_limit.setMonth(0);
			date_limit.setDate(1);
			date_limit.setYear(1997);

			
			var datePat4 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
			var matchArray4 = loss_date.match(datePat4); // Check patten match for user date.
			var matchArray5 = today_form.match(datePat4);

			// SETTING DAY,MONTH,YEAR returned by the match function to local variables.
			day = matchArray4[1];
			month = matchArray4[3];
			year = matchArray4[4];

			lossdate.setMonth(--month); //setting lossdate object with user values.
			lossdate.setDate(day);
			lossdate.setYear(year);

			day_tod = matchArray5[1];   //SETTING TODAYDATE OBJECT WITH VALUES FROM THE FORM.
			month_tod = matchArray5[3];
			year_tod = matchArray5[4];

			today_date.setMonth(--month_tod);
			today_date.setDate(day_tod);
			today_date.setYear(year_tod);

			if(lossdate.getTime() > today_date.getTime())
			{
				alert("Please enter a valid loss date");
				return false;
			}

			if(lossdate.getTime() == today_date.getTime())
			{
				var message = "This system only holds weather data up to yesterday." + "\n"+
				              "For information about today's weather please contact WeatherNet.";
				alert(message);
				return false;
			}

			year1 = year_tod - 1;
			today_date.setYear(year1);
			var today_minus_year = new String(today_date);

			if(lossdate.getTime() < today_date.getTime())
			{
				if(confirm("Is the loss date correct?") == true)
				{
					if(lossdate.getTime() < date_limit.getTime())
					{
						var message = "This system only holds weather data up to 1st January 1997. " + "\n"+
		                              "For information about earlier dates please contact WeatherNet.";
						alert(message);
						return false;
					}
					else
					{
						return true;
					}
				}
				else
				{
					return false;
				}
			}

			return true;
		}



		function dateCheckQueryInput(loss_date) // VALIDATES LOSS DATE ENTERED ON THE FORM
		{
			// STRING TO GET THE TODAY DATE FROM THE HTMLL FORM

			var today_form = document.NGWFORM.strtoday.value; 

			if(isValidDate(loss_date) == false)
			{
				document.NGWFORM.strlossdate.focus();
				return false;
			}

			today_date = new Date(); // TODAYS DATE
			lossdate = new Date();   // DATE OBJECT USE TO SET USER ENTERED LOSS DATE 
								     // FOR DATE VALIDATION.	
			date_limit = new Date();
			date_limit.setMonth(0);
			date_limit.setDate(1);
			date_limit.setYear(1997);

			
			var datePat4 = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
			var matchArray4 = loss_date.match(datePat4); // Check patten match for user date.
			var matchArray5 = today_form.match(datePat4);

			// SETTING DAY,MONTH,YEAR returned by the match function to local variables.
			day = matchArray4[1];
			month = matchArray4[3];
			year = matchArray4[4];

			lossdate.setMonth(--month); //setting lossdate object with user values.
			lossdate.setDate(day);
			lossdate.setYear(year);

			day_tod = matchArray5[1];   //SETTING TODAYDATE OBJECT WITH VALUES FROM THE FORM.
			month_tod = matchArray5[3];
			year_tod = matchArray5[4];

			today_date.setMonth(--month_tod);
			today_date.setDate(day_tod);
			today_date.setYear(year_tod);

			if(lossdate.getTime() > today_date.getTime())
			{
				alert("Please enter a valid loss date");
				return false;
			}

//			if(lossdate.getTime() == today_date.getTime())
//			{
//				var message = "This system only holds weather data up to yesterday." + "\n"+
//				              "For information about today's weather please contact WeatherNet.";
//				alert(message);
//				return false;
//			}

			year1 = year_tod - 1;
			today_date.setYear(year1);
			var today_minus_year = new String(today_date);

			if(lossdate.getTime() < today_date.getTime())
			{
				if(confirm("Is the loss date correct?") == true)
				{
					if(lossdate.getTime() < date_limit.getTime())
					{
						var message = "This system only holds weather data up to 1st January 1997. " + "\n"+
		                              "For information about earlier dates please contact WeatherNet.";
						alert(message);
						return false;
					}
					else
					{
						return true;
					}
				}
				else
				{
					return false;
				}
			}

			return true;
		}



		function isValidDate(dateStr) 
		{
			if (dateStr == "") return true;
			var datePat4 = /^(\d{1,2})(\/)(\d{1,2})\2(\d{4})$/;
			var matchArray4 = dateStr.match(datePat4);
			if (matchArray4 == null) 
			{
				alert("Date is not in a valid format. Should be dd/mm/yyyy");
				return false;
			}
			else 
			{
				day = matchArray4[1];
				month = matchArray4[3];
				year = matchArray4[4];
			}

			if (month < 1 || month > 12) 
			{ // check month range
				alert("Month must be between 1 and 12.");
				return false;
			}
			if (day < 1 || day > 31) 
			{
				alert("Day must be between 1 and 31.");
				return false;
			}
			if ((month==4 || month==6 || month==9 || month==11) && day==31) 
			{
				alert("Month " + month + " doesn't have 31 days!")
				return false
			}
			if (month == 2) 
			{
				var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
				if (day>29 || (day==29 && !isleap)) 
				{
					alert("February " + year + " doesn't have " + day + " days");
					return false;
				}
			}	
			return true;
		}


	function popWindowInfo(url,h,w) 
	{
		var peril=document.NGWFORM.perilname.value;
		var pid = 10;

	    if(peril == 'wind')
		{
			pid = 10;
		}

	    if(peril == 'rain')
		{
			pid = 20;
		}

	    if(peril == 'lightning')
		{
			pid = 30;
		}

	    if(peril == 'freeze')
		{
			pid = 40;
		}

	    if(peril == 'flood')
		{
			pid = 50;
		}

	    if(peril == 'hail')
		{
			pid = 60;
		}

	    if(peril == 'snow')
		{
			pid = 70;
		}

	    if(peril == 'earthquake')
		{
			pid = 80;
		}

		var url1 ="ngwpopup-"+peril+".jsp?info="+url+"&pid="+pid;	
		window.open(url1,"wData","height="+h+",width="+w+",screenX=10,left=10,screenY=10,top=10,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0");
	}

   function	popWindowReport(h,w) 
   {
	   var peril=document.NGWFORM.perilname.value;  
	   var url1 ="ngwsummary-"+peril+".jsp";
	   if(peril == 'wind' || peril == 'rain' || peril == 'freeze' || peril == 'snow')
	   {
		   url1 = "ngwImageServlet?peril="+peril
		   window.open(url1,"wData","height="+h+",width="+w+",screenX=10,left=10,screenY=10,top=10,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0");
	   }
	   else
	   {
		   window.open(url1,"wData","height="+h+",width="+w+",screenX=10,left=10,screenY=10,top=10,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0");
	   }
   }

   function	popWindowSummary(h,w) 
   {
	
	   var url1 ="ngwDetailSummary.jsp";
	window.open(url1,"wData","height="+h+",width="+w+",screenX=5,left=5,screenY=5,top=5,menubar=0,scrollbars=yes,resizable=1,status=0,toolbar=0");

   }



	function checkSpaces(formvalue)
	{
	   var unameval = new String(formvalue);
	   var spacecount = 0;

	   for(var i=0;i<=unameval.length - 1;i++)
	   {
	       if(unameval.charAt(i) == " ")
	       {
		        spacecount++;
	       }	 
	   }

	   if(spacecount == unameval.length)
	   {
			return true;
	   }	
	   else
	   {
			return false;
 	   }
	}

	function removeExtraSpaces(formvalue)
	{
	   var unameval = new String(formvalue);
	   var spacecount = 0;
	   var str_space_removed = "";

	   for(var i=0;i<=unameval.length - 1;i++)
	   {
	       if(unameval.charAt(i) != " ")
	       {
				str_space_removed = str_space_removed + unameval.charAt(i);		        
	       }	 
	   }
	   return str_space_removed;
	}

	// FUNCTION VALIDATE THE CLAIM REFERENCE FIELD ON THE FORM.
	function checkClaimRef()
	{
		var formated_value="";
			if(checkSpaces(document.NGWFORM.strclaimref.value) == true)
			{
				document.NGWFORM.strclaimref.value = "";
			}
			formated_value = removeExtraSpaces(document.NGWFORM.strclaimref.value);
			document.NGWFORM.strclaimref.value = formated_value;

	}

	// FUNCTION VALIDATE THE DISTRICT FIELD ON THE FORM.
	function checkDistrict()
	{
			if(checkSpaces(document.NGWFORM.strdistrict.value) == true)
			{
				alert("Please enter the postcode district of the claim");
				document.NGWFORM.strdistrict.value = "";
				document.NGWFORM.strdistrict.focus();
				return;
			}
			else
			{
				changeCase(document.NGWFORM.strdistrict);
				doDistrictCheck();
			}

	}

	// FUNCTION VALIDATES THE SECTOR FIELD ON THE FORM
	function checkSector()
	{
			if(checkSpaces(document.NGWFORM.strsector.value) == true)
			{
				document.NGWFORM.strsector.value = "";
			}
			else
			{	
				var sectorval = removeExtraSpaces(document.NGWFORM.strsector.value);
				if(sectorval == 'n/a' || sectorval == 'N/A')
				{
					document.NGWFORM.strsector.value = sectorval;
					return;
				}
				else
				{
					if(sectorvalidate(document.NGWFORM.strsector) != true)
					{
						document.NGWFORM.strsector.focus()
						return;
					}
				}
			}
	}

	// FUNCTION VALIDATE THE LOSSDATE ENTERED ON THE FORM
	function checkLossDate()
	{
		if(document.NGWFORM.strlossdate.value == "")
		{
			alert("Please enter the loss date for the search");
			document.NGWFORM.strlossdate.focus(); 
			return; 
		}
		else
		{
			checkPreDate(document.NGWFORM.strlossdate.value);
		}
	}

	//FUNCTION VALIDATE THE CLAIM VALUE ENTERED IN THE FORM
	function checkClaimValue()
	{
		if(checkSpaces(document.NGWFORM.strclaimvalue.value) == true)
		{
			document.NGWFORM.strclaimvalue.value = "";
		}
		else
		{
			var strclaimval1 =  removeExtraSpaces(document.NGWFORM.strclaimvalue.value);	
			if(strclaimval1 == 'n/a' || strclaimval1 == 'N/A')
			{
				document.NGWFORM.strclaimvalue.value = strclaimval1;					
				return;
			}
			else
			{
				claimval_validate(strclaimval1);
				document.NGWFORM.strclaimvalue.value = strclaimval1;
			}
		}
	}


	// FUNCTION TO PRE CHECK DATE IF ONLY DATE IS ENTERED THEN ADD CURRENT MONTH AND YEAR ELSE DO
	// REGULAR DATE VALIDATION
	function checkPreDate(dval)
	{
		var today_form = document.NGWFORM.strtoday.value; // TODAY DATE FROM FORM
		var datevalue = new String(dval); // CONVERT TODAY TO STRING OBJECT
		var datePat4 = /^(\d{1,2})(\/)(\d{1,2})\2(\d{4})$/;

		if(datevalue.length == 2 || datevalue.length == 1) //IF DAY LENGTH > 2 DO NORMAL VALIDATION
		{
			if(isNaN(dval) == true)
			{
				alert("Invalid Date entered Loss Date(DAY) cannot be charater");
				document.NGWFORM.strlossdate.focus();
				return false;
			}

			var date_str = new String(document.NGWFORM.strtoday.value);
			document.NGWFORM.strlossdate.value = datevalue+date_str.substr(2,9); // APPEND MONTH AND YEAR TO THE DAY ENTERED. 
		}

	}

	// FUNCTION INVOKED WHEN A START NEW CLAIM BUTTON CLICKED FROM ANY PERIL
	// CHECKS IF ACTION HAS BEEN CONFIRMED TO START A NEW SEARCH
	function StartnewClaim()
	{
		var param = document.NGWFORM.param.value;

		if(param == 'DATA')
		{
			   var mess = " Please decide upon the most probable date of loss and, against this date \n" +
			              " either confirm the WeatherNet recommendation \n"+
			              " or select & register your action ( Click Cancel to abandon this claim )";
				if(confirm(mess) == true)
				{
					return;
				}
				else
				{
				   document.location.href =	'ngwStartnewClaim.jsp';
				}
		}
		else
		{
			   document.location.href =	'ngwStartnewClaim.jsp';
		}
	}

	// FUNCTION IS INVOKED FROM CLAIM INPUT SCREEN IF START NEW CLAIM BUTTON IS CLICKED
	// WITHOUT RUNNING RUN WEATHER CHECK. HERE START NEW CLAIM WORKS AS CANCEL.
	function cancelClaim()
	{
		if(document.NGWFORM.strclaimref.value != "" ||
			document.NGWFORM.strdistrict.value != "" ||
			document.NGWFORM.strsector.value != "" ||
			document.NGWFORM.strlossdate.value != "" ||
			document.NGWFORM.strclaimvalue.value != "")
			{
			   if(confirm("Do you wish to Abandon this claim ?") == true)
			   {
					clearForm();
			   }
			   else
			   {
					return;
			   }
				
			}
			else
			{
				clearForm();
			}
	}

	function doDistrictCheck()
	{
		document.NGWFORMDIS.mstrclaimref.value = document.NGWFORM.strclaimref.value;
		document.NGWFORMDIS.mstrdistrict.value = document.NGWFORM.strdistrict.value;
		document.NGWFORMDIS.mstrsector.value = document.NGWFORM.strsector.value;
		document.NGWFORMDIS.mstrlossdate.value = document.NGWFORM.strlossdate.value;
		document.NGWFORMDIS.mstrclaimvalue.value = document.NGWFORM.strclaimvalue.value;
		document.NGWFORMDIS.submit();
 	}

	function changeCaseNA(fieldObj)
	{
		var f_value = fieldObj.value;
		if(f_value != "")
		{
			var temp = removeExtraSpaces(f_value)
			if(temp == 'n/a' || temp == 'N/A')
			{
				fieldObj.value = 'N/A';
				return;
			}
		}
	}


	function checkPreDateNew(dval)
	{
		var today_form = document.NGWFORM.strtoday.value; // TODAY DATE FROM FORM
		var datevalue = new String(dval); // CONVERT TODAY TO STRING OBJECT
		var datePat4 = /^(\d{1,2})(\/)(\d{1,2})$/;
		var datePat1 = /^(\d{1,2})$/;
		var date_str = new String(document.NGWFORM.strtoday.value);

		if(datevalue.indexOf("/") == -1) 
		{
			if(datevalue.length == 2 || datevalue.length == 1) //IF DAY LENGTH > 2 DO NORMAL VALIDATION
			{
				if(isNaN(dval) == true)
				{
					alert("Invalid Date entered Loss Date(DAY) cannot be charater");
					document.NGWFORM.strlossdate.focus();
					return false;
				}

				document.NGWFORM.strlossdate.value = datevalue+date_str.substr(2,9); // APPEND MONTH AND YEAR TO THE DAY ENTERED. 
			}
		}
		else
		{
			if(datevalue.length > 2 && datevalue.length <=5)
			{
				document.NGWFORM.strlossdate.value = datevalue+date_str.substr(5,9); // APPEND YEAR TO THE DAY AND MONTH ENTERED. 
			}
		}
	}

	function LogoutApp()
	{
		if(confirm("Are you sure you wish to quit the application?") == true)
		{
		   document.location.href =	'ngwLogoutApp.jsp';
		}
		else
		{
			return;
		}
	}


    function checkPostCode()
    {
        
        if(document.NGWFORM.strpostcode.value == "")
        {
            return;
        }
        else
        {
            changeCaseNoStrip(document.NGWFORM.strpostcode);
            if(checkForSpecialCharacter(document.NGWFORM.strpostcode.value) == false)
            {
                var param_array = new Array();
                var formpostcode = removeExtraSpaces(document.NGWFORM.strpostcode.value);
                param_array[0] = formpostcode;
                jsrsExecute("ngwRemoteServlet", postcodeValidatePost, "validatPostCodeFormat", param_array);
            }
            else
            {
                alert("Invalid postcode entered. The postcode field cannot have special character.");
                document.NGWFORM.strpostcode.focus();
                return;
            }
        }
    }

    function postcodeValidatePost(valueTextStr)
    {
        if(valueTextStr == "")
        {
            alert("The entered Postcode is not a valid format.");
            document.NGWFORM.strpostcode.focus();
            return;
        }
        else
        {
            var postcode = valueTextStr.split(":");
            document.NGWFORM.strdistrict.value = postcode[0];
            document.NGWFORM.strsector.value = postcode[1];
        }
    }


    function checkForSpecialCharacter(strvalue)
    {
        var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
        for (var i = 0; i < strvalue.length; i++) {
            if (iChars.indexOf(strvalue.charAt(i)) != -1) {
            return true;
            }
        }
        return false;
    }


