


    var http_request = false;
    var timeOut = 5;
    var tagId;
    var method;
    var fname;
    var part;
    var target;
    var vId;
    
    function ajaxSetRequest( method, fname, part, target, id, vId ) {

      if (  !method | !fname | !part | !target | !id | !vId | !chkString( document.getElementById( part ).value )  ) return false;

                this.method = method;
                this.fname = fname
                this.part = part;
                this.target = target;
                this.tagId = id;
                this.vId = vId;

               switch ( this.part )
                 {

                case "email": showHide('e_list'); showHide('e_actions'); break;
                case "emailactive": showHide('active_button_1'); showHide('active_status_1'); break;
                case "emailactivecode": showHide('active_button_2'); showHide('active_status_2'); break;
                case "mobileactive": showHide('active_button_3'); showHide('active_status_3'); break;
                case "mobileactivecode": showHide('active_button_4'); showHide('active_status_4'); break;
                
                 }
                 
               document.getElementById( this.target ).innerHTML = "<img src='./templates/images/loading_"+this.tagId+".gif'>";

               setTimeout(" ajaxDoRequest() ", 1000 * this.timeOut );
               
               return true;
        }

       function ajaxDoRequest() {


                  if (window.XMLHttpRequest) {   http_request = new XMLHttpRequest();     }
                   else if (window.ActiveXObject) {    http_request = new ActiveXObject("Microsoft.XMLHTTP");     }

                    http_request.onreadystatechange = function() { ajaxDone(); }
                    http_request.open( this.method , encodeURI( this.fname + "?" + this.part +"="+document.getElementById( this.part ).value+"&vid="+this.vId ) , false );
                    http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                    http_request.setRequestHeader("Connection", "close");
                    http_request.send(  null );

                                         }

                          function ajaxDone() {

                      if (http_request.readyState == 4) {

                   if (http_request.status == 200) {

                    switch ( this.fname )
                            {
                               case "maillist.php": document.getElementById( this.target ).innerHTML = http_request.responseText; break;
                               case "registercheck.php":

                                        switch ( http_request.responseText )
                                                {

                                                    case "emailsended": chkActiveStatus( this.target , 'sendemailcode' , 'emailactivecode' , false , 1 , 2 , 0 );  break;
                                                    case "emailcodechecked": chkActiveStatus( this.target , 'mobilecodeorder' , 'emailactivecode' , true , 2 , 3 , 1 );  break;
                                                    case "mobilesended": chkActiveStatus( this.target , 'mobilecodesend' , 'mobileactivecode' , false , 3 , 4 , 2 );  break;
                                                    case "mobilecodechecked": chkActiveStatus( this.target , 'go2nextframe' , 'mobileactivecode' , true , 4 , 4 , 3 );  break;
                                                    default: document.getElementById( this.target ).innerHTML = "<img src='./templates/images/no.gif'>"; document.getElementById( 'activeinfo' ).innerHTML  = http_request.responseText; break;

                                                }
                         }
                            }
                         else {
                                    document.getElementById( this.target ).innerHTML = ajaxError( http_request.status ) ;
                                    return false;
                              }

                              }
                            }

                    function ajaxError ( status ) {

                    var err;
                    cid = Array("o","w","g");

                    switch ( status ) {

                            case 404:

                                err = "<td class='ar"+cid[this.tagId]+"'>خطأ : <b>"+status+"</b><br />لم يتم العثور على الصفحة ! فضلا إتصل بالدعم الفني.";
                                        }
                                        
                            return "<table><tr>"+err+"</td></tr></table>";
                            
                                }

