//اللهم لا علم لنا الا ما علمتنا
//  Advanced  Javascript
//		PHP0@hotmail.com And Almhajer@hotmail.com
//   Class  BK  Javascript
//
//


//
//var Loading_Images = new Image();
//Loading_Images.src = "http://localhost/WWW/Msyar/Icons/loading.gif";

var Msg_Loading= new Image(); 
 Msg_Loading.src="Icons/loading.gif";

BK.Ajax ={

	////#------------> action
	On_Loading :null,
	On_Loaded : null,
	On_Interactive :null,
	On_Completion : null,
	On_Error : null,
	On_Fail : null,
	Get_Value:null,






	Updates: function(Urls, ID_Elements) {

		BK.Ajax.ID_Element=ID_Elements;

		var httpRequest;

		if (window.XMLHttpRequest) { // Mozilla, Safari, ...
			httpRequest = new XMLHttpRequest();
			if (httpRequest.overrideMimeType) {
				httpRequest.overrideMimeType('text/xml');
				// See note below about this line
			}
		}
		else if (window.ActiveXObject) { // IE
			try {
				httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (e) {
				try {
					httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {}
			}
		}

		if (!httpRequest) {
			alert('Giving up :( Cannot create an XMLHTTP instance');
			return false;
		}





		httpRequest.onreadystatechange = function() {

			if (httpRequest.readyState == 1) {

				BK.Elements.Get(ID_Elements).innerHTML ='loading....'+'<img src="'+Msg_Loading.src+'" alt="" />';

				if (typeof  BK.Ajax.On_Loading == 'function') {
					BK.Ajax.On_Loading();

				}


			}



			if (httpRequest.readyState == 2) {
				if (typeof  BK.Ajax.On_Loaded == 'function') {
					BK.Ajax.On_Loaded();
				}

			}

			if (httpRequest.readyState == 3) {
				if (typeof  BK.Ajax.On_Interactive == 'function') {

					BK.Ajax.On_Interactive();
				}
			}


			if (httpRequest.readyState == 4) {


				if (httpRequest.status == 200) {

					BK.Elements.Get(ID_Elements).innerHTML = httpRequest.responseText;


					if (typeof  BK.Ajax.On_Completion == 'function') {
						BK.Ajax.On_Completion();
					}

					//#------>  BK.Ajax.Get_Value=function(e){alert(e);}

					if (typeof  BK.Ajax.Get_Value == 'function') {
						BK.Ajax.Get_Value(httpRequest.responseText);

					}




				}
				else {

					if (typeof  BK.Ajax.On_Error == 'function') {
						BK.Ajax.On_Error();
					}


				}


			}

		}
		httpRequest.open('GET', Urls, true);
		httpRequest.send('');

	}





};
















