var tipses_exists = new Array();
var tipses = new Array();
function getTips(customfield_label, owner){
	if (t_type == undefined ) {
	    t_type = 'tips';
	}
	if (catid == undefined ) {
	    catid = 0;
	}
	var i = findInArray(tipses_exists, customfield_label);
	if ( i === false ){
	    Ext.Ajax.request({
		    url: '/ajax/tips.php',
		    success: function(response, opts) {
			    var obj = Ext.decode(response.responseText);
			    if(obj.success) {
				showTips(obj.data[customfield_label], owner);
				for (var j in obj.data){
				    tipses.push(obj.data[j]);
				    tipses_exists.push(j);
				}
			    }
		    },
		    params: {'label':customfield_label,'adtype':adtype, 'tips_type':t_type, 'cat_id': catid}
	    });
	   
	} else {
	    showTips(tipses[i], owner);
	}
}
function hideTips(owner){
	Ext.get("tips_help").setStyle({display : 'none'});
	return false;
}
function showTips(data, owner){
	var el_content = Ext.fly('_content').remove();
	Ext.get('tips_content').createChild({tag: 'div', id: '_content', html: data });
	Ext.get('div_tips').setXY(Ext.get(owner).getXY());
	Ext.get("tips_help").setStyle({display : 'block'});
	return false;
}
function findInArray(ar, val){
    for (var i = 0; i < ar.length; i++){
	if (ar[i] == val ) return i;
    }
    return false;
}
