if (!Array.prototype.indexOf)
{
  Array.prototype.indexOf = function(elt /*, from*/)
  {
    var len = this.length >>> 0;

    var from = Number(arguments[1]) || 0;
    from = (from < 0)
         ? Math.ceil(from)
         : Math.floor(from);
    if (from < 0)
      from += len;

    for (; from < len; from++)
    {
      if (from in this &&
          this[from] === elt)
        return from;
    }
    return -1;
  };
}

extend = function(destination, source) {
    destination = destination || {};
    if(source) {
        for(var property in source) {
            var value = source[property];
            if(value !== undefined) {
                destination[property] = value;
            }
        }

        var sourceIsEvt = typeof window.Event == "function"
                          && source instanceof window.Event;

        if(!sourceIsEvt
           && source.hasOwnProperty && source.hasOwnProperty('toString')) {
            destination.toString = source.toString;
        }
    }
    return destination;
};

highlightText = function(text,highlight,tag) {
    var selectedTag = tag || "strong";

    var lower = text.toLowerCase();
    
    var i = lower.indexOf(highlight.toLowerCase());

    if (i >= 0) {
        var ini = text.substring(0,i);
        var rep = "<"+selectedTag+">"+text.substring(i,i+highlight.length)+"</"+selectedTag+">";
        var end = text.substring(i+highlight.length);
        return ini+rep+end;
    } else {
        return text;
    }
}



checkResult =  function() {
  	var res = "";
  	var resFr = document.getElementById("gpxFrame");
  	if (resFr.contentDocument) {
  		res = resFr.contentDocument.documentElement.textContent;
  	}
  	else	{
  		res = resFr.contentWindow.document.body.innerHTML;
  		if (res != "") {
  		}
  	}

  	//search solution for IE
  	if (res != "")  {
  		var resJSON = JSON.parse(res);
        var toolBar = eGV.getControl("toolbar");
        toolBar.getControl("gpxControl").processResults(resJSON);
    } else {
    	setTimeout("checkResult()",500);
    }

}
