function checkApprove()
{
	var radio = document.getElementsByName("option");
	document.getElementById("showError").style.display = "none";
	var isCheckd =false;
	for (counter = 0; counter < radio.length; counter++){
		if(radio[counter].checked==true){
			isCheckd = true;
		}
	}
	if(isCheckd==false){
		document.getElementById("showError").style.display = "block";
	}
	else{
		var form = document.getElementsByTagName("form");
		form[0].submit();
	}
		//checkStatus();
		
}
function cancel()
{
	var form = document.getElementById("agreeForm");
	form.action="NotAgreeServlet";
	form.submit();
//	window.location ="index.jsp";
}

function checkStatus()
{
	try 
	{
 		 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
 		 xmlhttp.open("POST","CheckStatus",false);
	 } 
	 catch (e) 
	 {
		  try 
		  {
			   xmlhttp = new XMLHttpRequest();
		   	   xmlhttp.open("GET","CheckStatus",false);
	  	  } 
   	  	  catch (E) 
	  	  {
		    xmlhttp=false;
          }
     }   
    
	xmlhttp.setRequestHeader("Content-Type", "text/xml");
	xmlhttp.onreadystatechange=getContenetCheckStatus;
	xmlhttp.send(null); 
}

function getContenetCheckStatus() 
{
	if (xmlhttp.readyState==4) 
	{
		if (xmlhttp.status==200) 
		{
			var content = xmlhttp.responseText;
			
			if(content.indexOf('ERROR')==0)
			{
				document.getElementById("message").innerHTML="ישנה בעיה במערכת , אנא נסה שנית במועד מאוחר יותר";
				document.getElementById("showError").style.display = "block";
				return;
			}
			else if(content.indexOf('N')==0)
			{
				window.location ="agree.jsp";
			}
			else if(content.indexOf('Y1')==0)
			{
				window.location ="ExistAndEligible.jsp";
			}
			else if(content.indexOf('Y2')==0)
			{
				window.location ="ExistAndNotEligible.jsp";
			}
			else if(content.indexOf('Y3')==0)
			{
				window.location ="notExistAndEligible.jsp";
			}
			else if(content.indexOf('Y4')==0)
			{
				window.location ="notExistAndNotEligible.jsp";
			}
			else if(content.indexOf('Y5')==0)
			{
				window.location ="renewedPolicyDetails.jsp";
			}
			else if(content.indexOf('BAD_PARAM')==0)
			{
				document.getElementById("message").innerHTML="המערכת אינה מזהה את אחד או יותר מהנתונים שהקשת - נא הקש את הנתונים מחדש";
				document.getElementById("showError").style.display = "block";
				return;
			}
					
		}
	}	
}

function openNewWindow(urlPath)
{
	window.open(urlPath,'','fullscreen=no,width=800,height=600,toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=no,resizable=yes',false);

	
}

