// JavaScript Document
//

// 
function ajaxObject(url,layer,msg) {                                    // This is the object constructor
 			var msg=msg || '<img src=images/indicator.gif border=0 align=left>لطفا صبر کنيد...';
 			var obj = document.getElementById( layer);
 			//obj.innerHTML='<p align=center class=label dir=rtl>'+msg+''+'</p>';
 			obj.innerHTML=msg;

   var that=this;                                                    // A workaround for some javascript idiosyncrocies
   var updating = false;                                             // Set to true if this object is already working on a request
   this.callback = function() {}                                     // A post-processing call -- a stub you overwrite.

   this.update = function(passData) {                                // Initiates the server call.
      if (updating==true) { return false; }                          // Abort if we're already processing a call.
      updating=true;                                                 // Set the updating flag.
      var AJAX = null;                                               // Initialize the AJAX variable.
      if (window.XMLHttpRequest) {                                   // Are we working with mozilla?
         AJAX=new XMLHttpRequest();                                  //  Yes -- this is mozilla.
      } else {                                                       // Not Mozilla, must be IE
         AJAX=new ActiveXObject("Microsoft.XMLHTTP");                //  Wheee, ActiveX, how do we format c: again?
      }                                                              // End setup Ajax.
      if (AJAX==null) {                                              // If we couldn't initialize Ajax...
         alert("Your browser doesn't support AJAX.");                // Sorry msg.						
         return false                                                // Return false (WARNING - SAME AS ALREADY PROCESSING!)
      } else {
         AJAX.onreadystatechange = function() {                      // When the browser has the request info..
            if (AJAX.readyState==4 || AJAX.readyState=="complete") { //   see if the complete flag is set.
               LayerID.innerHTML=AJAX.responseText;                  //   It is, so put the new data in the object's layer
               delete AJAX;                                          //   delete the AJAX object since it's done.
               updating=false;                                       //   Set the updating flag to false so we can do a new request
               that.callback();                                      //   Call the post-processing function.
            }                                                        // End Ajax readystate check.
         }                                                           // End create post-process fucntion block.
         var timestamp = new Date();                                 // Get a new date (this will make the url unique)
         var uri=urlCall+'?'+passData+'&amp;timestamp='+(timestamp*1);   // Append date to url (so the browser doesn't cache the call)
         AJAX.open("GET", uri, true);                                // Open the url this object was set-up with.
         AJAX.send(null);                                            // Send the request.
         return true;                                                // Everything went a-ok.
      }                                                              // End Ajax setup aok if/else block                 
  }
      
   // This area set up on constructor calls.
   var LayerID = document.getElementById(layer);                     // Remember the layer associated with this object.
   var urlCall = url;                                                // Remember the url associated with this object.
} 
     

//

function getData( dataSource, divID,msg,js) 
 { 
 var XMLHttpRequestObject = false;
 if (window.XMLHttpRequest) 
 	{ XMLHttpRequestObject = new XMLHttpRequest();} 
 else if ( window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");} 
 	if( XMLHttpRequestObject) 
 		{ 
 			var js=js || 'notjs';
 			var msg=msg || 'لطفا صبر کنيد';
 			var obj = document.getElementById( divID);
 			//obj.innerHTML='<p align=center class=label dir=rtl><img src=images/indicator.gif border=0 align=left>'+msg+'...'+'</p>';
 			obj.innerHTML=msg+'...';
 			XMLHttpRequestObject.open("GET", dataSource);
 			XMLHttpRequestObject.onreadystatechange = function() 
 		{ 
 			if ( XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) 
 						{
 							if (js=='notjs')
 								obj.innerHTML = XMLHttpRequestObject.responseText;
 							else if (js=='js')	
 								obj.innerHTML = eval(XMLHttpRequestObject.responseText);
 						} 
 		} 
		 XMLHttpRequestObject.send(null);
 		} 
}
//
function checkEmail (mail){
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(mail)) {
alert('پست الکترونيک وارد شده معتبر نمي باشد');
mail.focus;
return false;
}
return true;
}
