The htmlinfowindowclick
function should be outside of the initialize
function. Also var gmarkers = [];
should be defined outside your functions so that it can be accessed by both functions.
var gmarkers = [];
function htmlinfowindowclick(item) {
google.maps.event.trigger(gmarkers[item], 'click');
}
function initialize() {
[...]
}