
function getHTTPObject() {
  var xmlhttp;
 
  if(window.XMLHttpRequest){
    xmlhttp = new XMLHttpRequest();
  }
  else if (window.ActiveXObject){
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    if (!xmlhttp){
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    
}
  return xmlhttp;

  
}
var http = getHTTPObject(); // We create the HTTP Object

/*
	Funtion Name=requestInfo 
	Param = url >> Url to call : id = Passing div id for multiple use ~ as a seprator for eg. div1~div2 :
	redirectPage >> if you like to redirect to other page once the event success then 
	the response text = 1 and the redirectPage not left empty
*/

    function requestInfo(url,id,redirectPage) { 
		var temp=new Array();
			http.open("GET", url, true);
			http.onreadystatechange = function() {
				if (http.readyState == 4) {
				  if(http.status==200) {
			  		var results=http.responseText;

					if(redirectPage=="" || results!="1") {
					
						
							document.getElementById(id).innerHTML = results;
							if(image_limit>0){
							
								for(i=0; i<document.case_add_edit.elements.length; i++)
								{
									if(document.case_add_edit.elements[i].type=="file")
									{
									document.case_add_edit.elements[i].disabled=false;
									}
								}
						
								}
							
						
					} else {
						//alert(results);
						window.location.href=redirectPage;			
					}
				  } 
  				}
			};
			http.send(null);
       }


function init_table(case_id) {
requestInfo('showTable.php?mode=list&case_id='+case_id,'showTable','');
	}
	
	function save_data() {
			var id=document.getElementById("id").value;
			var username=document.getElementById("username").value;
			var password=document.getElementById("password").value;
			var checkValidation=emptyValidation('id~username~password');
	
		if(checkValidation==true) {
			requestInfo('showTable.php?mode=save_new&id='+id+'&username='+username+'&password='+password,'showTable','');
		} 
	}
	

	
function confirmLink(theLink)
{
   
    var is_confirmed = confirm('Are you sure to delete this record?\n\nThis will permanently delete the Record!');
    if (is_confirmed) {
        theLink.href += '';
		image_limit++;
		//alert(image_limit);
    }

    return is_confirmed;
}


