function Tooltip(marker, text, padding){
	this.marker_ = marker;
	this.text_ = text;
	this.padding_ = padding;
}
Tooltip.prototype.initialize = function(map){
	var div = document.createElement("div");
	div.appendChild(document.createTextNode(this.text_));
	div.className = 'tooltip';
	div.style.position = 'absolute';
	div.style.visibility = 'hidden';
	
	map.getPane(G_MAP_FLOAT_PANE).appendChild(div);
	this.map_ = map;
	this.div_ = div;

}
Tooltip.prototype.remove = function(){
	this.div_.parentNode.removeChild(this.div_);
}
Tooltip.prototype.copy = function(){
	return new Tooltip(this.marker_,this.text_,this.padding_);
}
Tooltip.prototype.redraw = function(force){
	if (!force) return;
	var markerPos = this.map_.fromLatLngToDivPixel(this.marker_.getPoint());
	var iconAnchor = this.marker_.getIcon().iconAnchor;
	var xPos = Math.round(markerPos.x+5);
	var yPos = markerPos.y;
	this.div_.style.top = yPos + 'px';
	this.div_.style.left = xPos + 'px';
}
Tooltip.prototype.show = function(){
	this.div_.style.visibility = 'visible';
	this.div_.style.opacity = 1;
}
Tooltip.prototype.popup = function(){
	this.info_.style.visibility = 'visible';
	this.info_.style.opacity = 1;
}
Tooltip.prototype.hide = function(){
	this.div_.style.visibility = 'hidden';
}
function pass(field,val){
if (field == 'p_city'){ 
document.getElementById('p_p').value = 1; 
}
document.getElementById('p_comp').value = val;

Next();
}
function isnum(elem) {
var str = elem.value;
var re = /^[-]?\d*\.?\d*$/;
str = str.toString();
if (!str.match(re)) { return false; }
return true;
}

function file (url) {
    var req = this.window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
    if (!req) {throw new Error('XMLHttpRequest not supported');}
    req.open("GET", url, false);
    req.send(null);
    return req.responseText.split('\n');
}
function str_replace (search, replace, subject, count) {
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}

function ifBound (polygon, latLng){
	var bounds = polygon.getBounds();
	if(bounds != null && !bounds.containsLatLng(latLng)) {
		return false;
	}
	var numPoints = polygon.getVertexCount();
	var inPoly = false;
	var i;
	var j = numPoints-1;
	for(var i=0; i < numPoints; i++) { 
		var vertex1 = polygon.getVertex(i);
		var vertex2 = polygon.getVertex(j);
		if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng())  {
			if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
				inPoly = !inPoly;
			}
		}
		j = i;
	}
	return inPoly;
};


