﻿// JScript File
var Use = {

         changeImage: function(val)
         {                   
               var data="id="+val;                
               Use.SendDataToServer("khung1","ServiceDetail.aspx","POST",data);
                  // ("test","Server.aspx","POST","test=100")
         },
         changeImage2: function(val)
         {                   
               var data="id="+val;                
               Use.SendDataToServer("khung1","WDetail.aspx","POST",data);
                  // ("test","Server.aspx","POST","test=100")
         },
   changeImage1: function(val)
         {    
               var data="id="+val;
               Use.SendDataToServer("khung1","SolutionDetail.aspx","POST",data);
               //Session["lll"]="d";
                  // ("test","Server.aspx","POST","test=100")
         },
        Khoitao : function()
        {
            if(window.XMLHttpRequest){
                xmlhttp = new XMLHttpRequest();        
            }else{
                try{
                    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
                }catch(e){
                    try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                    }catch(e){
                        xmlhttp = false;
                    }
                }
            }
            return xmlhttp;
         },
    //=========================================================================
    // Ajax :: Method 1, Send Data to Server   ("dv_Dsisplay","Server.aspx","POST",sQry)
    //=========================================================================    
    SendDataToServer : function (sCtrID,sUrl,sMethod,sQry)
    {
                clientCtr = sCtrID;
                xmlhttp = Use.Khoitao();
                if(xmlhttp){
                    xmlhttp.open(sMethod,sUrl,true);
                    xmlhttp.onreadystatechange = Use.ProcessAjax;
                    xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
                    xmlhttp.send(sQry);            
                }
                else
                {
                    alert('Browser do not support Ajax!');
                }
            
     } ,
     
     //=========================================================================
    // Ajax :: Process
    //=========================================================================
    ProcessAjax : function ()
            {   
          //Use.OnPleaseWait(clientCtr);
                if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
                {
                                
                    var sReply = xmlhttp.responseText;
                    var theDvContent = Use.findControlByID(clientCtr);
                    try
                    {
                        theDvContent.innerHTML = sReply;
                        
                    }
                    catch(ex)
                    {
                        theDvContent.innerHTML = ex.message;
                    }
                }        
            },            
      //=========================================================================
    // Ajax :: On Please wait 
    //=========================================================================
    OnPleaseWait : function(clientCtr){    
                var ctr = Use.findControlByID(clientCtr);                
                // Loading
                ctr.innerHTML = "Loading...";
                
                //var loading = new AdminLoading();
                //ctr.innerHTML = loading.innerHTML;
            },
                  
    //================================================================
    // Find Div
    //================================================================
    findControlByID: function(sID)
                {
                    
                    if(window.document.all){
                        theDv = window.document.all[sID];
                    }else if(document.layers){
                        theDv = document.layers[sID];
                    }else if(document.getElementById){
                        theDv = document.getElementById(sID);        
                    }else{
                        alert('Browser do not support Div');
                    }
                  
                    return theDv;
                } 
     //================================================================
    // SendImageDataToServer
    //================================================================         
   
    
  }