// JavaScript Document
function showHide(fldId,option){
	try{
			if(option == "hide"){
				document.getElementById(fldId).style.display = 'none';
			}
			else{			
				document.getElementById(fldId).style.display = 'block';
			}
		}catch(e){
		alert(e.descriptions);
		}
	}
	
//function to get NIC #
function getNIC(empName){
	//alert(empName);	
	var objNic;
	try{	
			if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  objNic=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  objNic=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			  objNic.onreadystatechange=function()
			  {
			  if (objNic.readyState !=4){
				document.getElementById("waitMsg").innerHTML = "<img src='../../images/loading/loading.gif' /> <span style='position:relative; top:-10px;'> Loading wait... </span>";
				}
			 else {
				 document.getElementById("NIC").innerHTML = objNic.responseText;
				 document.getElementById('waitMsg').innerHTML = '';
				 }
			  }
				// GET Method
				//objNic.open("GET","../ajaxPhp/getNIC.php?empName="+empName,true);				
				//objNic.send();
				
				// POST Method
				objNic.open("POST","../ajaxPhp/getNIC.php",true);
				objNic.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				objNic.send("empName="+empName);
				//alert(empName);
		}catch(e){
		alert(e.descriptions);
		}
	}
   //function to allow only 4 digits in the year field
   function checkYear(val) {
	   try{
		   if(isNaN(val) || val.length > 4 || val.length < 4){
			   	  alert("Provided Number Must be 4 Digits Number");
		  	     }
		   }catch(e){
		   alert(e.descriptions);
		   }
	   }

//function to confirm and then transfer case to other court
function confirmTransferCase(newCaseNumberT,transferDateT,empSnoT,caseSnoT,courtNoT,caseNumberT,caseTitleT,OriginalInstitutionT,reInstitutionT,dateOfHearingT,stageOfProceedingsT,isDecidedT,caseNatureT,isCurrentT,isOutT,isTransferredT,transferToCourtT){
	var conf = "Are you sure you want to Transfer "+caseTitleT+" \nPermanently From \n\t "+courtNoT+" To \n\t "+transferToCourtT+"\n\tWith New Number OF Case AS:"+newCaseNumberT+"\n\tAND\n\tTransfer Date : "+transferDateT+" ?";
	var str = "newCaseNumberT = "+newCaseNumberT+"\ntransferDateT="+transferDateT+"\nempSnoT="+empSnoT+"\ncaseSnoT="+caseSnoT+"\ncourtNoT="+courtNoT+"\ncaseNumberT="+caseNumberT+"\ncaseTitleT="+caseTitleT+"\nOriginalInstitutionT="+OriginalInstitutionT+"\nreInstitutionT="+reInstitutionT+"\ndateOfHearingT="+dateOfHearingT+"\nstageOfProceedingsT="+stageOfProceedingsT+"\nisDecidedT="+isDecidedT+"\ncaseNatureT="+caseNatureT+"\nisCurrentT="+isCurrentT+"\nisOutT="+isOutT+"\nisTransferredT="+isTransferredT+"\ntransferToCourtT="+transferToCourtT;
	if(newCaseNumberT.length < 1 || transferDateT.length < 1 || empSnoT.length < 1 || caseSnoT.length < 1 || courtNoT.length < 1 || caseNumberT.length < 1 || caseTitleT.length < 1 || OriginalInstitutionT.length < 1 || reInstitutionT.length < 1 || dateOfHearingT.length < 1 || stageOfProceedingsT.length < 1 || isDecidedT.length < 1 || caseNatureT.length < 1 || isCurrentT.length < 1 || isOutT.length < 1 || isTransferredT.length < 1 || transferToCourtT.length < 1){
		alert("Please Provide Case Transfering Date And New Number for Case");
		//alert(str);	
		}
	else{
		//alert(conf);
			if(!confirm(conf)){ 
				//alert('Not Confirmed');
			}
			else {
				//alert(empSnoT+"\n"+caseSnoT+"\n"+courtNoT+"\n"+caseNumberT+"\n"+caseTitleT+"\n"+OriginalInstitutionT+"\n"+reInstitutionT+"\n"+dateOfHearingT+"\n"+stageOfProceedingsT+"\n"+isDecidedT+"\n"+caseNatureT+"\n"+isCurrentT+"\n"+isOutT+"\n"+isTransferredT+"\n"+transferToCourtT);	
				//alert(str);
			var objCase;
			try{	
					if (window.XMLHttpRequest)
					  {// code for IE7+, Firefox, Chrome, Opera, Safari
					  objCase=new XMLHttpRequest();
					  }
					else
					  {// code for IE6, IE5
					  objCase=new ActiveXObject("Microsoft.XMLHTTP");
					  }
					  objCase.onreadystatechange=function()
					  {
					  if (objCase.readyState !=4){
						document.getElementById("msg").innerHTML = "<img src='../../images/loading/loading.gif' /> <span style='position:relative; top:-10px;'> Loading wait... </span>";
						}
					 else {
						 document.getElementById("msg").innerHTML = objCase.responseText;
						 }
					  }										
						// POST Method
						var params = "newCaseNumber="+newCaseNumberT+"&transferDate="+transferDateT+"&empSno="+empSnoT+"&caseSno="+caseSnoT+"&courtNo="+courtNoT.replace("&","|")+"&caseNumber="+caseNumberT+"&caseTitle="+caseTitleT+"&OriginalInstitution="+OriginalInstitutionT+"&reInstitution="+reInstitutionT+"&dateOfHearing="+dateOfHearingT+"&stageOfProceedings="+stageOfProceedingsT+"&isDecided="+isDecidedT+"&caseNature="+caseNatureT+"&isCurrent="+isCurrentT+"&isOut="+isOutT+"&isTransferred="+isTransferredT+"&transferToCourt="+transferToCourtT.replace("&","|");
						objCase.open("POST","../ajaxPhp/transferCaseToOtherCourt.php",true);
						objCase.setRequestHeader("Content-type","application/x-www-form-urlencoded");
						objCase.send(params);
						//alert(params);						
				}catch(e){
				alert(e.descriptions);
				}
			}
	}//end else
	}	

