/****************************************************************************************************/
/****************************************************************************************************/
function getClassName(obj) {
if (typeof obj != "object" || obj === null) return false;
return /(\w+)\(/.exec(obj.constructor.toString())[1];
}

function zincir (oBlok , strIleti, strPHP, strParametre, strDigerParametreler, strFormAdi, strNesneAdi, oSonraki) {
	this.oAjax = null;
	this.oBlok = oBlok; // javascript assignment pass by reference
	this.strIleti = strIleti;
	this.strPHP = strPHP;
	this.strParametre = strParametre;
	this.strDigerParametreler = strDigerParametreler;
	this.strFormAdi = strFormAdi;
	this.strNesneAdi = strNesneAdi;
	this.oSonraki = oSonraki;
	this.zincir = null;
	
	/****************************************************************************************************/	
	
	this.goster = function () {
		// alert (getClassName (this) + '.goster');
		this.zincir.oBlok.innerHTML = this.zincir.oAjax.response;
		
		// alert (this.zincir.strFormAdi + ' ' + this.zincir.strNesneAdi);
		// alert (this.zincir.oSonraki);
		if (this.zincir.oSonraki != null && this.zincir.strFormAdi != null && this.zincir.strNesneAdi != null) {		
			// alert (this.zincir.strFormAdi);
			var oForm = document.getElementById (this.zincir.strFormAdi);
			if (oForm == null) {
				alert ('Form yok!!!');
				return -1;
			}
			// alert ('Liste getirildi.');
	
			var oNesne = document.getElementById(this.zincir.strNesneAdi);
			if (oNesne != null) {
				oNesne.onchange = this.zincir.oSonraki.getir;
				oNesne.zincir = this.zincir.oSonraki; 
			}
		} // if
	} // goster ()
	
	/****************************************************************************************************/
	
	this.iletBekleniyor = function () {
		// alert (getClassName (this) + '.iletBekleniyor');
		// alert (this.zincir.strIleti + ' 1');
		this.zincir.oBlok.innerHTML = this.zincir.strIleti;
		// alert (this.zincir.oBlok.innerHTML + ' 2');
	}

	/****************************************************************************************************/
	
	this.getAjax = function (strDosyaAdi) {
		// alert (getClassName (this) + '.getAjax');
		// alert (strDosyaAdi);
		this.oAjax.zincir = this;
		this.oAjax.requestFile = strDosyaAdi;	// Specifying which file to get
		this.oAjax.onCompletion = this.goster;	// Specify function that will be executed after file has been found
		this.oAjax.onLoading = this.iletBekleniyor;	// Action when AJAX is loading the file
		this.oAjax.runAJAX();		// Execute AJAX function	
	}
	
	/****************************************************************************************************/
	
	this.getir = function () {
		// alert (this);
		// alert ('Seçilen: ' + this.value);
		if (this.zincir != null) {
			// alert (getClassName (this.zincir) + '.getir');
			this.zincir.oAjax = new sack ();
			// alert (this.zincir.strPHP + '?' + this.zincir.strParametre + '=' + escape(this.value) + this.zincir.strDigerParametreler);
			this.zincir.getAjax (this.zincir.strPHP + '?' + this.zincir.strParametre + '=' + encodeURI(this.value) + this.zincir.strDigerParametreler);
		} else {
			alert ('yeni burada');
		}
	}
	
	/****************************************************************************************************/
	
} // class tanımlama sonu

/****************************************************************************************************/
/****************************************************************************************************/

