
// Ajax Tables

function GetXmlHttpObject(handler)

{ 

		var objXmlHttp=null

		

		if (navigator.userAgent.indexOf("Opera")>=0)

		{

		 //alert("This example doesn't work in Opera") 

		 //return 

		    objXmlHttp=new XMLHttpRequest();

			objXmlHttp.onreadystatechange=handler ;

		//	objXmlHttp.onload=handler

			objXmlHttp.onerror=handler ;

			return objXmlHttp;

		}

		if (navigator.userAgent.indexOf("MSIE")>=0)

		{ 

			var strName="Msxml2.XMLHTTP";

			if (navigator.appVersion.indexOf("MSIE 5.5")>=0)

			{

				strName="Microsoft.XMLHTTP";

			} 

			try

			{ 

				objXmlHttp=new ActiveXObject(strName);

				objXmlHttp.onreadystatechange=handler; 

				return objXmlHttp;

			} 

			catch(e)

			{ 

				alert("Error. Scripting for ActiveX might be disabled"); 

			return ;

			} 

		} 

		if (navigator.userAgent.indexOf("Mozilla")>=0)

			{

			objXmlHttp=new XMLHttpRequest();

			objXmlHttp.onreadystatechange=handler; 

		//	objXmlHttp.onload=handler

			objXmlHttp.onerror=handler; 

			return objXmlHttp;

			}

} 


function CaseWiseValidate()
{
 	document.project.cn.value = LTrim(document.project.cn.value);
 	document.project.cn.value = RTrim(document.project.cn.value);
 	
   	document.project.cy.value = LTrim(document.project.cy.value);
   	document.project.cy.value = RTrim(document.project.cy.value);

	if(document.project.cn.value.length < 1 )
	{
		alert("Enter Case Number");
		document.project.cn.focus();
        	return(false);
	}


	if (isNaN(document.project.cn.value))
	{
		alert( "Enter numeric value in Case Number");
		document.project.cn.focus();
		return( false );
	}
		
	
        if (document.project.cn.value.length > 6)
	{
		alert( "Enter proper Case Number");
		document.project.cn.focus();
		return( false );
	}
		


	if(document.project.cy.value.length < 1)
	{
		alert("Enter Case Year");
		document.project.cy.focus();
        	return(false);
	}


	if (isNaN(document.project.cy.value))
	{
		alert( "Enter numeric value in Case Year");
		document.project.cy.focus();
		return( false );
	}

    document.project.submit();           
}


function CaseLowerCourtValidate()
{
	document.project.cn.value = LTrim(document.project.cn.value);
   	document.project.cn.value = RTrim(document.project.cn.value);
   	
   	if(document.project.cn.value.length < 1 )
	{
		alert("Enter Case Number");
		document.project.cn.focus();
		return(false);
	}
	if (isNaN(document.project.cn.value))
	{
		alert( "Enter numeric value in Case Number");
		document.project.cn.focus();
		return( false );
	}
	if (document.project.cn.value.length > 6)
	{
		alert( "Enter proper Case Number");
		document.project.cn.focus();
		return( false );
	}	
	
	
	var dt=document.project.day.value+"/"+document.project.mon.value+"/"+document.project.year.value;
	if (isDate(dt)==false)
	{	
		return false;
	}		
    	return true;
}



var dtCh= "/";

function isInteger(s)
{
    var i;
    for (i = 0; i < s.length; i++)
    {
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag)
{
    var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary(year)
{	
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n)
{
	for (var i = 1; i <= n; i++)
	{
		this[i] = 31;
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
		if (i==2) {this[i] = 29;}
	} 
	return this;
}







function isDate(dtStr)
{
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);

	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++)
	{
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth);
	day=parseInt(strDay);
	year=parseInt(strYr);
	if (pos1==-1 || pos2==-1)
	{
		alert("The date format should be : dd/mm/yyyy")
		return false;
	}
	if (strMonth.length<1 || month<1 || month>12)
	{
		alert("Please select a valid month");
		return false;
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month])
	{
		alert("Please select a valid day");
		return false;
	}
	if (strYear.length != 4 || year==0)
	{
		alert("Please select a valid 4 digit year");
		return false;
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false)
	{
		alert("Please select a valid date");
		return false;
	}
	return true;
}






