
if (!Array.indexOf) {
    Array.prototype.indexOf = function(obj){
        for (var i = 0; i < this.length; i++) {
            if (this[i] == obj) {
                return i;
            }
        }
        return -1;
    }
}

function TF3StartErrorHighlight(id)
{
	$('#'+id).addClass('tf3_eh');
	if(TF3_eh_blink.indexOf(id) > -1)
		window['TF3_eh_timeout_'+id] = setTimeout('TF3StopErrorHighlight("'+id+'")',1000);
	return true;
}

function TF3StopErrorHighlight(id,bStop)
{
	$('#'+id).removeClass('tf3_eh');
	
	if(bStop)
	{
		if(typeof(window['TF3_eh_timeout_'+id]) != 'undefined')
			clearTimeout(window['TF3_eh_timeout_'+id]);
		return true;
	}
	
	if(TF3_eh_blink.indexOf(id) > -1)
		window['TF3_eh_timeout_'+id] = setTimeout('TF3StartErrorHighlight("'+id+'")',1000);
	return true;
}


function TF3HandleEnter(el,ev)
{
	if ((ev.keyCode ? ev.keyCode : ev.which ? ev.which : ev.charCode) == 13)
	{
		$(el).moveNext();	
		return false;
	}
	else
		return true;
}

function TF3AjaxKontrola(el,jm)
{
	var id = $(el).attr('id');
	var ido = 'aidd_al_' + id;
	var nam = $(el.form).attr('name');

	
	$('body').append('<div class="ui-widget-overlay" id="'+ido+'"><div class="tf3loader">&nbsp;</div></div>');
	$('#'+ido).height($('#'+id).outerHeight()).width($('#'+id).outerWidth()).css($('#'+id).offset()).css('opacity','0.7').css('filter','Alpha(Opacity=70)');
	//$('#aidd_chyba_'+id).html('<div class="tf3loader">&nbsp;</div>');
	
	data = {}
	data[$('#'+id).attr('name')] = $('#'+id).val();
	
	ajaxurl = eval('Form' + nam + 'AjaxURL');
	ajaxurl += ajaxurl.indexOf('?') > 0 ? '&' : '?';
	
	$.ajax({
		url:  ajaxurl + 'jmeno=' + nam,
		type: "post",
		dataType: 'json',
		data: data,
		success: function(val){
			if(val==0){}
			else{
				
				if (val.hlaska == '') {
					$('#aidd_chyba_' + id).fadeOut(700, function(){
						$('#aidd_chyba_' + id).html('').show();
					});

					//if(TF3_eh_ajax.indexOf(id) > -1)
						TF3StopErrorHighlight(id, 1);
				}
				else {
					$('#aidd_chyba_' + id).html(val.hlaska);
					
					if(typeof(TF3_eh_ajax) != 'undefined')
						if(TF3_eh_ajax.indexOf(id) > -1)
							TF3StartErrorHighlight(id);
				}
			}
		},
		complete: function(){
			$('#'+ido).remove();
			$('#aidd_chyba_'+id+' .tf3loader').remove();
		},
		error: function(){
			$('#'+ido).remove();
		}
	});
}

function TF3ShowHint(txt,el,ev,w)
{
	
}

function TF3mceToggle(ee)
{
	
}

