
/**
*   getPoint function for polyline
**/
GPolyline.prototype.getPoint = function(){
    return new GLatLng(parseFloat(this._GeoInfo['lat']), parseFloat(this._GeoInfo['lng']));
}
    
/**
*   Open InfoWindows for Polyline
**/    
GPolyline.prototype.openInfoWindowHtml = function(content){
    var oRef = this;    
    oGeoStart.oMap.openInfoWindowHtml(this.getPoint(), content, {onOpenFn:this.setUpListeners(this)});
}

GPolyline.prototype.setUpListeners = function(oRef){

    var closeEvent = GEvent.addListener(oGeoStart.oMap, 'infowindowclose', function(){
        GEvent.trigger(oRef, 'infowindowclose');
    });
    
    this.handleInfoWindowClose();
    
}

GPolyline.prototype.handleInfoWindowClose = function() { 
    var oRef = this;
    GEvent.addListener(oRef, 'infowindowclose', function(){
        try { closeEvent.remove(); } catch(e){}
        try { GEvent.removeListener(closeEvent);  } catch(e){}
    });
    GEvent.trigger(oRef, 'infowindowopen');
}

/**
*   @desc Check if polygon contains point.
*           Hopefully works for polyline... *pray*
*   @return boolean
**/    
GPolyline.prototype.Contains = function(point) {
    var j=0;
    var oddNodes = false;
    var x = point.lng();
    var y = point.lat();
    for (var i=0; i < this.getVertexCount(); i++) {
      j++;
      if (j == this.getVertexCount()) {j = 0;}
      if (((this.getVertex(i).lat() < y) && (this.getVertex(j).lat() >= y))
      || ((this.getVertex(j).lat() < y) && (this.getVertex(i).lat() >= y))) {
        if ( this.getVertex(i).lng() + (y - this.getVertex(i).lat())
        /  (this.getVertex(j).lat()-this.getVertex(i).lat())
        *  (this.getVertex(j).lng() - this.getVertex(i).lng())<x ) {
          oddNodes = !oddNodes
        }
      }
    }
    return oddNodes;
}