function CaseStringValidate()
{
	document.project.litigantname.value = LTrim(document.project.litigantname.value);
	document.project.litigantname.value = RTrim(document.project.litigantname.value);

	if(document.project.litigantname.value.length < 1 )
	{
		alert("Enter the String to Search");
		document.project.litigantname.focus();
		return(false);
	}
	//if(document.project.litigantname.value.length < 5 )
//	{
//		alert("please enter a minimun of 5 character");
//		document.project.litigantname.focus();
//		return(false);
//	}


var url="litigantdata.jsp?litiganttype="+document.getElementById('litiganttype').value+"&litigantname="+document.getElementById('litigantname').value+"&waytosearch="+document.getElementById('waytosearch').value+"&cy="+document.getElementById('cy').value+"&colHiddenCal=sss";
xmlHttp=GetXmlHttpObject(CaseStringValidate123);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);

}

function CaseStringValidate123() 

{ 

	    if (xmlHttp.readyState==1)

		{
		
	document.getElementById("divlitigant").innerHTML="Loading...<img src='images/loading.gif'>";//
	document.getElementById("pageNavPosition").innerHTML="";
	
		}

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		{  if(xmlHttp.responseText.replace(/^\s+|\s+$/g,'').substring(0,2)=='EXP' )

		   {
			 alert("Data Not Entered Proper");
			 return false;
		   }  
		document.getElementById("divlitigant").innerHTML=xmlHttp.responseText.replace(/^\s+|\s+$/g,'');
		demo();
		} 

}




function CaseAdvctValidate()
{
	
	if ((document.getElementById('search').value.length < 1 ))
	{
		alert("Please Enter an Advocate Name");
		return(false);
	}
	else {
		if(document.getElementById('advocate_hidden_txt').value==""){

			alert("Please select the advocate only from the list available");
			return false;
		}
		else{

			document.getElementById('advocate_hidden_txt').value="";
		}
	}
	//alert(document.getElementById('country_hidden').value.replace(/^\s+|\s+$/g,''));
	var url="advocatewisedata.jsp?search="+document.getElementById('search').value+"&litiganttype="+document.getElementById('litiganttype').value+"&namecode="+document.getElementById('country_hidden').value.replace(/^\s+|\s+$/g,'')+"&cy="+document.getElementById('cy').value;
//	alert(url);
xmlHttp=GetXmlHttpObject(Caseadvocate123);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
	
    //	document.projectADVCT.submit();       
}

function Caseadvocate123() 

{ 

	    if (xmlHttp.readyState==1)

		{
		
	document.getElementById("divlitigant").innerHTML="Loading...<img src='images/loading.gif'>";//
	document.getElementById("pageNavPosition").innerHTML="";
	//document.getElementById("pageNavPosition1").innerHTML="";

		}

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		{  if(xmlHttp.responseText.replace(/^\s+|\s+$/g,'').substring(0,2)=='EXP' )

		   {

			 alert("Data Not Entered Proper");

			 return false;

		   }  

	//	alert(xmlHttp.responseText.replace(/^\s+|\s+$/g,''));
//		alert(document.getElementById("divlitigant").innerHTML);
		document.getElementById("divlitigant").innerHTML=xmlHttp.responseText.replace(/^\s+|\s+$/g,'');
		demo1();
		} 

}



function CaseTxtScrhValidate()
{
	
	if(document.getElementById("txtSearch").value.length < 1 )
	{
		alert("Enter the String to Search");
		document.getElementById("txtSearch").focus();
		return(false);
	}
	
	//alert("A"+document.getElementById('fdate').value+"A");
	if(document.getElementById('fdate').value=="")
	{
	 alert('Enter From date');
	 document.getElementById('fdate').focus();
	 return false;
	}

	if(document.project.tdate.value=="")
	{
	 alert('Enter to date');
	 	 document.getElementById('tdate').focus();
	 return false;
	}
	
    	var url="txtsrchdata.jsp?txtSearch="+document.getElementById('txtSearch').value+"&fdate="+document.getElementById('fdate').value+"&tdate="+document.getElementById('tdate').value;
xmlHttp=GetXmlHttpObject( CaseTxtScrhValidate123);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);
}
function CaseTxtScrhValidate123() 