//function to get empSno
function getEmpSno(courtNo){
	var objEmpSno;
	try{	
			if (window.XMLHttpRequest)
			  {// code for IE7+, Firefox, Chrome, Opera, Safari
			  objEmpSno=new XMLHttpRequest();
			  }
			else
			  {// code for IE6, IE5
			  objEmpSno=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			  objEmpSno.onreadystatechange=function()
			  {
			  if (objEmpSno.readyState !=4){
				document.getElementById("msg").innerHTML = "<img src='../../images/loading/loading.gif' /> <span style='position:relative; top:-10px;'> Loading wait... </span>";
				}
			 else {
				 document.getElementById("empSnoNew").value = objEmpSno.responseText;
				 document.getElementById("msg").innerHTML = "";
				 }
			  }					
				// POST Method
				objEmpSno.open("POST","../ajaxPhp/getEmpSno.php",true);
				objEmpSno.setRequestHeader("Content-type","application/x-www-form-urlencoded");
				objEmpSno.send("courtNo="+courtNo.replace("&","|"));
				//alert(courtNo);
		}catch(e){
		alert(e.descriptions);
		}
	}   
/*function Print(tblId){
	try{
		$(document).ready(function(){
			$('#'+tblId).jqprint();
			$('#'+tblId).jqprint({ operaSupport: true });
			});
		}catch(e){
		alert(tblId);
		}
	}*/
function Print(node){
	try{
		  var content=document.getElementById(node).innerHTML;
		  var pwin=window.open('','print_content','width=10,height=10');
		  pwin.document.open();
		  pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
		  pwin.document.close();
		 
		  setTimeout(function(){pwin.close();},1000);
		}catch(e){
		alert(node);
		}
	}

//function to edit the field with table sno
/*function EDIT(fldId){
	try{
		//alert(fldId);
		var win = window.open('editToDoListPop.php?id='+fldId,win,'width=693,height=500,location=no,resizable=no,menubar=no,title=no,status=no');
		}catch(e){
		alert(e.description);
		}
	}*/
function EDIT(fldId){
	try{
		//alert(fldId);
		var options = {
        height: 500, // sets the height in pixels of the window.
        width: 693, // sets the width in pixels of the window.
        toolbar: 0, // determines whether a toolbar (includes the forward and back buttons) is displayed {1 (YES) or 0 (NO)}.
        scrollbars: 1, // determines whether scrollbars appear on the window {1 (YES) or 0 (NO)}.
        status: 0, // whether a status line appears at the bottom of the window {1 (YES) or 0 (NO)}.
        resizable: 0, // whether the window can be resized {1 (YES) or 0 (NO)}. Can also be overloaded using resizable.
        left: 0, // left position when the window appears.
        top: 0, // top position when the window appears.
        center: 0, // should we center the window? {1 (YES) or 0 (NO)}. overrides top and left
        createnew: 0, // should we create a new window for each occurance {1 (YES) or 0 (NO)}.
        location: 0, // determines whether the address bar is displayed {1 (YES) or 0 (NO)}.
        menubar: 0 // determines whether the menu bar is displayed {1 (YES) or 0 (NO)}.
    };

    var parameters = "location=" + options.location +
                     ",menubar=" + options.menubar +
                     ",height=" + options.height +
                     ",width=" + options.width +
                     ",toolbar=" + options.toolbar +
                     ",scrollbars=" + options.scrollbars +
                     ",status=" + options.status +
                     ",resizable=" + options.resizable +
                     ",left=" + options.left +
                     ",screenX=" + options.left +
                     ",top=" + options.top +
                     ",screenY=" + options.top;

    // target url
    var target = 'editToDoListPop.php?id='+fldId;  

    popup = window.open(target,'popup', parameters);
		//var win = window.open('editToDoListPop.php?id='+fldId,win,'width=693,height=500,location=no,resizable=no,menubar=no,title=no,status=no');
		}catch(e){
		alert(e.description);
		}
	}
