﻿// JScript File
var loadingFile = "../Lxpdm/Img/wait.gif";
var loadBannerWidth = 238; 	// width of image
var loadBannerHeight = 28;	// height of image
var AddressPopUp = '../PesquisaRoteiroMoradas.aspx';
var SearchPage   = '/ResultadoPesquisa.aspx';
var WebFolder = '../';
var str;
// global placeholders for popup windows
var idWin;
var sessionId;


// Enable Identify functionality by setting the mode and toolbar parameters
function ID() 
{
	MapPoint('Map1','Identify');
	// Set the event to the special identify handler
		// Bypasses the default postback process since no new map is needed
	var iddiv = document.getElementById("MapDiv_Map1");
	if (iddiv!=null) iddiv.onmousedown = MapIdClick;
}

// Point action for Identify
// Does not do a postback, but opens the Identify window to process request
function MapIdClick(e) {
	getXY(e);
	getMapDiv(e);
	ShowLoading();
	var blurb = adjustMapCoords();
	
	var f = document.forms[0];
	f.minx.value=zleft;
	f.miny.value=ztop;
	var today = new Date();
	var rand = today.getTime();
	var winId = "IdentifyWindow_" + sessionId;
	var url = "Identify.aspx?idx=" + zleft + "&idy=" + ztop + "&idtype=new&random=" + rand+"&Page=Identify.aspx";
	idWin = window.open(url, winId, "width=400,height=450,scrollbars=yes,status");
	return false;
}

function zoom2F(idL,idF){
    document.WebForm.fid.value = idF;
    document.WebForm.layerid.value = idL;
  // __doPostBack('Toolbar1', 'Zoom2Feature_' + idL + '_' + idF);	     
    __doPostBack('Toolbar1', 'Zoom2Feature');
    
}
  
// Set up various items when page is loaded
function start() 
{   
	var f = document.forms[0];
	tool = f.elements['Map1_mode'].value;
}

// JavaScript function called at unload
// Used to close any windows specifically opened by this page, if still open			
function shutDown() {
	if ((idWin!=null) && (!idWin.closed)) idWin.close();
}
var research;
research=0;
function OpenSearchResult(SearchText)
{   
    research = 1;
    document.location.href=SearchPage+'?text='+SearchText;
}

function SetSelectedValue(CodSigIDTipo)
{   
    window.opener.document.forms[0].TextBox1.value=CodSigIDTipo;
    window.opener.document.forms[0].submit();
    window.close();
}
    
function OnFormSubmit()
{   
    var QueryValue = document.forms(0).txtAddress.value;
    window.opener.location.href=PageName+'?ADD='+QueryValue;
    QueryValue= null;
}
         
function xreplace(checkMe,toberep,repwith)
{
	temp = checkMe;
	a = 0;

    for(i = 0; i < checkMe.length; i++)
    {
        a = temp.indexOf(toberep);
		temp = temp.substring(0 , a) + repwith + temp.substring((a + toberep.length));

		if (a == -1){
		    break;}
		}
    return temp;
}
 
function TrimString(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}

function SetValueSearch(searchvalue)
{   
    if (window.event && window.event.keyCode == 13)
    {
       OpenSearchResult(searchvalue);
    }
}

function ClearTypedText()
{ 
  document.getElementById('txtpesquisa').value ='';
}

function HideLoading()
{   debugger;
    document.getElementById('Loading').visible=false;
}