{ 

	    if (xmlHttp.readyState==1)

		{
		
	document.getElementById("divlitigant").innerHTML="Loading...<img src='images/loading.gif'>";//
	document.getElementById("pageNavPosition").innerHTML="";
//	document.getElementById("pageNavPosition1").innerHTML="";

		}

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		{  if(xmlHttp.responseText.replace(/^\s+|\s+$/g,'').substring(0,2)=='EXP' )

		   {

			 alert("Data Not Entered Proper");

			 return false;

		   }  

	//	alert(xmlHttp.responseText.replace(/^\s+|\s+$/g,''));
//		alert(document.getElementById("divlitigant").innerHTML);
		document.getElementById("divlitigant").innerHTML=xmlHttp.responseText.replace(/^\s+|\s+$/g,'');
		demo1();
		} 

}



function AcceptCondt()
{
	if (document.DisclaimForm.agree[1].checked)
	{
		alert("Need to Agree to the Disclaimer to access the site");
		return false;
	}
	
}

function LoginValidate()
{

   if(document.LoginForm.ucode.value.length < 1)
	{
	alert("Enter User Code");
	document.LoginForm.ucode.focus();
        return(false);
	}

	if(isNaN(document.LoginForm.ucode.value))
	{
	alert("Enter Numeric value in User Code");
	document.LoginForm.ucode.focus();
        return(false);
	}

	if(document.LoginForm.password.value.length < 1)
	{
	alert("Enter Password");
	document.LoginForm.password.focus();
        return(false);
	}

   // pollwindow=window.open("alert.html","popup",
   //    "status=no.resize=no,toolbar=no,scrollbars=no,width=625,height=325,left=125,top=120,maximize=null");

   document.LoginForm.submit();
}



function CaseWiseReport1(getVals)
{		document.getElementById('hdnprint').Value="kakani";
		alert(getVals);
		CaseWiseReport(getVals);
}

function CaseWiseReport(getVals,prm)
{
	
	
	var options = "toolbar=0,status=0,menubar=0,scrollbars=1,resizable=0,width=350,height=400";
	
	//newwindow=window.open("./briefcasevdetails.jsp?"+getVals+"&prmreporttype="+prm,"mywindow", options);
	//alert(getVals);
	//getVals+="&prmrpttype="+prm;
	//alert(getVals);
	newwindow=window.open("./briefcasevdetails.jsp?"+getVals,"mywindow", options);
		//	newwindow.print();
		newwindow.document.close(); 
	//(location.href="./briefcasevdetails.jsp?"+getVals);
	return false;	
}

 
function ViewOrderReport(getVals)
{
	(location.href="./showtext1.jsp?"+getVals);
	return false;	
}




//==========================================================================

	function LTrim(VALUE)
	{
	  	var w_space = String.fromCharCode(32);
	  	if(v_length < 1)
		{
	 		return"";
		}

		var v_length = VALUE.length;
		var strTemp = "";
		var iTemp = 0;

		while(iTemp < v_length)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = VALUE.substring(iTemp,v_length);
				break;
			}
			iTemp = iTemp + 1;
		}
		return strTemp;
	}


	//removing the right spaces

	function RTrim(VALUE)
	{
		var w_space = String.fromCharCode(32);
		var v_length = VALUE.length;
		var strTemp = "";
		if(v_length < 0)
		{
			return"";
		}

		var iTemp = v_length -1;
	
		while(iTemp > -1)
		{
			if(VALUE.charAt(iTemp) == w_space)
			{
			}
			else
			{
				strTemp = VALUE.substring(0,iTemp +1);
				break;
			}
			iTemp = iTemp-1;

		} //End While
		return strTemp;

	} 

