Avoid that line index is already passed through callback function ,
var exists = false;
$(".ui-tabs-anchor").each(function(index){
if ($(this).text() == "stock"){
exists = true;
$("#tabs").tabs({active: index});
}
});
If you want the index of the current item then use $(".ui-tabs-anchor").index(this)