//Seçili olan satırı belirlemek için hazırlanmıştır.
var i_step = 0, a_stepCount = new Array (), maxStep = 3;
var a_stepError = new Array ();
a_stepError [0] = new Array ();
a_stepError [1] = new Array ();
a_stepError [2] = new Array ();
var temps = new Array();
function f_selOwner (t_tableID, t_element) {
	var t_table = getElement (t_tableID);
	if (!t_table) return ;
	var a_tds = t_table.getElementsByTagName ("td");
	for (var i=0; i<a_tds.length; a_tds[i].className =  a_tds[i].className.replace("selected", ""), i++);
	if (!t_element) return ;
	if (!t_element.offset) {
		var t_offset = t_element.offsetParent;
		while ( t_offset && t_offset.nodeName.toLowerCase() != "td")
			t_offset = t_offset.offsetParent;
		t_element.offset = t_offset;
	}
	t_element.offset.className += " selected";
	if (!t_element.hints) {
		t_element.hints = new Array ();
		var t_hints = t_offset.getElementsByTagName("span");
		for (var i=0; i<t_hints.length; i++)
			if (t_hints[i].className.indexOf ('hint')>=0)
				t_element.hints[t_element.hints.length] = t_hints[i];
	}
	for (var i=0; i<t_element.hints.length; f_display(t_element.hints[i], "none"), i++);
}
//İlgili componenet hakkındaki yazıyı göstermek için hazırlanmıştır.
function f_showHint (t_obj, t_index) {
	try {
		f_display(t_obj.hints[t_index?t_index:0], "block");
	}catch (e) { }
}
//İlgili componenet hakkındaki yazıyı gizlemek için hazırlanmıştır.
function f_hideHint (t_obj, t_index) {
	try {
		if (isNType(t_index, "number"))
			for (var i in t_obj.hints)
				f_display(t_obj.hints[i], "none" );
		else f_display(t_obj.hints[0], "none");
	} catch (e) {
	}
}
var f_control = function () {
	// Zorunlu alan kontrolü
	this.hint = 1;
	if (this.style.display == "none") return true;
	if (this.isClass('combo')) {
		if (this.isClass('zor')) return (parseInt(f_trim(this.value))>0);
		return true;
	}
	if (this.isClass('zor')) if (!isFull(this)) return false;
	if (isFull(this)) {
		this.hint = 2;
		if ( this.isClass('mail') ) return isMail (f_trimO(this)); // mail ise kontrolü
		if ( this.isClass('number') ) return isNumber (f_trimO(this)); // sayı kontrolü
		if ( this.isClass('tel') ) return isTel (f_trimO(this)); // tel kontrolü
		if ( this.isClass('pass') && !this.isClass('pass2')) {temps["pass"] = this.id; return true;}// Şifre kontrol
		if ( this.isClass('pass2')) return (getValue(temps["pass"])==this.value);
	}
	return true;
}
var f_isClass = function (cls) {
	return (this.className.indexOf(cls)>=0);
};
//Seçili işlemini gerçekleştirmek için gerekli fonksiyon değişkeni
var f_gotFocus = function () {
	f_selOwner ('step'+ (i_step+1), this );
	f_showHint( this );
};
//Seçili işlemini kapamak için gerekli fonksiyon değişkeni
var f_lostFocus = function () {
	f_selOwner ('step'+ (i_step+1));
	f_hideHint( this );
	var t_error = false;
	// Boş yazı alanı kontrolü
	if (!this.control()) t_error = true;
	if (t_error) f_showHint(this, this.hint);
	if (isNaN(parseInt(this.index)))
		this.index = a_stepError [i_step].length;
	a_stepError [i_step][this.index]=t_error;
};
//Seçili değer bulma fonksiyonlarını atamak için hazırlanmıştır
function f_setObjectFocus(container, tag) {
	container = getElement (container);
	if (!container) return;
	var objects = container.getElementsByTagName (tag);
	for (var i=0; i<objects.length;
		 objects[i].onfocus = f_gotFocus,
		 objects[i].onblur = f_lostFocus,
		 objects[i].isClass = f_isClass,
		 objects[i].control = f_control,
		 i++);
}
//Form nesnelerinin focus işlemlerini ayarlamak için hazırlanmıştır.
function f_setFormFocus() {
  for ( var s = 0 ; s<maxStep; s ++){
	f_setObjectFocus("step" + (s+1), "input");
	f_setObjectFocus("step" + (s+1), "textarea");
	f_setObjectFocus("step" + (s+1), "select");
	var t_table = getElement ("step"+(s+1));
	var a_trs = t_table.getElementsByTagName ("tr");
	for (var i=0; i<a_trs.length; i++) {
		if (a_trs[i].className.indexOf ("param")>=0)
			if (isNaN(parseInt(a_stepCount[s])))
				a_stepCount [s]=0;
		a_stepCount [s]++;
	}
  }
}
//Form kontrol işlemleri için hazırlanmıştır.
var e_error = false; //Form kontrolünde hata olup olmadığının kontrolü için
var o_firstElement ; //Form kontrolünde hata durumunda konumlanacağı ilk eleman
function f_lenControl (t_objectId) {//Uzunluk kontrolü için
	return (f_trimO(t_objectId).length >= 3);
}
function f_focusControl (t_tableId, t_tagName) {
	var t_table = getElement (t_tableId);
	if (!t_table) return;
	var t_objectArray = t_table.getElementsByTagName (t_tagName);
	for (var i=0; i<t_objectArray.length; i++)
		try {
			var e_error = false;
			var t_obj = t_objectArray[i];
			if (!t_obj.control()) e_error = true;
			if (e_error && t_obj.isClass('combo')) if (parseInt(f_trim(t_obj.value))>0) e_error = false;
			if (e_error) {
				try {t_obj.focus();} catch(e){try {t_obj.onfocus();} catch(e){}}
				f_showHint(t_obj, t_obj.hint);
				return false;
			}
		} catch (e) { return false; }
	return true;
}
function f_focusStepControl(t_step) {
	return ( f_focusControl("step" + t_step, "input") && 
	f_focusControl("step" + t_step, "textarea") &&
	f_focusControl("step" + t_step, "select") );
}
function uyelikKontrol (t_prefix) {
	try {
		t_prefix = t_prefix?t_prefix + '_':"";
		return f_stepControl();
	}catch (e) {
		return ShowError (e.description);
	}
}
//Adımlar arası kontrol geçişi için hazırlanmıştır.
function f_stepControl (){
//	e_error = false;
	return f_focusStepControl(i_step+1);
//	return !e_error;//true;
}
//Bir sonraki adıma geçmek için hazırlanmıştır.
function f_nextStep () {
	if (!f_stepControl()) return false;
	i_step++;
	for (var i=0; i<maxStep; f_display ("divStep" + (i+1), i==i_step?"block":"none"), i++);
	var t_tds = getElement("step_table").getElementsByTagName("td");
	var i_nav = 1;
	for (i=i_step-1;i_nav>=0 && i>=0; t_tds[i].className = ("t" + i_nav),i--, i_nav--);
	t_tds[i_step].className= (i_step==2?"tcempty":"tc");
}
//Bir önceki adıma geçmek için hazırlanmıştır
function f_prevStep () {
/*	if (!f_stepControl()) return false;*/
	i_step--;
	for (var i=0; i<maxStep; f_display( "divStep" + (i+1), i==i_step?"block":"none"),i++);
	var t_tds = getElement("step_table").getElementsByTagName("td");
//	for (i=0;i_nav>=0 && i>=0; t_tds[i].className = ("t" + i_nav),i--, i_nav--);
	t_tds [i_step+1].className = ((i_step+1) == 2)?"empty":"";
	var i_nav = 1;
	for (i=i_step-1;i_nav>=0 && i>=0; t_tds[i].className = ("t" + i_nav),i--, i_nav--);
	t_tds[i_step].className= "tc";
}
function f_formControl () {
	for (var i=0; i<maxStep; i++) if (!f_focusStepControl(i+1)) return false;
	return true;
}