//===========================================================





//---------------------open window ---------------------------------------

  self.moveTo(0,0);
  self.resizeTo(screen.availWidth,screen.availHeight);

  function hidenclose(idName)
  {
	if(document.getElementById)
	    document.getElementById(idName).style.visibility = 'hidden'; 
    
	else if(document.all)
	    document.all(idName).style.visibility = 'hidden'; 
    
	else if(document.layers)
	    document.layers[idName].visibility = 'hidden'; 
  }

  function hidenopen(idName)
  {  
	if(document.getElementById)
	    document.getElementById(idName).style.visibility = 'visible' 
    
	else if(document.all)
	    document.all(idName).style.visibility = 'visible' 
    
	else if(document.layers)
	    document.layers[idName].visibility = 'show' 	  
  }
  
  
  function showThRExec(hidURLTrans)
  {    	
  	location.href = hidURLTrans;    	
  	return false;  	
  }
  

 
  function CaseJudgeValidate()
  {
  	
 // alert(document.projectJUDGE.JudgeNo.value.length);
  	if (document.getElementById('search').value.length < 1 )
  	{
  		alert("EnterJudge Name");
  		return(false);
  	}
  
 
  	if(document.getElementById('fdate').value.length!=10)
  	{
  		alert("Select From date ");
  		document.getElementById('fdate').focus();
  		return (false);
  	}
  
 
	if(document.getElementById('tdate').value.length!=10)
  	{
  		alert("Select To date ");
  		document.getElementById('tdate').focus();
  		return (false);
  	}
      
	  

var url="coramwisedata.jsp?search="+document.getElementById('search').value+"&namecode="+document.getElementById('country_hidden').value.replace(/^\s+|\s+$/g,'')+"&fdate="+document.getElementById('fdate').value+"&tdate="+document.getElementById('tdate').value;
//alert(url);
xmlHttp=GetXmlHttpObject(CaseJudgeValidate123);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);	  
	  
}





function CaseJudgeValidate123() 

{ 

	    if (xmlHttp.readyState==1)

		{
		
	document.getElementById("divlitigant").innerHTML="Loading...<img src='images/loading.gif'>";//
//	document.getElementById("pageNavPosition").innerHTML="";
	
		}

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		{  if(xmlHttp.responseText.replace(/^\s+|\s+$/g,'').substring(0,2)=='EXP' )

		   {
			 alert("Data Not Entered Proper");
			 return false;
		   }  
		document.getElementById("divlitigant").innerHTML=xmlHttp.responseText.replace(/^\s+|\s+$/g,'');
		demo1();
		} 

}


function CaseorderdateValidate()
{
	
		if(document.getElementById('fdate').value.length!=10)
  	{
  		alert("Select From date ");
  		document.getElementById('fdate').focus();
  		return (false);
  	}
  
 
	if(document.getElementById('tdate').value.length!=10)
  	{
  		alert("Select To date ");
  		document.getElementById('tdate').focus();
  		return (false);
  	}
      
	  

var url="orderdatewisedata.jsp?fdate="+document.getElementById('fdate').value+"&tdate="+document.getElementById('tdate').value;
xmlHttp=GetXmlHttpObject(CaseorderdateValidate123);
xmlHttp.open("GET", url , true);
xmlHttp.send(null);	  
}



function CaseorderdateValidate123() 

{ 

	    if (xmlHttp.readyState==1)

		{
		
	document.getElementById("divlitigant").innerHTML="Loading...<img src='images/loading.gif'>";//
	document.getElementById("pageNavPosition").innerHTML="";
//	document.getElementById("pageNavPosition1").innerHTML="";

		}

		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

		{ 
		document.getElementById("divlitigant").innerHTML=xmlHttp.responseText.replace(/^\s+|\s+$/g,'');
			demo1();
		} 

}



































  function numbersonly(e){
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode!=8 && unicode!=9 ){ //if the key isn't the backspace key (which we should allow)
		
	if (unicode<48||unicode>57) //if not a number
	return false; //disable key press
	}
	}

//------------------------------------------------------------

