/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



//function getVal(param)
//{
//    var strURL="checkemailandpassword.php?emailid=venu.jakku@mcran.com&password=venujakku";
//    var req = createRequestObject();
//    req.open('GET', strURL, false); //third parameter is set to false here
//    req.send(null);
//
//    return req.responseText;
//}


var  HTTPResponceTEXT;
var AjaxReturncontent="";
var http ;//createRequestObject();
// if response type is XML output will get in the formate of XML.
var HTTPResponceXML;
// if responce type is TEXt you get the result in th normale formate.

var AjaxURLStatus=false;
var test=""
var DisplayID="";
var outputparam;
function createRequestObject() {
   
    // find the correct xmlHTTP, works with IE, FF and Opera
    var xmlhttp;
    try {
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e) {
        try {
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch(e) {
            xmlhttp=null;
        }
    }
    if(!xmlhttp&&typeof XMLHttpRequest!="undefined") {
        xmlhttp=new XMLHttpRequest();
    }
    return  xmlhttp;
}

function sendRequestT(ResType,url,OutPutDiv,outputparam) {

    sendRequest(ResType,url,OutPutDiv);
   
    
}
var display_loading=true;
function sendRequest_displayloading(ResType,url,OutPutDiv,display_loading_value) {
    display_loading=display_loading_value;
    sendRequest(ResType,url,OutPutDiv);
}
function sendRequest(ResType,url,OutPutDiv) {


   
    http =createRequestObject();

   


    DisplayID=OutPutDiv;
    try{

        if(display_loading)
        {
            document.getElementById(DisplayID).innerHTML="Content loading.. "+
			
        "<br/><img src='../images/loading.gif' alt='loading...'/><br/>Please wait";

           

        }
        else
        {
            document.getElementById(DisplayID).innerHTML="Loading details ";
        }
    }catch(e){
        
    }
    // document.getElementById(DisplayID).innerHTML='loading...';
     
    ResType=ResType.toLowerCase();
   
    HTTPResponceXML="";
    HTTPResponceTEXT="";

    //To acceess fress page on every request
    var rnd = Math.random();
    

    url+="&count="+rnd;
    // url="creditinformationByMemberIndustryId.php?MID=TFP3689514&IID=MI_1&EditOptions=false&count=0.6817256404555232";
    //alert(url)
        
    try{
        


        

        if(ResType=="text")
        {
           //alert(url);
            http.open('GET', url, false); //third parameter is set to false here
            http.send(null);
              
            
            HTTPResponceTEXT=http.responseText;
            try{
                if(DisplayID!="")
                {

                    
                    document.getElementById(DisplayID).innerHTML=HTTPResponceTEXT;

                    AjaxReturncontent=document.getElementById(DisplayID).innerHTML;


                   


                }
            }catch(e)
            {

            }
            return HTTPResponceTEXT;
            //http.onreadystatechange = handleResponseTEXT;
           
            try{
                msg (DisplayID, "error",AjaxReturncontent);
            }catch(e){}
          
        }
        if(ResType=="xml")
        {
            
            http.setRequestHeader('content-type',  "text/xml");
            http.onreadystatechange = handleResponseXML;
             
        }
        http.send(null);
    }
    catch(e){
         
        
    //alert('Request send failed.'+e);
    }
     
    return HTTPResponceTEXT;
 
 
}
//---------------------------------****************************************-----------------------------

function handleResponseTEXT() {

    try{

        if (http.readyState==4 || http.readyState=="complete")
        {


            AjaxURLStatus=true;

            //************** ******************** YOUr Data will come here..........
            // alert(http.responseText );
            HTTPResponceTEXT=http.responseText ;
            //Write all the final process in this method(outside)
            //ReadRetunValues(HTTPResponceTEXT)
            try{
                if(DisplayID!="")
                {
                    //  alert(HTTPResponceTEXT);
                    document.getElementById(DisplayID).innerHTML=HTTPResponceTEXT;
                    //  alert( document.getElementById(DisplayID).innerHTML)
                    AjaxReturncontent=document.getElementById(DisplayID).innerHTML;
                
                    //   alert(AjaxReturncontent);
                    document.getElementById("dispayCatcount_search").innerHTML="";
                //  return AjaxReturncontent;
  
                }
            }catch(e)
            {
                 
            }
			 
        // FinalProcess(HTTPResponceTEXT);
        //************** ******************** YOUr Data END here..........








        }
        else
        {
            AjaxURLStatus=false;
        }
    }
    catch(e){
    //alert(e)
    // caught an error
    //alert('Response failed.');
    }
//alert(HTTPResponceTEXT);
//return HTTPResponceTEXT;
  
}
//---------------------------------****************************************-----------------------------

function handleResponseXML() {
   
    try{
        
        if((http.readyState == 4)&&(http.status == 200))
        {

            if(http.responseXML != null)
            // success!
            {



 

                //************** ******************** YOUr Data will come here..........
                HTTPResponceXML=http.responseXML;
                FinalProcess(HTTPResponceXML);
            //var result = http.responseXML.getElementsByTagName('FRUIT')[0].firstChild.nodeValue;
            //  alert(result);
            //************** ******************** YOUr Data end here..........





            }
            else{
                alert("Responce is in Invalid XML Formate or  Responce XML is NULL");
            }


      
        }
    }
    catch(e){
    //  alert(e)
    // caught an error
    //alert('Response failed.');
    }
     
}

