// CREATED BY
// Infopins.com
// SINOPSIS
// Funciones comunes a tratamiento de mapas entre user y admin
// KNOWN BUGS

// BITACORA 
// GB 14-1-2008 CReacion
// GB 23-4-2008 Se agregaron atributos a propiedad
// GB 13-3-2009 Las calles y otros labels menores se muestran solo en el segundo nivel de zoom

// GB 17-4-2009 Cambio a version 7 para implementacion de nueva version del sitio
// GB 15-5-2009 Map Control to Top Right
// GB 29-5-2009 Cambio en mensaje "Sorry, we are experimenting..."

// GB 11-7-2009 Version 8: removes all functions related to labels like street names and plazas
// GB 17-7-2009 Version unificada de common y user!

// GLOBALES (Revisar esto) 
var map;
// var custommap;
var debug = 0;

var zoomLevel;
var INITIAL_ZOOM_LEVEL = 13;
var BA_LATITUD = -34.5848;
var BA_LONGITUD = -58.4010;

// GB 11-2-2009
var SLOW = 0;
var FAST = 1;

// COD. AREAS
// gb 1-4-2008 Areas, valores tomados de la base. 
var LASCANITAS = '54';
var PALERMONUEVO = '26';
var PALERMOHOLL = '57';
var PALERMOSOHO = '56';
var PUERTOMADERO = '34';
var PLAZA = '36';
var RECOLETA = '35';
var SANTELMO = '40';
var MENDOZA = '72';
var BARILOCHE = '74';
var SALTA = '73';
var AROUNDBA = '75';

var NAME_LASCANITAS = "Las Cañitas";
var NAME_PALERMONUEVO = "Palermo Nuevo";
var NAME_PALERMOHOLL = "Palermo Hollywood";
var NAME_PALERMOSOHO = "Palermo Soho";
var NAME_PUERTOMADERO = "Puerto Madero";
var NAME_PLAZA = "Plaza San Martin";
var NAME_RECOLETA = "Recoleta";
var NAME_SANTELMO = "San Telmo";
var NAME_MENDOZA = "Mendoza";
var NAME_BARILOCHE = "Bariloche";
var NAME_SALTA = "Salta";
var NAME_AROUNDBA = "Around BA";

var polyLasCanitas;
var polyPalermoNuevo;
var polyPalermoHoll;
var polyPalermoSoho;
var polyPuertoMadero;
var polyPuertoMadero;
var polyPlaza;
var polyRecoleta;
var polySanTelmo;
var polyMendoza;
var polyBariloche;
var polySalta;
var polyAroundBA;

// Las Cañitas
var LATITUD_LASCANITAS = -34.56863420401555;
var LONGITUD_LASCANITAS = -58.43361854553223;
var LATITUD_LABEL_LASCANITAS = -34.56963420401555;
var LONGITUD_LABEL_LASCANITAS = -58.43801854553223;

// Palermo Nuevo
var LATITUD_PALERMONUEVO = -34.57937641885099;
var LONGITUD_PALERMONUEVO = -58.41456413269043;
var LATITUD_LABEL_PALERMONUEVO = -34.58037641885099;
var LONGITUD_LABEL_PALERMONUEVO = -58.42086413269043;

// Palermo Hollywood
// gb 27-10-2009
var LATITUD_PALERMOHOLL = -34.58286043150301;
var LONGITUD_PALERMOHOLL = -58.44276431274414;
var LATITUD_LABEL_PALERMOHOLL = -34.58386043150301;
var LONGITUD_LABEL_PALERMOHOLL = -58.44476431274414;

// Palermo Soho
var LATITUD_PALERMOSOHO = -34.59354537801345;
var LONGITUD_PALERMOSOHO = -58.42279296875;
var LATITUD_LABEL_PALERMOSOHO = -34.59454537801345;
var LONGITUD_LABEL_PALERMOSOHO = -58.42879296875;

// Puerto Madero
var LATITUD_PUERTOMADERO = -34.611518575658475;
var LONGITUD_PUERTOMADERO = -58.35806848144531;
var LATITUD_LABEL_PUERTOMADERO = -34.612518575658475;
var LONGITUD_LABEL_PUERTOMADERO = -58.37008;

// Plaza San Martin
var LATITUD_PLAZA = -34.59817195449581;
var LONGITUD_PLAZA = -58.37382452392578;
var LATITUD_LABEL_PLAZA = -34.59917195449581;
var LONGITUD_LABEL_PLAZA = -58.38085;

// Recoleta
var LATITUD_RECOLETA = -34.58826933602292;
var LONGITUD_RECOLETA = -58.398423889160156;
var LATITUD_LABEL_RECOLETA = -34.58916933602292;
var LONGITUD_LABEL_RECOLETA = -58.40200;

// San Telmo
var LATITUD_SANTELMO = -34.61699178146911;
var LONGITUD_SANTELMO = -58.37546784667969;
var LATITUD_LABEL_SANTELMO = -34.61799178146911;
var LONGITUD_LABEL_SANTELMO = -58.38046784667969;

// MENDOZA
var LATITUD_MENDOZA = -32.8905933;
var LONGITUD_MENDOZA = -68.8443803;
var LATITUD_LABEL_MENDOZA = -32.8905933;;
var LONGITUD_LABEL_MENDOZA =  -68.8443803;

// BARILOCHE
var LATITUD_BARILOCHE = -41.1499453;
var LONGITUD_BARILOCHE = -71.3011980;
var LATITUD_LABEL_BARILOCHE = -41.1499453;
var LONGITUD_LABEL_BARILOCHE =  -71.3011980;

// SALTA
var LATITUD_SALTA = -24.7928;
var LONGITUD_SALTA =  -65.4168;
var LATITUD_LABEL_SALTA = -24.7928;
var LONGITUD_LABEL_SALTA =  -65.4168;

// AROUND BA
var LATITUD_AROUNDBA = -34.4564;
var LONGITUD_AROUNDBA = -58.9063;
var LATITUD_LABEL_AROUNDBA = -34.4564;
var LONGITUD_LABEL_AROUNDBA =  -58.9063;

var NAME_CITY = "Buenos Aires";

// COLORES
var GRIS = "#333333";
var AZUL = "#0A1F62";
var BLANCO = "#ffffff";

// POLYLINES, CENTROS DE AREAS, Etc.
var centerLocation;
var centerLasCanitas;
var centerPalermoNuevo;
var centerPalermoHoll;
var centerPalermoSoho;
var centerPuertoMadero;
var centerPlaza;
var centerRecoleta;
var centerSanTelmo;
var centerMendoza;
var centerBariloche;
var centerSalta;
var centerAroundBA;



// gb 10-6-2009 Distingo por navegador
var navegador = "NOTIE6";

// gb 24-3-2009
// Valores default
var filtroArea = 0;
var filtroPrice = 0;
var filtroSize = 99;
var filtroFecha = 0;

// GB 10-2-2009
// array de rotating properties
var rotatingProperties = new Array();

if ( pictureDirectory() == "oasisba" )
{
    rotatingProperties[0] = 15;
    rotatingProperties[1] = 38;
    rotatingProperties[2] = 64;
    rotatingProperties[3] = 34;
    rotatingProperties[4] = 75;
}
else
{
    rotatingProperties[0] = 15;
    rotatingProperties[1] = 38;
    rotatingProperties[2] = 64;
    rotatingProperties[3] = 34;
    rotatingProperties[4] = 75;
}

var nextPropertyIndex = 0;
var rotatingTime = 7500;
var timeoutId;

// GB 16-9-2009
// array de rotating areas, no se usa todavia
var rotatingAreas = new Array();
rotatingAreas[0] = 58;
rotatingAreas[1] = 59;
var nextAreaIndex = 0;
var rotatingTimeArea = 7500;
var timeoutIdArea;
// FIN GB 

// gb 13-7-2009 
var visitedProperties;

// GB 18-8-2009 Para clavar la ciudad aca para toda la aplicacion/sesion
// GB 27-8-2009 pruebo con version text de id-ciudad
var BA = "1";

// SINOPSIS
// retorna el nombre del directorio, para distinguir si estamos en testing o no
// Indica el directorio de donde sacar las fotos!
// KNOWN BUGS
// No es automatica, setear a mano
// BITACORA 
// GB 17-3-2007 Creacion
// GB 23-8-2009 Ver para qué se usa esto bien! se usa solo para ubicar el directorio de las fotos. Le cambio el na,s.
// function directory()
function pictureDirectory()
{
    return "oasisba";
    //return "oasisbatest";
}

function isOutsideBA(areaID) {
    if (areaID == MENDOZA || areaID == BARILOCHE || areaID == SALTA || areaID == AROUNDBA) {
        return true;
    } else {
        return false;
    }
}

function setLanguage(language) {
    if (language == 'portuguese') {
        _RETRIEVING = "Retrieving properties...";
        _UNKNOWN_AREA = "Unknown Area";
        _CLICK_PINS = "Click pins to view properties that fit your search.";
        _NO_PROPERTIES = "There are no properties that fit your search.";
        _PROPERTY_HOUSE = 'house';
        _PROPERTY_APARTMENT = 'apartment';
        _LOCATION = "Location";
        _BEDROOMS = "Bedrooms";
        _BATHROOMS = "Bathrooms";
        _SIZE = "Size";
        _DAILY = "Daily";
        _WEEKLY = "Weekly";
        _MONTHLY = "Monthly";
        _HIGHLIGHTS = "Highlights";
        _TEXTO_LASCANITAS = 'A small, exclusive sub-section of Palermo that has been a favorite of high-end Porte&ntilde;os since the late 90s, Canitas is known for its &ldquo;Restaurant Row&ldquo; on Baez St., which also has more than a few bars and trendy lounges.  The great thing about Canitas is that it&rsquo;s very self-contained, and it strikes a great balance between quiet days (no bus traffic!) and active nights.';
        _LOCATION_LASCANITAS = 'Adjacent to Palermo Hollywood; 5 minute cab to Soho; 20 minutes to Downtown.';
        _HIGHLIGHTS_LASCANITAS = 'Polo field; restaurants and bars; access to Palermo; neighborhood feel.';
        
        _TEXTO_PALERMONUEVO = 'The more residential, traditionally upper-class part of Palermo, Nuevo is home to some of the nicest high-rise buildings in the city. it&rsquo;s quieter at night than Hollywood or Soho, with few bars or restaurants, but has a more polished feel than either, with more easily accessible services (banks, salons, supermarkets), and is close to Palermo&rsquo;s beautiful parks and gardens.';
        _LOCATION_PALERMONUEVO = '5 minute walk to Soho; 15 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMONUEVO = 'Palermo parks (3 de Febrero, Rosedal, Jardin Japones); Zoo; Botanical Gardens; MALBA (the modern art museum).';

        _TEXTO_PALERMOHOLL = 'Taking its name from the film and TV companies that have set up shop there over the last decade, Hollywood is quickly transforming into one of the city&rsquo;s most vibrant neighborhoods. It still retains a good deal of its grit and authenticity, however its tree-lined streets and early 1900s buildings house an extensive and bustling dining and nightlife scene.';
        _LOCATION_PALERMOHOLL = '5 minute walk to Soho or Las Canitas; 20 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMOHOLL = 'Proximity to Palermo parks and the Botanical Gardens; Restaurants/Bars; Adjacent to Palermo Soho shopping.';

        _TEXTO_PALERMOSOHO = 'Full of clothing and design boutiques, restaurants and galleries, and home to two popular outdoor markets, Soho has become one of BA&rsquo;s most popular neighborhoods as period homes have been restored and converted to high-end housing or retail. Traditional architecture and cobblestone streets make it one of the most aesthetically pleasing parts of BA.';
        _LOCATION_PALERMOSOHO = 'Next to Palermo Hollywood; 10 minute cab to Recoleta; 15 minute cab to the Center.';
        _HIGHLIGHTS_PALERMOSOHO = 'Restaurants/Bars; New designer shopping; Outdoor markets; Palermo Parks; Botanical Gardens.';

        _TEXTO_PUERTOMADERO = 'Puerto Madero has undergone a major redevelopment over the past 10 years, and is the most modern area of BA. It is a mix of residential towers and office buildings, with restaurants and cafes lining the river boardwalk that bisects it. Easily accessible from San Telmo, Microcentro and Retiro. Puerto Madero will appeal to those valuing cleanliness, modern amenities and safety.';
        _LOCATION_PUERTOMADERO = 'Adjacent to San Telmo, Retiro and City Center; 15 minute cab to Recoleta.';
        _HIGHLIGHTS_PUERTOMADERO = 'River walk; Ecological Reserve; Sunday antiques market in San Telmo; near to Plaza de Mayo and other downtown attractions.';

        _TEXTO_PLAZA = 'Between the Microcentro, Retiro and Recoleta is Plaza San Martin, a bustling area with some of the most famous buildings in town. The center of the neighborhood is, unsurprisingly, Plaza San Martin itself, BA&rsquo;s prettiest square, featuring lovely trees which flower in the spring. This area makes sense for those who have business in the center, or plan to spend time in San Telmo or Puerto Madero.';
        _LOCATION_PLAZA = 'Walk to the Center; 5 minute cab to San Telmo or Puerto Madero.';
        _HIGHLIGHTS_PLAZA = 'Shopping on Florida Street and Galerias Pacifico; proximity to Plaza de Mayo.';

        _TEXTO_RECOLETA = 'Referred to as the &ldquo;Paris of South America&ldquo;, Recoleta is the most traditionally upscale area of BA, and is home to French-style mansions, sophisticated restaurants and high-end clothing boutiques and art galleries. If you&rsquo;re looking for something edgy, Recoleta is not for you, but if you prefer history and elegance, you won&rsquo;t be disappointed.';
        _LOCATION_RECOLETA = '10 minute cab to Palermo; 10 minute cab to Downtown.';
        _HIGHLIGHTS_RECOLETA = 'Recoleta Cemetery and its outdoor market; Museum of Fine Arts; Evita Museum; High-end designer shopping.';

        _TEXTO_SANTELMO = 'Gracefully crumbling building facades and an active tango scene characterize San Telmo. The area strikes a balance between old and new; where traditional middle-class residents mix with the artists and artisans whose presence has ushered in shops, bars and restaurants. A lively Sunday antiques market takes place in Dorrego Square.';
        _LOCATION_SANTELMO = '5 minute cab to Downtown; 15 minute cab Recoleta; 20 minute cab to Palermo.';
        _HIGHLIGHTS_SANTELMO = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_MENDOZA = 'In the past fifteen years Argentina has emerged as an internationally recognized producer of wine, and it is largely thanks to the region of Mendoza. The area is full of bodegas (vineyards) that produce that famous Malbec, some just outside the capital city, also called Mendoza. The city itself has a tranquil charm, but the real draw is heading into the surrounding countryside for a day (or two!) of wine tastings.';
        _LOCATION_MENDOZA = '1.000 Km from BA';
        _HIGHLIGHTS_MENDOZA = 'Bodegas and fine wines; Trekking; the Aconcagua.';

        _TEXTO_BARILOCHE = 'The picturesque city of Bariloche rests on the shores of Nahuel Haupi Lake, in a massive and stunning national park in Argentina&rsquo;s Lakes District. One of the largest ski centers in all of South America, Argentines and foreigners alike visit the area throughout the year to enjoy a variety of outdoor activities set amongst a magnificent natural backdrop of turquoise lakes, dense forests and snow-capped mountain peaks.';
        _LOCATION_BARILOCHE = '1.571 Km from BA';
        _HIGHLIGHTS_BARILOCHE = 'Skiing resorts; rock climbing and trekking; Nahuel Huapi Lake.';

        _TEXTO_SALTA = '"Salta la Linda" (Salta the Beautiful), as this northern province of Argentina is known, offers a stunning array of painted deserts, towering rock formations, parched salt flats and small colonial towns. The pretty capital city, also called Salta, sits near the border of the neighboring province of Jujuy, and is a great starting point to explore the surrounding region.';
        _LOCATION_SALTA = '1475 Km from BA';
        _HIGHLIGHTS_SALTA = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_AROUNDBA = 'The provincial terrain that surrounds the city of Buenos Aires is quintessentially Argentine, encompassing both its past and its present. A two-hour drive at most, the grasslands are close enough to provide an easy retreat from the city, and life definitely moves at a different pace out here.';
        _LOCATION_AROUNDBA = 'Two hours drive from BA';
        _HIGHLIGHTS_AROUNDBA = 'Gauchos, cattle, ranches, country homes.';
        _SEARCH_BYAREA = "Search by Area";
        _SEARCH_BYPRICE = "Search by Price";
        _PRICE_1 = "Up to U$S 600 / Week";
        _PRICE_2 = "U$S 601 - 1000 / Week";
        _PRICE_3 = "Over U$S 1000 / Week";
        _PRICE_4 = "Up to U$S 1800 / Month";
        _PRICE_5 = "U$S 1801 - 3000 / Month";
        _PRICE_6 = "Over U$S 3000 / Month";
        _SEARCH_BYSIZE = "Search by Size";
        _SIZE_0 = "Studio";
        _SIZE_1 = "One bedroom";
        _SIZE_2 = "Two bedrooms";
        _SIZE_3 = "Three or more bedrooms";
        _CLICK_PROPERTIES = "Click to view properties in ";
        _SEARCH_BYDATE = "Search by Date";
        _HOME_CLEAR_SEARCH = 'Reset Search';
    } else if (language == 'spanish') {
        _RETRIEVING = "Retrieving properties...";
        _UNKNOWN_AREA = "Unknown Area";
        _CLICK_PINS = "Click pins to view properties that fit your search.";
        _NO_PROPERTIES = "There are no properties that fit your search.";
        _PROPERTY_HOUSE = 'house';
        _PROPERTY_APARTMENT = 'apartment';
        _LOCATION = "Location";
        _BEDROOMS = "Bedrooms";
        _BATHROOMS = "Bathrooms";
        _SIZE = "Size";
        _DAILY = "Daily";
        _WEEKLY = "Weekly";
        _MONTHLY = "Monthly";
        _HIGHLIGHTS = "Highlights";
        _TEXTO_LASCANITAS = 'A small, exclusive sub-section of Palermo that has been a favorite of high-end Porte&ntilde;os since the late 90s, Canitas is known for its &ldquo;Restaurant Row&ldquo; on Baez St., which also has more than a few bars and trendy lounges.  The great thing about Canitas is that it&rsquo;s very self-contained, and it strikes a great balance between quiet days (no bus traffic!) and active nights.';
        _LOCATION_LASCANITAS = 'Adjacent to Palermo Hollywood; 5 minute cab to Soho; 20 minutes to Downtown.';
        _HIGHLIGHTS_LASCANITAS = 'Polo field; restaurants and bars; access to Palermo; neighborhood feel.';
        
        _TEXTO_PALERMONUEVO = 'The more residential, traditionally upper-class part of Palermo, Nuevo is home to some of the nicest high-rise buildings in the city. it&rsquo;s quieter at night than Hollywood or Soho, with few bars or restaurants, but has a more polished feel than either, with more easily accessible services (banks, salons, supermarkets), and is close to Palermo&rsquo;s beautiful parks and gardens.';
        _LOCATION_PALERMONUEVO = '5 minute walk to Soho; 15 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMONUEVO = 'Palermo parks (3 de Febrero, Rosedal, Jardin Japones); Zoo; Botanical Gardens; MALBA (the modern art museum).';

        _TEXTO_PALERMOHOLL = 'Taking its name from the film and TV companies that have set up shop there over the last decade, Hollywood is quickly transforming into one of the city&rsquo;s most vibrant neighborhoods. It still retains a good deal of its grit and authenticity, however its tree-lined streets and early 1900s buildings house an extensive and bustling dining and nightlife scene.';
        _LOCATION_PALERMOHOLL = '5 minute walk to Soho or Las Canitas; 20 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMOHOLL = 'Proximity to Palermo parks and the Botanical Gardens; Restaurants/Bars; Adjacent to Palermo Soho shopping.';

        _TEXTO_PALERMOSOHO = 'Full of clothing and design boutiques, restaurants and galleries, and home to two popular outdoor markets, Soho has become one of BA&rsquo;s most popular neighborhoods as period homes have been restored and converted to high-end housing or retail. Traditional architecture and cobblestone streets make it one of the most aesthetically pleasing parts of BA.';
        _LOCATION_PALERMOSOHO = 'Next to Palermo Hollywood; 10 minute cab to Recoleta; 15 minute cab to the Center.';
        _HIGHLIGHTS_PALERMOSOHO = 'Restaurants/Bars; New designer shopping; Outdoor markets; Palermo Parks; Botanical Gardens.';

        _TEXTO_PUERTOMADERO = 'Puerto Madero has undergone a major redevelopment over the past 10 years, and is the most modern area of BA. It is a mix of residential towers and office buildings, with restaurants and cafes lining the river boardwalk that bisects it. Easily accessible from San Telmo, Microcentro and Retiro. Puerto Madero will appeal to those valuing cleanliness, modern amenities and safety.';
        _LOCATION_PUERTOMADERO = 'Adjacent to San Telmo, Retiro and City Center; 15 minute cab to Recoleta.';
        _HIGHLIGHTS_PUERTOMADERO = 'River walk; Ecological Reserve; Sunday antiques market in San Telmo; near to Plaza de Mayo and other downtown attractions.';

        _TEXTO_PLAZA = 'Between the Microcentro, Retiro and Recoleta is Plaza San Martin, a bustling area with some of the most famous buildings in town. The center of the neighborhood is, unsurprisingly, Plaza San Martin itself, BA&rsquo;s prettiest square, featuring lovely trees which flower in the spring. This area makes sense for those who have business in the center, or plan to spend time in San Telmo or Puerto Madero.';
        _LOCATION_PLAZA = 'Walk to the Center; 5 minute cab to San Telmo or Puerto Madero.';
        _HIGHLIGHTS_PLAZA = 'Shopping on Florida Street and Galerias Pacifico; proximity to Plaza de Mayo.';

        _TEXTO_RECOLETA = 'Referred to as the &ldquo;Paris of South America&ldquo;, Recoleta is the most traditionally upscale area of BA, and is home to French-style mansions, sophisticated restaurants and high-end clothing boutiques and art galleries. If you&rsquo;re looking for something edgy, Recoleta is not for you, but if you prefer history and elegance, you won&rsquo;t be disappointed.';
        _LOCATION_RECOLETA = '10 minute cab to Palermo; 10 minute cab to Downtown.';
        _HIGHLIGHTS_RECOLETA = 'Recoleta Cemetery and its outdoor market; Museum of Fine Arts; Evita Museum; High-end designer shopping.';

        _TEXTO_SANTELMO = 'Gracefully crumbling building facades and an active tango scene characterize San Telmo. The area strikes a balance between old and new; where traditional middle-class residents mix with the artists and artisans whose presence has ushered in shops, bars and restaurants. A lively Sunday antiques market takes place in Dorrego Square.';
        _LOCATION_SANTELMO = '5 minute cab to Downtown; 15 minute cab Recoleta; 20 minute cab to Palermo.';
        _HIGHLIGHTS_SANTELMO = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_MENDOZA = 'In the past fifteen years Argentina has emerged as an internationally recognized producer of wine, and it is largely thanks to the region of Mendoza. The area is full of bodegas (vineyards) that produce that famous Malbec, some just outside the capital city, also called Mendoza. The city itself has a tranquil charm, but the real draw is heading into the surrounding countryside for a day (or two!) of wine tastings.';
        _LOCATION_MENDOZA = '1.000 Km from BA';
        _HIGHLIGHTS_MENDOZA = 'Bodegas and fine wines; Trekking; the Aconcagua.';

        _TEXTO_BARILOCHE = 'The picturesque city of Bariloche rests on the shores of Nahuel Haupi Lake, in a massive and stunning national park in Argentina&rsquo;s Lakes District. One of the largest ski centers in all of South America, Argentines and foreigners alike visit the area throughout the year to enjoy a variety of outdoor activities set amongst a magnificent natural backdrop of turquoise lakes, dense forests and snow-capped mountain peaks.';
        _LOCATION_BARILOCHE = '1.571 Km from BA';
        _HIGHLIGHTS_BARILOCHE = 'Skiing resorts; rock climbing and trekking; Nahuel Huapi Lake.';

        _TEXTO_SALTA = '"Salta la Linda" (Salta the Beautiful), as this northern province of Argentina is known, offers a stunning array of painted deserts, towering rock formations, parched salt flats and small colonial towns. The pretty capital city, also called Salta, sits near the border of the neighboring province of Jujuy, and is a great starting point to explore the surrounding region.';
        _LOCATION_SALTA = '1475 Km from BA';
        _HIGHLIGHTS_SALTA = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_AROUNDBA = 'The provincial terrain that surrounds the city of Buenos Aires is quintessentially Argentine, encompassing both its past and its present. A two-hour drive at most, the grasslands are close enough to provide an easy retreat from the city, and life definitely moves at a different pace out here.';
        _LOCATION_AROUNDBA = 'Two hours drive from BA';
        _HIGHLIGHTS_AROUNDBA = 'Gauchos, cattle, ranches, country homes.';
        _SEARCH_BYAREA = "Search by Area";
        _SEARCH_BYPRICE = "Search by Price";
        _PRICE_1 = "Up to U$S 600 / Week";
        _PRICE_2 = "U$S 601 - 1000 / Week";
        _PRICE_3 = "Over U$S 1000 / Week";
        _PRICE_4 = "Up to U$S 1800 / Month";
        _PRICE_5 = "U$S 1801 - 3000 / Month";
        _PRICE_6 = "Over U$S 3000 / Month";
        _SEARCH_BYSIZE = "Search by Size";
        _SIZE_0 = "Studio";
        _SIZE_1 = "One bedroom";
        _SIZE_2 = "Two bedrooms";
        _SIZE_3 = "Three or more bedrooms";
        _CLICK_PROPERTIES = "Click to view properties in ";
    } else {    // ingl�s por defecto
        _RETRIEVING = "Retrieving properties...";
        _UNKNOWN_AREA = "Unknown Area";
        _CLICK_PINS = "Click pins to view properties that fit your search.";
        _NO_PROPERTIES = "There are no properties that fit your search.";
        _PROPERTY_HOUSE = 'house';
        _PROPERTY_APARTMENT = 'apartment';
        _LOCATION = "Location";
        _BEDROOMS = "Bedrooms";
        _BATHROOMS = "Bathrooms";
        _SIZE = "Size";
        _DAILY = "Daily";
        _WEEKLY = "Weekly";
        _MONTHLY = "Monthly";
        _HIGHLIGHTS = "Highlights";
        _TEXTO_LASCANITAS = 'A small, exclusive sub-section of Palermo that has been a favorite of high-end Porte&ntilde;os since the late 90s, Canitas is known for its &ldquo;Restaurant Row&ldquo; on Baez St., which also has more than a few bars and trendy lounges.  The great thing about Canitas is that it&rsquo;s very self-contained, and it strikes a great balance between quiet days (no bus traffic!) and active nights.';
        _LOCATION_LASCANITAS = 'Adjacent to Palermo Hollywood; 5 minute cab to Soho; 20 minutes to Downtown.';
        _HIGHLIGHTS_LASCANITAS = 'Polo field; restaurants and bars; access to Palermo; neighborhood feel.';
        
        _TEXTO_PALERMONUEVO = 'The more residential, traditionally upper-class part of Palermo, Nuevo is home to some of the nicest high-rise buildings in the city. it&rsquo;s quieter at night than Hollywood or Soho, with few bars or restaurants, but has a more polished feel than either, with more easily accessible services (banks, salons, supermarkets), and is close to Palermo&rsquo;s beautiful parks and gardens.';
        _LOCATION_PALERMONUEVO = '5 minute walk to Soho; 15 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMONUEVO = 'Palermo parks (3 de Febrero, Rosedal, Jardin Japones); Zoo; Botanical Gardens; MALBA (the modern art museum).';

        _TEXTO_PALERMOHOLL = 'Taking its name from the film and TV companies that have set up shop there over the last decade, Hollywood is quickly transforming into one of the city&rsquo;s most vibrant neighborhoods. It still retains a good deal of its grit and authenticity, however its tree-lined streets and early 1900s buildings house an extensive and bustling dining and nightlife scene.';
        _LOCATION_PALERMOHOLL = '5 minute walk to Soho or Las Canitas; 20 minute cab to Downtown.';
        _HIGHLIGHTS_PALERMOHOLL = 'Proximity to Palermo parks and the Botanical Gardens; Restaurants/Bars; Adjacent to Palermo Soho shopping.';

        _TEXTO_PALERMOSOHO = 'Full of clothing and design boutiques, restaurants and galleries, and home to two popular outdoor markets, Soho has become one of BA&rsquo;s most popular neighborhoods as period homes have been restored and converted to high-end housing or retail. Traditional architecture and cobblestone streets make it one of the most aesthetically pleasing parts of BA.';
        _LOCATION_PALERMOSOHO = 'Next to Palermo Hollywood; 10 minute cab to Recoleta; 15 minute cab to the Center.';
        _HIGHLIGHTS_PALERMOSOHO = 'Restaurants/Bars; New designer shopping; Outdoor markets; Palermo Parks; Botanical Gardens.';

        _TEXTO_PUERTOMADERO = 'Puerto Madero has undergone a major redevelopment over the past 10 years, and is the most modern area of BA. It is a mix of residential towers and office buildings, with restaurants and cafes lining the river boardwalk that bisects it. Easily accessible from San Telmo, Microcentro and Retiro. Puerto Madero will appeal to those valuing cleanliness, modern amenities and safety.';
        _LOCATION_PUERTOMADERO = 'Adjacent to San Telmo, Retiro and City Center; 15 minute cab to Recoleta.';
        _HIGHLIGHTS_PUERTOMADERO = 'River walk; Ecological Reserve; Sunday antiques market in San Telmo; near to Plaza de Mayo and other downtown attractions.';

        _TEXTO_PLAZA = 'Between the Microcentro, Retiro and Recoleta is Plaza San Martin, a bustling area with some of the most famous buildings in town. The center of the neighborhood is, unsurprisingly, Plaza San Martin itself, BA&rsquo;s prettiest square, featuring lovely trees which flower in the spring. This area makes sense for those who have business in the center, or plan to spend time in San Telmo or Puerto Madero.';
        _LOCATION_PLAZA = 'Walk to the Center; 5 minute cab to San Telmo or Puerto Madero.';
        _HIGHLIGHTS_PLAZA = 'Shopping on Florida Street and Galerias Pacifico; proximity to Plaza de Mayo.';

        _TEXTO_RECOLETA = 'Referred to as the &ldquo;Paris of South America&ldquo;, Recoleta is the most traditionally upscale area of BA, and is home to French-style mansions, sophisticated restaurants and high-end clothing boutiques and art galleries. If you&rsquo;re looking for something edgy, Recoleta is not for you, but if you prefer history and elegance, you won&rsquo;t be disappointed.';
        _LOCATION_RECOLETA = '10 minute cab to Palermo; 10 minute cab to Downtown.';
        _HIGHLIGHTS_RECOLETA = 'Recoleta Cemetery and its outdoor market; Museum of Fine Arts; Evita Museum; High-end designer shopping.';

        _TEXTO_SANTELMO = 'Gracefully crumbling building facades and an active tango scene characterize San Telmo. The area strikes a balance between old and new; where traditional middle-class residents mix with the artists and artisans whose presence has ushered in shops, bars and restaurants. A lively Sunday antiques market takes place in Dorrego Square.';
        _LOCATION_SANTELMO = '5 minute cab to Downtown; 15 minute cab Recoleta; 20 minute cab to Palermo.';
        _HIGHLIGHTS_SANTELMO = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_MENDOZA = 'In the past fifteen years Argentina has emerged as an internationally recognized producer of wine, and it is largely thanks to the region of Mendoza. The area is full of bodegas (vineyards) that produce that famous Malbec, some just outside the capital city, also called Mendoza. The city itself has a tranquil charm, but the real draw is heading into the surrounding countryside for a day (or two!) of wine tastings.';
        _LOCATION_MENDOZA = '1.000 Km from BA';
        _HIGHLIGHTS_MENDOZA = 'Bodegas and fine wines; Trekking; the Aconcagua.';

        _TEXTO_BARILOCHE = 'The picturesque city of Bariloche rests on the shores of Nahuel Haupi Lake, in a massive and stunning national park in Argentina&rsquo;s Lakes District. One of the largest ski centers in all of South America, Argentines and foreigners alike visit the area throughout the year to enjoy a variety of outdoor activities set amongst a magnificent natural backdrop of turquoise lakes, dense forests and snow-capped mountain peaks.';
        _LOCATION_BARILOCHE = '1.571 Km from BA';
        _HIGHLIGHTS_BARILOCHE = 'Skiing resorts; rock climbing and trekking; Nahuel Huapi Lake.';

        _TEXTO_SALTA = '"Salta la Linda" (Salta the Beautiful), as this northern province of Argentina is known, offers a stunning array of painted deserts, towering rock formations, parched salt flats and small colonial towns. The pretty capital city, also called Salta, sits near the border of the neighboring province of Jujuy, and is a great starting point to explore the surrounding region.';
        _LOCATION_SALTA = '1475 Km from BA';
        _HIGHLIGHTS_SALTA = 'Weekend antiques market; tango dancehalls; walk to Puerto Madero, the Ecological Reserve and Plaza de Mayo.';

        _TEXTO_AROUNDBA = 'The provincial terrain that surrounds the city of Buenos Aires is quintessentially Argentine, encompassing both its past and its present. A two-hour drive at most, the grasslands are close enough to provide an easy retreat from the city, and life definitely moves at a different pace out here.';
        _LOCATION_AROUNDBA = 'Two hours drive from BA';
        _HIGHLIGHTS_AROUNDBA = 'Gauchos, cattle, ranches, country homes.';
        _SEARCH_BYAREA = "Search by Area";
        _SEARCH_BYPRICE = "Search by Price";
        _PRICE_1 = "Up to U$S 600 / Week";
        _PRICE_2 = "U$S 601 - 1000 / Week";
        _PRICE_3 = "Over U$S 1000 / Week";
        _PRICE_4 = "Up to U$S 1800 / Month";
        _PRICE_5 = "U$S 1801 - 3000 / Month";
        _PRICE_6 = "Over U$S 3000 / Month";
        _SEARCH_BYSIZE = "Search by Size";
        _SIZE_0 = "Studio";
        _SIZE_1 = "One bedroom";
        _SIZE_2 = "Two bedrooms";
        _SIZE_3 = "Three or more bedrooms";
        _CLICK_PROPERTIES = "Click to view properties in ";
    }
}

// SINOPSIS
// Carga el mapa
// KNOWN BUGS
// BITACORA 
// GB 16-12-2007 Creacion
// GB 13-7-2009 Grayed Properties
// function load() 
function load( properties, language) 
{
    // alert("Entrando a load(), properties = " + properties);
    visitedProperties = properties;
    setLanguage(language);

    if (GBrowserIsCompatible()) 
    {
        // alert("Despues de GBrowserIsCompatible()");
        // map = new GMap2( document.getElementById("map"), { mapTypes : [G_HYBRID_MAP], draggableCursor: 'pointer', draggingCursor: 'pointer' } );
        map = new GMap2( document.getElementById("map"), { mapTypes : [G_NORMAL_MAP]});

        // CONTROLES
        var position = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,10));
        map.addControl(new GSmallMapControl(), position);

        // ZOOM
        map.enableContinuousZoom();
        // map.enableScrollWheelZoom();

        // CUSTOM
        // Add markers and polylines
        initMapEvent();
        // Centro el mapa
        centerMap();
        // Muestra las propiedades
        // GB 19-10-2009 desde hoy la llamo renderMap
        // showProperties();
        renderMapContent();
    }
}

// SINOPSIS
// Inicializa eventos del mapa
// KNOWN BUGS
// BITACORA 
// GB 16-12-2007 Creacion
// GB 23-8-2009 No hace falta en floripa
function initMapEvent()
{
    createAreas();
    createAreaLabels();
}


// SINOPSIS
// Crea elementos relacionados con areas
// KNOWN BUGS
// BITACORA 
// GB 30-09-2009 Creacion
function createAreas()
{
    // alert( "Entrando a createAreas" );
    centerLocation = new GLatLng( BA_LATITUD, BA_LONGITUD );	
    centerLasCanitas = new GLatLng( LATITUD_LASCANITAS, LONGITUD_LASCANITAS );
    centerPalermoNuevo = new GLatLng( LATITUD_PALERMONUEVO, LONGITUD_PALERMONUEVO );
    centerPalermoHoll = new GLatLng( LATITUD_PALERMOHOLL, LONGITUD_PALERMOHOLL );
    centerPalermoSoho = new GLatLng( LATITUD_PALERMOSOHO, LONGITUD_PALERMOSOHO );
    centerPuertoMadero = new GLatLng( LATITUD_PUERTOMADERO, LONGITUD_PUERTOMADERO );
    centerPlaza = new GLatLng( LATITUD_PLAZA, LONGITUD_PLAZA );
    centerRecoleta = new GLatLng( LATITUD_RECOLETA, LONGITUD_RECOLETA );
    centerSanTelmo = new GLatLng( LATITUD_SANTELMO, LONGITUD_SANTELMO );
    centerMendoza = new GLatLng( LATITUD_MENDOZA, LONGITUD_MENDOZA );
    centerBariloche = new GLatLng( LATITUD_BARILOCHE, LONGITUD_BARILOCHE );
    centerSalta = new GLatLng( LATITUD_SALTA, LONGITUD_SALTA );
    centerAroundBA = new GLatLng( LATITUD_AROUNDBA, LONGITUD_AROUNDBA );

    var polyOptions = {geodesic:true};
    
    // Las Cañitas
    polyLasCanitas = new GPolyline([
            new GLatLng(-34.571037188374596, -58.4238338470459),	// Dorrego y Libertador	
            new GLatLng(-34.56368666461157, -58.436665534973144),	// Libertador y Olleros
            new GLatLng(-34.563103542363585, -58.43836069107056),	// Libertador y Lacroze
            new GLatLng(-34.56543600682457, -58.440377712249756),	// Campos y Lacroze	
            new GLatLng(-34.56619581066698, -58.439412117004394),	// Campos y Olleros
            new GLatLng(-34.568422172649754, -58.437373638153076),	// Campos y Maure
            new GLatLng(-34.57467687065438, -58.431429862976074),	// Campos y via
            new GLatLng(-34.57393481244155, -58.4292197227478),		// Campos y via + 1
            new GLatLng(-34.573051401171064, -58.427181243896484),	// Campos y via + 2	
            new GLatLng(-34.571037188374596, -58.4238338470459),	// Dorrego y Libertador	
            ], AZUL, 3, 0.5, polyOptions);

    // Palermo Nuevo
    polyPalermoNuevo = new GPolyline([
            new GLatLng(-34.57870507108972, -58.42550754547119),	// j.b. justo y sta. fe
            new GLatLng(-34.57838706236286, -58.426451683044434),	// j.b. justo y sta. fe + 1
            new GLatLng(-34.571355225218134, -58.422911167144775),	// libertador y sarmiento
            new GLatLng(-34.577609702575295, -58.41014385223389),	// libertador y casares		
            new GLatLng(-34.57467687065438, -58.40748310089111),	// alcorta y casares		
            new GLatLng(-34.5782457247604, -58.402719497680664),	// alcorta y ortiz de ocampo		
            new GLatLng(-34.581213763943346, -58.40314865112305),	// libertador y ortiz de ocampo + 1
            new GLatLng(-34.581390429600226, -58.40362071990967),	// libertador y ortiz de ocampo
            new GLatLng(-34.580613097901036, -58.404672145843506),	// libertador y cnel diaz
            new GLatLng(-34.58340439154656, -58.40615272521973),	// las heras y cnel diaz
            new GLatLng(-34.58902202744696, -58.41010093688965),	// sta fe y cnel diaz
            new GLatLng(-34.581302096818725, -58.42151641845703),	// sta fe. pza italia	
            new GLatLng(-34.57870507108972, -58.42550754547119),	// j.b. justo y sta. fe
            ], AZUL, 3, 0.5, polyOptions);


    // Palermo Hollywood
    polyPalermoHoll = new GPolyline([
            new GLatLng(-34.57870507108972, -58.42550754547119),	// j.b. justo y sta. fe
            new GLatLng(-34.58078976483469, -58.42722415924072),	// g. cruz y honduras + 2
            new GLatLng(-34.583934373420995, -58.43052864074707),	// g. cruz y honduras + 1
            new GLatLng(-34.586372246510955, -58.43357563018799),	// g. cruz y honduras
            new GLatLng(-34.588810048081676, -58.438425064086914),	// cdba y j.b. justo
            new GLatLng(-34.58457034720894, -58.44481945037842),	// cdba y dorrego
            new GLatLng(-34.58177909272353, -58.44348907470703),	// cdba y dorrego 2 
            new GLatLng(-34.57503022938008, -58.43548536300659), 	// sta fe y dorrego
            new GLatLng(-34.57870507108972, -58.42550754547119),	// j.b. justo y sta. fe		
            ], AZUL, 3, 0.5, polyOptions);


    // Palermo Soho
    polyPalermoSoho = new GPolyline([
            new GLatLng(-34.58912801692679, -58.41031551361084),	// sta fe y salguero
            new GLatLng(-34.58902202744696, -58.41010093688965),	// sta fe y cnel diaz		
            new GLatLng(-34.594180025309626, -58.414435386657715),	// cnel diaz y soler
            new GLatLng(-34.59781869416358, -58.41598033905029),	// cordoba y mario bravo		
            new GLatLng(-34.597748041916844, -58.423404693603516),	// cdba y estado de israel
            new GLatLng(-34.5961583504773, -58.427138328552246),	// cdba subiendo 1
            new GLatLng(-34.5889866975903, -58.43825340270996),		// cdba y j.b. justo
            new GLatLng(-34.586372246510955, -58.43357563018799),	// g. cruz y honduras
            new GLatLng(-34.583934373420995, -58.43052864074707),	// g. cruz y honduras + 1
            new GLatLng(-34.58078976483469, -58.42722415924072),	// g. cruz y honduras + 2
            new GLatLng(-34.57870507108972, -58.42550754547119),	// j.b. justo y sta. fe
            new GLatLng(-34.58912801692679, -58.41031551361084), 	// sta fe y salguero
            ], AZUL, 3, 0.5, polyOptions);

    // Puerto Madero
    polyPuertoMadero = new GPolyline([
            new GLatLng(-34.59838390997399, -58.3689022064209),		// cdba y alem
            new GLatLng(-34.62226076348112, -58.365983963012695),	// p. colon y garay
            new GLatLng(-34.62388527023713, -58.36495399475098),	// p. colon y garay abajo 1 
            new GLatLng(-34.62452093813695, -58.36306571960449),	// p. colon y brasil
            new GLatLng(-34.617952135025526, -58.356285095214844),	// av. españa sur
            new GLatLng(-34.59795999847676, -58.363494873046875),	// av. españa norte
            new GLatLng(-34.59838390997399, -58.3689022064209),		// cdba y alem		
            ], AZUL, 3, 0.5, polyOptions);

    // Plaza San Martín
    polyPlaza = new GPolyline([
            new GLatLng(-34.58882771304945, -58.38158369064331),	// alcorta y 9 de julio
            new GLatLng(-34.595557792460326, -58.38216304779053),	// 9 de julio y sta. fe
            new GLatLng(-34.60371794474704, -58.38164806365967),	// 9 de julio y corrientes
            new GLatLng(-34.60311744138932, -58.36838722229004),	// corrientes y madero
            new GLatLng(-34.59845456167985, -58.3689022064209),		// cordoba y madero
            new GLatLng(-34.595345829770636, -58.37079048156738),	// cordoba y madero + 1
            new GLatLng(-34.59365010878254, -58.37379455566406),	// libertador y san martin
            new GLatLng(-34.58882771304945, -58.38158369064331),	// alcorta y 9 de julio
            ], AZUL, 3, 0.5, polyOptions);

    // Recoleta
    polyRecoleta = new GPolyline([
            new GLatLng(-34.580613097901036, -58.404672145843506),	// libertador y cnel diaz
            new GLatLng(-34.58131976338253, -58.403706550598144),	// libertador y ortiz de ocampo
            new GLatLng(-34.581213763943346, -58.40314865112305),	// libertador y ortiz de ocampo + 1
            new GLatLng(-34.5782457247604, -58.402719497680664),	// alcorta y ortiz de ocampo		
            new GLatLng(-34.579888759547025, -58.39990854263306),	// alcorta bajando 1		
            new GLatLng(-34.58176142625736, -58.39585304260254),	// alcorta bajando 2		
            new GLatLng(-34.58501199280933, -58.389179706573486),	// alcorta bajando 3	
            new GLatLng(-34.58660189753636, -58.38587522506714),	// alcorta y callao	
            new GLatLng(-34.58882771304945, -58.38158369064331),	// alcorta y 9 de julio
            new GLatLng(-34.59361478089388, -58.382463455200195),	// 9 de julio y juncal	
            new GLatLng(-34.59545181118308, -58.38216304779053),	// 9 de julio y sta. fe
            new GLatLng(-34.59612302365532, -58.38212013244629),	// 9 de julio y sta. fe II		
            new GLatLng(-34.59587573548076, -58.3933424949646),		// sta. fe y callao
            new GLatLng(-34.59562844657003, -58.39799880981445),	// sta. fe, entre callao y pueyrredon		
            new GLatLng(-34.59449797360336, -58.40239763259888),	// sta. fe y pueyrredon
            new GLatLng(-34.59333215724376, -58.405165672302246),	// sta. fe, entre pueyrredon y aguero
            new GLatLng(-34.59176004564101, -58.40711832046509),	// sta. fe y aguero
            new GLatLng(-34.58902202744696, -58.41010093688965),	// sta fe y cnel diaz		
            new GLatLng(-34.580613097901036, -58.404672145843506),	// libertador y cnel diaz
            ], AZUL, 3, 0.5, polyOptions);

    // San Telmo
    polySanTelmo = new GPolyline([
            new GLatLng(-34.612195175810925,-58.366670608520511),	// Belgrano y Moreau de Justo	
            new GLatLng(-34.61307817093802, -58.38117599487305),	// Belgrano y 9 de Julio
            new GLatLng(-34.62296707467393, -58.3807897567749),		// 9 de Julio y San Juan
            new GLatLng(-34.626357284715944, -58.37954521179199),	// 9 de Julio y Garay
            new GLatLng(-34.624662197008945, -58.37555408477783),	// Garay 1 
            new GLatLng(-34.62377932511372, -58.36508274078369),	// Garay  y Moreau de Justo
            new GLatLng(-34.612195175810925,-58.366670608520511),	// Belgrano y Moreau de Justo	
            ], AZUL, 3, 0.5, polyOptions);
    // Mendoza
    polyMendoza = new GPolyline([
            new GLatLng(-32.8710, -68.8345),
            new GLatLng(-32.8687, -68.8580),
            new GLatLng(-32.8863, -68.8620),		
            new GLatLng(-32.9015, -68.8644),
            new GLatLng(-32.9020, -68.8522),
            new GLatLng(-32.8967, -68.8410),
            new GLatLng(-32.8710, -68.8345),
            ], AZUL, 3, 0.5, polyOptions)
    //Bariloche
    polyBariloche = new GPolyline([
            new GLatLng(-41.13275, -71.3071),
            new GLatLng(-41.13657, -71.3124),
            new GLatLng(-41.14665, -71.3127),	
            new GLatLng(-41.15447, -71.3037),
            new GLatLng(-41.14943, -71.2894),	
            new GLatLng(-41.13896, -71.2887),
            new GLatLng(-41.13359, -71.2888),
            new GLatLng(-41.13275, -71.3071),
            ], AZUL, 3, 0.5, polyOptions)
    //Salta
    polySalta = new GPolyline([
            new GLatLng(-24.7783, -65.4320),	
            new GLatLng(-24.7926, -65.4403),	
            new GLatLng(-24.8040, -65.4279),	
            new GLatLng(-24.8071, -65.3967),
            new GLatLng(-24.7946, -65.3989),
            new GLatLng(-24.7817, -65.4030),
            new GLatLng(-24.7783, -65.4320),
            ], AZUL, 3, 0.5, polyOptions)
    //Around BA
    polyAroundBA = new GPolyline([
            new GLatLng(LATITUD_AROUNDBA, LONGITUD_AROUNDBA),
            new GLatLng(LATITUD_AROUNDBA, LONGITUD_AROUNDBA),
            ], AZUL, 3, 0.5, polyOptions)
}

// SINOPSIS
// Crea los labels de barrios
// KNOWN BUGS
// BITACORA 
// GB 30-09-2009 Creacion
function createAreaLabels()
{
    var dx = 0.5;

    var centerLabelLasCanitas = new GLatLng( LATITUD_LABEL_LASCANITAS, LONGITUD_LABEL_LASCANITAS);
    var labelLasCanitas = crearNombreBarrio( NAME_LASCANITAS, centerLabelLasCanitas );
    map.addTLabel(labelLasCanitas);

    var centerLabelPalermoNuevo = new GLatLng(LATITUD_LABEL_PALERMONUEVO, LONGITUD_LABEL_PALERMONUEVO);
    var labelPalermoNuevo = crearNombreBarrio( NAME_PALERMONUEVO, centerLabelPalermoNuevo );
    map.addTLabel(labelPalermoNuevo);

    var centerLabelPalermoHoll = new GLatLng(LATITUD_LABEL_PALERMOHOLL, LONGITUD_LABEL_PALERMOHOLL);
    var labelPalermoHoll = crearNombreBarrio( NAME_PALERMOHOLL, centerLabelPalermoHoll );
    map.addTLabel(labelPalermoHoll);

    var centerLabelPalermoSoho = new GLatLng(LATITUD_LABEL_PALERMOSOHO, LONGITUD_LABEL_PALERMOSOHO);
    var labelPalermoSoho = crearNombreBarrio( NAME_PALERMOSOHO, centerLabelPalermoSoho );
    map.addTLabel(labelPalermoSoho);

    var centerLabelPuertoMadero = new GLatLng(LATITUD_LABEL_PUERTOMADERO, LONGITUD_LABEL_PUERTOMADERO);
    var labelPuertoMadero = crearNombreBarrio( NAME_PUERTOMADERO, centerLabelPuertoMadero );
    map.addTLabel(labelPuertoMadero);

    var centerLabelPlaza = new GLatLng(LATITUD_LABEL_PLAZA, LONGITUD_LABEL_PLAZA);
    var labelPlaza = crearNombreBarrio( NAME_PLAZA, centerLabelPlaza );
    map.addTLabel(labelPlaza);

    var centerLabelRecoleta = new GLatLng(LATITUD_LABEL_RECOLETA, LONGITUD_LABEL_RECOLETA);
    var labelRecoleta = crearNombreBarrio( NAME_RECOLETA, centerLabelRecoleta );
    map.addTLabel(labelRecoleta);

    var centerLabelSanTelmo = new GLatLng(LATITUD_LABEL_SANTELMO, LONGITUD_LABEL_SANTELMO);
    var labelSanTelmo = crearNombreBarrio( NAME_SANTELMO, centerLabelSanTelmo );
    map.addTLabel(labelSanTelmo);

    var centerLabelMendoza = new GLatLng(LATITUD_LABEL_MENDOZA, LONGITUD_LABEL_MENDOZA);
    var labelMendoza = crearNombreBarrio( NAME_MENDOZA, centerLabelMendoza );
    map.addTLabel(labelMendoza);

    var centerLabelBariloche = new GLatLng(LATITUD_LABEL_BARILOCHE, LONGITUD_LABEL_BARILOCHE);
    var labelBariloche = crearNombreBarrio( NAME_BARILOCHE, centerLabelBariloche );
    map.addTLabel(labelBariloche);

    var centerLabelSalta = new GLatLng(LATITUD_LABEL_SALTA, LONGITUD_LABEL_SALTA);
    var labelSalta = crearNombreBarrio( NAME_SALTA, centerLabelSalta );
    map.addTLabel(labelSalta);

    var centerLabelAroundBA = new GLatLng(LATITUD_LABEL_AROUNDBA, LONGITUD_LABEL_AROUNDBA);
    var labelAroundBA = crearNombreBarrio( NAME_AROUNDBA, centerLabelAroundBA );
    map.addTLabel(labelAroundBA);

}

// SINOPSIS
// Crea un TLabel del nombre de un barrio con su coordnada y estilo
// KNOWN BUGS
// El formato del label esta clavado en el codigo por ahora
// BITACORA 
// GB 10-9-2008 Creacion
function crearNombreBarrio( nombre, coordenada )
{
    // alert( "Debug Message: Entering to function crearNombreBarrio(): nombre = " + nombre + ", coordenada = " + coordenada.toString());  
    var content;	
    content = '<div class="map-label">'+'<nobr>'+nombre+'</nobr>'+'</div>';

    var label = new TLabel();
    // gb pongo un label univoco para que no haya problemas
    if ( label )
    {		
        label.id = 'label-' + nombre;
        label.anchorLatLng = coordenada;
        label.anchorPoint = 'bottomCenter';
        label.anchorPoint = 'topLeft';
        label.content = content;
        label.percentOpacity = 100;
        return label;
    }
}


// SINOPSIS
// Muestra una propiedad en infowindos
// KNOWN BUGS
// BITACORA 
// AG 04-2008 Creacion
// GB 10-04-2008 Revision y cambion nombre
// GB 9-3-2009 Agregamos posibilidad de contar vistas de infowindow
// function mostrarInfowindow( idx , speed )
function mostrarInfowindow( idx , speed, count )
{
    // alert( "En mostrarInfowindow, id = " + idx );
    ajax = creaAjax();	
    // gb 26-4-2008 pruebo con GET, como esta en los manuales en vez de POST, para sortear el problema com FF
    ajax.open("GET", "AXPropiedad.php?IA="+idx+"&count="+count, true);
    ajax.onreadystatechange = function() 
    {   
        if (ajax.readyState == 1) 
        {
            // alert("MostrarInfoWindow: ajax.readyState = 1");
        } 
        else 
            if (ajax.readyState == 4)
            {  
                // alert("MostrarInfoWindow: ajax.readyState = 4, response = " + ajax.responseText);
                // parseo la respuesta y convierto en array
                var arrTemp = ajax.responseText.split("|");
                // alert( "arrTemp.length = " + arrTemp.length); 
                // chequeo si hay contenido en la respuesta
                if ( arrTemp.length == 1 )
                {
                    mostrarMensaje(_RETRIEVING);
                    return;
                }
                // creo propiedad en base a array
                p = createProperty( arrTemp );
                // armo infowindow
                var html = buildInfowindowContent( p );
                // GB 11-2-2009
                abrirInfowindow( html, speed );
            } 
    }
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(null);
}

// SINOPSIS
// Muestra un area en infowindow
// KNOWN BUGS
// BITACORA 
function mostrarAreaWindow( idx , speed )
{
    showNeighborhoodDescription( idx, "", "areawindow");
}

// SINOPSIS
// Apaga con un efecto de fade out la infowindow
// BITACORA
// GB 10/2/2008 Creacion
// GB 11-2-2009 No va mas
function ocultarInfowindow()
{
    // fadeOutMyPopup();
}

// SINOPSIS
// Apaga con un efecto de fade out la infowindow
// BITACORA
// GB 11/2/2009 Cambio nombres desde Abrir... y saco window title
// GB 11/2/2009 Traida desde styled_popup.js aca
// GB 10/2/2008 Creacion
function abrirInfowindow(html, speed)
{
    // alert( "En abrirInfowindow");
    if ( speed == SLOW )
        slowlyFireMyPopup(html);
    else
        fireMyPopup(html);
}

// SINOPSIS
// Apaga con un efecto de fade out el areawindow
// BITACORA
// GB 16-9-2009 Creacion
function abrirAreaWindow(html, speed)
{
    // alert( "En abrirAreaWindow");
    slowlyFireMyAreaWindow(html);
}

// Devuelve el tipo de propiedad, usada en la creación del enlace SEO.
function getPropertyType(type) {
    if (type == "1") {
        return _PROPERTY_APARTMENT;
    } else if (type == "2") {
        return _PROPERTY_HOUSE;
    } else {
        return 'NA';
    }
}

// SINOPSIS
// Crea una propiedad en base a respuesta de query
// INPUT
// responseText - resultado de query ajax, en state = 4
// KNOWN BUGS
// Unificar y usar en maps_google_user_2.js tambien!
// BITACORA 
// GB 23-04-2008 Creacion
function createProperty( arrTemp )
{
    // alert( "Entrando a createProperty()");
    var p = new PropiedadMapa();
    // p.id = idx;
    p.id = arrTemp[0];
    // en la posision 1 esta la imagen chica o campo deprecado que no se usa mas
    p.type = getPropertyType(arrTemp[1]);
    p.direccion_publica = arrTemp[2];
    p.capacidad = arrTemp[3];
    p.sup_int_mts = arrTemp[4];
    p.ambientes = arrTemp[5];
    p.precio_diario = arrTemp[6]; 
    p.precio_semana = arrTemp[7]; 
    p.precio_mes = arrTemp[8];
    p.latitud = arrTemp[9];
    p.longitud = arrTemp[10];
    p.area = arrTemp[11];
    p.sup_int_pies = arrTemp[12];			
    // gb 23-4-2008 se agreagan estos tres y desplazan a las imagenes
    p.sup_ext_mts = arrTemp[13];
    p.sup_ext_pies = arrTemp[14];
    p.banos = arrTemp[15];
    // gb 23-4-2008 imagenes antes comenzaban en posicion 13
    p.foto1_th = arrTemp[16];
    p.foto2_th = arrTemp[17];				
    p.foto3_th = arrTemp[18];
    p.foto4_th = arrTemp[19];
    p.foto5_th = arrTemp[20];

    return p;
}

// SINOPSIS
// Constructor de objeto Propiedad
// KNOWN BUGS
// BITACORA 
// AG 18-12-2007 Creacion
// GB 18-12-2007 Revision, le faltaria pasar parametros en la creacion
function PropiedadMapa () 
{ 
    this.constructor.population++;  
    var id;
    // var foto_chica;
    var direccion_publica;
    var latitud;
    var longitud;
    var description;
    var capacidad;
    var ambientes;
    var sup_int_mts;
    var sup_int_pies;
    var precio_diario;
    var precio_semana;
    var precio_mes;
    var area;
    // gb 23-4-2008 se agregan estos tres
    var sup_ext_mts;
    var sup_ext_pies;
    var banos;

    var foto1_th;
    var foto2_th;
    var foto3_th;
    var foto4_th;
    var foto5_th;

    this.id = id;
    // this.foto_chica = foto_chica;
    this.direccion_publica = direccion_publica; 
    this.latitud = latitud;
    this.longitud = longitud;
    this.description = description;
    this.capacidad = capacidad;
    this.ambientes = ambientes;
    this.sup_int_mts = sup_int_mts;
    this.sup_int_pies = sup_int_pies;
    this.precio_diario = precio_diario;
    this.precio_semana = precio_semana;
    this.precio_mes = precio_mes;
    this.area = area;
    // gb 23-4-2008 se agregan estos tres
    this.sup_ext_mts = sup_ext_mts;
    this.sup_ext_pies = sup_ext_pies;
    this.banos = banos;

    this.foto1_th = foto1_th;
    this.foto2_th = foto2_th;
    this.foto3_th = foto3_th;
    this.foto4_th = foto4_th;
    this.foto5_th = foto5_th;
} 

// SINOPSIS
// Mueve mapa al centro elegido
function centerMap(areaID) {
    if (areaID && isOutsideBA(areaID)) {
        var newCenter = 0;
        var zoomLevel = INITIAL_ZOOM_LEVEL;
        switch (areaID) {
            case AROUNDBA:
            newCenter = centerAroundBA;
            zoomLevel = INITIAL_ZOOM_LEVEL - 8;
            break;
            case MENDOZA:
            newCenter = centerMendoza;
            zoomLevel = INITIAL_ZOOM_LEVEL - 8;
            break;
            case SALTA:
            newCenter = centerSalta;
            zoomLevel = INITIAL_ZOOM_LEVEL - 8;
            break;
            case BARILOCHE:
            newCenter = centerBariloche;
            zoomLevel = INITIAL_ZOOM_LEVEL - 8;
            break;
            default: 
            newCenter = centerLocation;
            zoomLevel = INITIAL_ZOOM_LEVEL;
            break;
        }
        showAreaPins();
        map.setCenter(newCenter, zoomLevel);
    } else {
        map.setCenter( centerLocation, INITIAL_ZOOM_LEVEL );
    }
}


// SINOPSIS
// Zoom out
function zoomOutMap()
{
    map.zoomOut();
}

// SINOPSIS
// Mueve el mapa para abajo, sensacion de subir
function moveUpMap()
{
    map.panDirection( 0, 1 );
}

// SINOPSIS
// Mueve el mapa a la izquierda, sensacion de moverse a derecha
function moveRightMap()
{
    map.panDirection( -1, 0 );
}

// SINOPSIS
// Mueve el mapa a la derecha, sensacion de moverse a izquierda
function moveLeftMap()
{
    map.panDirection( 1, 0 );
}

// SINOPSIS
// Mueve el mapa a la izquierda, sensacion de moverse a derecha
function moveDownMap()
{
    map.panDirection( 0, -1 );
}

// SINOPSIS
// Zoom In
function zoomInMap()
{
    map.zoomIn();
}

// SINOPSIS
// Setea el zoom level fijo para despues de una seleccion de area
// BITACORA
// 21-06-2010 AVP: Parker pide que, en caso de ser una ciudad fuera de BA, 
// el zoom muestre toda Argentina, con pin y leyenda. Habr�a que ajustar ac� y mostrar el pin.
function setSelectAreaZoomLevel( areaID ) {
    if (isOutsideBA(areaID)) {
        map.setZoom(INITIAL_ZOOM_LEVEL + 1); // ajustar esto.
    } else {
        map.setZoom( INITIAL_ZOOM_LEVEL + 1 );
    }
}

// SINOPSIS
// Solamente se ubica en la posicion del area, todavia no hacemos zoom
// BITACORA
// GB 23-8-2009 Creacion
function drawArea( area )
{
    // alert( "Entrando a drawArea = " + area );
    var point;
    var polyline;
    switch (area) {
        case LASCANITAS:
            point = centerLasCanitas;
            polyline = polyLasCanitas;
            break;
        case PALERMONUEVO:
            point = centerPalermoNuevo;
            polyline = polyPalermoNuevo;
            break;
        case PALERMOHOLL:
            point = centerPalermoHoll;
            polyline = polyPalermoHoll;
            break;
        case PALERMOSOHO:
            point = centerPalermoSoho;
            polyline = polyPalermoSoho;
            break;
        case PUERTOMADERO:
            point = centerPuertoMadero;
            polyline = polyPuertoMadero;
            break;
        case PLAZA:
            point = centerPlaza;
            polyline = polyPlaza;
            break;
        case RECOLETA:
            point = centerRecoleta;
            polyline = polyRecoleta;
            break;
        case SANTELMO:
            point = centerSanTelmo;
            polyline = polySanTelmo;
            break;
        case MENDOZA:
            point = centerMendoza;
            polyline = polyMendoza;
            break;
        case BARILOCHE:
            point = centerBariloche;
            polyline = polyBariloche;
            break;
        case SALTA:
            point = centerSalta;
            polyline = polySalta;
            break;
        case AROUNDBA:
            point = centerAroundBA;
            polyline = polyAroundBA;
            break;
        default:
            point = centerLocation;
            break;

    }
    map.addOverlay(polyline);
    map.panTo(point);
}

// SINOPSIS
// Atrapa evento zoom nuevo. Anda ok pero no usamos aun
// BITACORA 
// GB 21-10-2008 Creacion
function onZoomEnd( oldLevel, newLevel )
{
    // gb mantenemos en memoria el zoom level
    zoomLevel = newLevel;
}

// SINOPSIS
// Atrapa evento click y cambia de nivel de zoom.
// BITACORA 
// GB 17-9-2009 Creacion
// Gb 17-9-2009 No uso. No anda muy bien
function onDoubleClick()
{	
    // alert( "onDoubleClick()"); 
    // map.setZoom( map.getZoom() + 3 );
}

// SINOPSIS
// Muestra pagina de propiedad
// KNOWN BUGS
// Asegurarse que el path sirva en caso de mover la pagina de lugar...
// BITACORA 
// GB 2-3-2008 Creacion en base a AG
function mostrarPropiedad( idx )
{
    location.href="propiedad.php?IA="+idx;
}

// SINOPSIS
// Retorna el nombre de un area
// KNOWN BUGS
// BITACORA 
// GB 12-1-09
function obtenerNombreArea( area )
{
    var name = "";
    switch(area) {
        case LASCANITAS:
        name = NAME_LASCANITAS;
            break;
        case PALERMONUEVO:
        name = NAME_PALERMONUEVO;
            break;
        case PALERMOHOLL:
        name = NAME_PALERMOHOLL;
            break;
        case PALERMOSOHO:
        name = NAME_PALERMOSOHO;
            break;
        case PUERTOMADERO:
        name = NAME_PUERTOMADERO;
            break;
        case PLAZA:
        name = NAME_PLAZA;
            break;
        case RECOLETA:
        name = NAME_RECOLETA;
            break;
        case SANTELMO:
        name = NAME_SANTELMO;
            break;
        case MENDOZA:
        name = NAME_MENDOZA;
            break;
        case BARILOCHE:
        name = NAME_BARILOCHE;
            break;
        case SALTA:
        name = NAME_SALTA;
            break;
        case AROUNDBA:
        name = NAME_AROUNDBA;
            break;
        default:
        name = _UNKNOWN_AREA;
            break;
    }
   
    // alert( name );
    return name;
}

// SINOPSIS
// Retorna el nombre de la foto del area
// KNOWN BUGS
// BITACORA 
// GB 12-1-09
function obtenerNombreFotoArea( area )
{
    var name = "";
    switch(area) {
        case LASCANITAS:
        name = "las-canitas-ok.jpg";
            break;
        case PALERMONUEVO:
        name = "palermo-nuevo-ok.jpg";
            break;
        case PALERMOHOLL:
        name = "palermo-hollywood-ok.jpg";
            break;
        case PALERMOSOHO:
        name = "palermo-soho-ok.jpg";
            break;
        case PUERTOMADERO:
        name = "puerto-madero-ok.jpg";
            break;
        case PLAZA:
        name = "plaza-san-martin-ok.jpg";
            break;
        case RECOLETA:
        name = "recoleta-ok.jpg";
            break;
        case SANTELMO:
        name = "san-telmo-ok.jpg";
            break;
        case MENDOZA:
        name = "mendoza_s.jpg";
            break;
        case BARILOCHE:
        name = "bariloche_s.jpg";
            break;
        case SALTA:
        name = "salta_s.jpg";
            break;
        case AROUNDBA:
        name = "around_ba_s.jpg";
            break;
        default:
        name = "las-canitas-ok.jpg";
            break;

    }

    return name;
}


// SINOPSIS
// Detecta browser
// BITACORA
// gb 10-6-2009 Creacion
function getBrowser()
{
    var browser=navigator.appName;
    var b_version=navigator.appVersion;
    var version=parseFloat(b_version);
    if ( browser == "Microsoft Internet Explorer" && version == 4 ) 
        return "IE6";
    else
        return "NOTIE6";
}

// SINOPSIS
// Guarda valor en una cookie
// BITACORA
// gb 17-6-2009 Creacion
// gb 17-9-2009 *** ATENCION *** Clavo en 30 minutos!
function createCookie(name,value,days) 
{
    if (days) {
        var date = new Date();
        // gb 17-9 clavo en 30 minutos 
        // date.setTime(date.getTime()+(days*24*60*60*1000));
        date.setTime(date.getTime()+(days*30*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

// SINOPSIS
// lee valor de una cookie
// BITACORA
// gb 17-6-2009 Creacion
function readCookie(name) 
{
    // alert( "Entrando a readCookie");
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

// SINOPSIS
// Elimina una cookie
// BITACORA
// gb 17-6-2009 Creacion
function eraseCookie(name) 
{
    createCookie(name,"",-1);
}

// SINOPSIS
// Antigua showProperties
// Rendering the contenido en mapa
// Se agrega nivel incial, donde se muestran pins de areas solamente
// BITACORA
// GB 19-10-2009 creacion
function renderMapContent()
{
    // gb 19-10-2009 agrego nivel de render para pines por areas
    /* gb 27-10-2009 por ahora no */
    if ( getZoomLevel() == INITIAL_ZOOM_LEVEL && noFiltersSelected() ){
        showAreaPins();

    } else {
        showPropertyPins();
    }
}

// SINOPSIS
// true si ningun filtro ha sido seleccionado
// GB 19-10-2009 Creacion
function noFiltersSelected()
{
    return ( obtenerFiltroArea() == 0 && obtenerFiltroPrice() == 0 && obtenerFiltroSize() == 99 && obtenerFiltroFecha() == 0);
}

// SINOPSIS
// Retorna nivel de zoom
function getZoomLevel()
{
    return map.getZoom();
}

// SINOPSIS
// Crea y muestra los pines de area
function showAreaPins()
{
    // borra todos los pines del mapa
    map.clearOverlays();
    centerMap();	
    createAreaMarkers();
    rotarInfowindow();
}

// SINOPSIS
// Trae y muestra propiedades en el mapa
// KNOWN BUGS
// - separar en una funcion que haga el query y otra que muestre
// BITACORA 
// GB 16-12-2007 Creacion
// AG 18-12-2007 Agregado de llamado a funcion AJAX para traer lista de properties
// GB 18-12-2007 Revision, indentado.
// AG 01-03-2008 Agregado de filtros
// GB 18-08-2009 Agrego filtro ciudad
// GB 27-10-2009 le cambio el nombre a showPropertyPins()
// function showProperties()
function showPropertyPins()
{
    // ag 1-3-2008 levantamos valores del filtro
    var filtro_area = obtenerFiltroArea();
    var filtro_price = obtenerFiltroPrice();
    var filtro_bedrooms = obtenerFiltroSize();
    var filtro_ciudad = obtenerFiltroCiudad();
    var filtro_fecha = obtenerFiltroFecha();
    //alert(filtro_area + ' ' + filtro_price + ' ' + filtro_bedrooms + ' ' + filtro_ciudad);

    // gb 1-3-2008 llamada ajax
    var arrTemp  = new Array(); 

    ajax = creaAjax();

    // GB 18-08-2009 paso filtro ciudad
    ajax.open("GET", "AXPropiedades.php?&area="+filtro_area+"&price="+filtro_price+"&bedrooms="+filtro_bedrooms+"&fechadesdehasta="+filtro_fecha, true);

    ajax.onreadystatechange = function() 
    {
        if ( ajax.readyState == 1 ) 
        {
            // alert( "ajax.readyState = 1");
        } 
        else 
            if (ajax.readyState == 4 )
            {
                // alert( "ajax.readyState = 4, response = " + ajax.responseText);
                // Convertir el contenido de ajax en arrays JS
                arrTemp = convertirTextToArray(ajax.responseText);
                // alert( "Despues de convertirTextToArray");

                // Recorro el array de propiedades
                for( i=0; i < arrTemp.length; i++)
                {
                    // gb 30-6-2008 Uso propiedad simplificada
                    var p = new PropiedadMapaUser();
                    // creo cada propiedad
                    p.id  = arrTemp[i][0];
                    // gb 30-6-2008 solo traigo los puntos
                    p.latitud = arrTemp[i][1];
                    p.longitud = arrTemp[i][2];
                    // gb new 16-3
                    p.capacidad = arrTemp[i][3];
                    p.name = arrTemp[i][4];
                    // fin new
                    var point = new GLatLng( p.latitud, p.longitud );
                    addPropertyToMap( map, point, p );
                }

                //////////////////////////////////////////////////////////////////////////////////////////////////
                // gb 1-4-2008 desde aca poner todo lo que queremos hacer al mapa despues de recargar propiedades!
                /////////////////////////////////////////////////////////////////////////////////////////////////

                // Si se hizo cualquier busqueda...
                // alert( "Area = " + filtro_area + " Precio = " + filtro_price + " Bedrooms " + filtro_bedrooms);
                if ( filtro_area > 0 || filtro_price > 0 || filtro_bedrooms < 99  || filtro_fecha !== 0)
                {
                    // GB 10-2-2009 - Si hay seleccion apago la rotacion
                    apagarRotarInfowindow();

                    // Si se selecciono el area, muestro el perimetro
                    if ( filtro_area > 0 )
                    {
                        // gb 13-11 le paso el area setSelectAreaZoomLevel();
                        setSelectAreaZoomLevel( filtro_area);
                        drawArea( filtro_area );
                        // gb 13-12-2009
                        showNeighborhoodDescription( filtro_area );					
                    }
                    // gb 9-6-2008 si se deselecciono el area, centro el mapa
                    else
                        centerMap();

                    // gb 13-12-2009 muestro la primera propiedad de la busqueda si existe
                    if ( arrTemp.length > 0 )
                    {
                        mostrarMensaje(_CLICK_PINS);
                        if ( filtro_area == 0 )
                            mostrarInfowindow( arrTemp[0][0], FAST, 0 );
                    }
                    else
                    {
                        mostrarMensaje(_NO_PROPERTIES);
                        if ( filtro_area == 0 )
                            mostrarInfowindow( rotatingProperties[0], FAST, 0 );
                    }

                }
                // Si no se hicieron busquedas, muestro una propiedad default en la infowindow  
                else
                {
                    // alert( "En filtrarPropiedades(), fuera de cualquier busqueda");
                    // gb 9-6-2008 tambien centro el mapa
                    centerMap();
                    // gb 13-12-2009
                    rotarInfowindow();
                }
            }
    } 
    ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    ajax.send(null);
}

// obtiene el filtro de area actualmente seteado
function obtenerFiltroArea()
{
    // gb 17-6-2009
    if ( filtroArea == 0 )
    {
        filtroArea = readCookie( "filtroArea" );
        if ( filtroArea == null )
            filtroArea = 0;
        else
        {
            // alert( "En obtenerFiltroArea(), antes de setFiltroArea()" );
            setFiltroArea( filtroArea );
        }
    }
    // fin gb 17-6
    // alert ( "En obtenerFiltroArea, filtro area = " + filtroArea);
    return filtroArea;
}

// Obtiene el filtro de precio actualmente seteado
function obtenerFiltroPrice()
{
    // gb 17-6-2009
    if ( filtroPrice == 0 )
    {
        filtroPrice = readCookie( "filtroPrice" );
        if ( filtroPrice == null )
            filtroPrice = 0;
        else
            setFiltroPrice( filtroPrice );
    }
    // fin gb 17-6
    return filtroPrice;
}

// Obtiene el filtro de tamaño actualmente seteado
function obtenerFiltroSize()
{
    if ( filtroSize == 99 )
    {
        filtroSize = readCookie( "filtroSize" );
        if ( filtroSize == null )
            filtroSize = 99;
        else
            setFiltroSize( filtroSize );
    }
    // fin gb 17-6
    return filtroSize;
}

//Obtiene el filtro la fecha desde actualmente seteada
function obtenerFiltroFechaDesde()
{

    filtroFechaDesde = readCookie( "filtroFechaDesde" );

    if ( filtroFechaDesde =="0")
    {
        filtroFechaDesde = readCookie( "filtroFechaDesde" );

        if (filtroFechaDesde==null)
            filtroFechaDesde = 0;
        else
            setFiltroFechaDesde( filtroFechaDesde );
    }

    return filtroFechaDesde;
}

//Obtiene el filtro la fecha hasta actualmente seteada
function obtenerFiltroFechaHasta()
{

    filtroFechaHasta = readCookie( "filtroFechaHasta" );

    if ( filtroFechaHasta == 0)
    {
        filtroFechaHasta = readCookie( "filtroFechaHasta" );

        if (filtroFechaHasta==null)
            filtroFechaHasta = 0;
        else
            setFiltroFechaHasta( filtroFechaHasta );
    }

    return filtroFechaHasta;
}



//Obtiene el filtro la fecha actualmente seteada
function obtenerFiltroFecha()
{

    //filtroFecha = readCookie( "filtroFecha" );

    if ( filtroFecha ==0)
    {
        filtroFecha = readCookie( "filtroFecha" );

        if (filtroFecha==null)
            filtroFecha = 0;
        else
            setFiltroFecha( filtroFecha );
    }

    return filtroFecha;
}

//Setea el fitro de Fecha
function setFiltroFechaDesde( valor )
{

    //Recibie los valores de los parametro buscados
    filtroFechaDesde = valor;

    document.getElementById("desde").innerHTML = fechaToString(filtroFechaDesde);
    createCookie("filtroFechaDesde",valor,1);

}

//Setea el fitro de Fecha
function setFiltroFechaHasta( valor )
{

    //Recibie los valores de los parametro buscados
    filtroFechaHasta = valor;

    document.getElementById("hasta").innerHTML = fechaToString(filtroFechaHasta);
    createCookie("filtroFechaHasta",valor,1);

}

//Setea el filtro de Fecha
function setFiltroFecha( valor )
{
    //Recibe los valores de los parametros buscados
    filtroFecha = valor;

    //document.getElementById("select-fecha").innerHTML = fechaToString(filtroFecha);
    createCookie("filtroFecha",valor,1);

}

// Traduce la fecha a string
function fechaToString( valorFecha )
{

    if (valorFecha !=="0")
        return '<span class="filter-option-selected-fecha">' + valorFecha + '</span>';
    else
        return '<span class="filter-option-not-selected">Search by Dates</span>';


}


// Obtiene la ciudad actualmente seleccionada (ES FIJA PARa TODA LA APLICACION!)
function obtenerFiltroCiudad()
{
    return BA;
}

// SINOPSIS
// Constructor de objeto Propiedad
// KNOWN BUGS
// BITACORA 
// AG 18-12-2007 Creacion en base a PropiedadMapa en common
function PropiedadMapaUser() 
{ 
    var id;
    var longitud;
    var latitud;
    var capacidad;
    var name;

    this.id = id;
    this.latitud = latitud;   
    this.longitud = longitud;
    // new gb 16-3
    this.capacidad = capacidad;
    this.name = name;
}

function getPropertyType(type) {
    if (type == 1) {
        return _PROPERTY_APARTMENT;
    } else if (type == 2) {
        return _PROPERTY_HOUSE;
    } else {
        return 'NA';
    }
}


// SINOPSIS
// Agregar una propiedad al mapa
// KNOWN BUGS
// BITACORA 
// GB 17-12-2007 Creacion
// GB 18-12-2007 Completar HTML en base a parametros
// GB 20-02-2008 Nueva interfase
// function addPropertyToMap( map, point, idx, direccion_publica )
function addPropertyToMap( map, point, property )
{
    var marker = createMarker( point, property.id, composeTooltip(property) );
    map.addOverlay(marker);
}

// SINOPSIS
// Arma el texto del tooltip
// KNOWN BUGS
// BITACORA 
// GB 16-03-2009 Creacion
function composeTooltip( property )
{
    // gb 24-10-2009
    return property.name;
    // return "Name: " + property.name + "  -  Click to view";
    // gb 17-9-2009 esto no anda
    // return "<p>Name: " + property.name + "<br/> Click to view</p>";
}

// SINOPSIS
// A function to create the marker and set up the event window
// KNOWN BUGS
// Dont try to unroll this function. It has to be here for the function closure
// Each instance of the function preserves the contends of a different instance
// of the "marker" and "html" variables which will be needed later when the event triggers.    
// INPUT 
// point - coordenadas donde ubicar el marker
// html - contenido de la ventana que se abre al "estimular" el marker
// windowTitle - titulo de la ventana
// BITACORA 
// GB 16-12-2007 Creacion
// GB 30-6-2008  Para mayor reuso de codigo
// function createMarker( point, html, windowTitle ) 
// function createMarker( point, idx, windowTitle ) 
function createMarker( point, idx, toolTip ) 
{
    // gb 23-3-2008 ponemos icono en azul, ver si sacar esto afuera para hacer mas eficiente
    var icon = new GIcon();
    // alert( "On createMarker(), visited properties = " + visitedProperties );
    // gb 13-7-2009 grayed properties
    if ( visitedProperties.indexOf(idx) >= 0 )
    {
        icon.image = "images/map-pin-gray-med-small-2.gif";
    }
    else
    {
        icon.image = "images/map-pin-blu-med-small-2.gif";
    }

    icon.iconSize = new GSize(11, 27);
    icon.iconAnchor = new GPoint(6, 27);

    markerOptions = { icon:icon, title:toolTip };	
    // Set up our GMarkerOptions object
    var marker = new GMarker( point, markerOptions );

    // gb 3-6 prueba
    
    GEvent.addListener( marker, "click", function() {

            apagarRotarInfowindow();

            // gb 13-12-2009
            alertMessageOff();

            mostrarInfowindow( idx, FAST, 1 );
            });
    return marker;
}

// SINOPSIS
// Apaga la rotacion de propiedades en el infowindow 
// ASSUPTIONS & BUGS
// Usa variable glbal timeoutId
// BITACORA
// GB 10-2-2008 Creacion
function apagarRotarInfowindow()
{
    clearTimeout( timeoutId );
}

// SINOPSIS
// Agregar una propiedad al mapa
// KNOWN BUGS
// BITACORA 
// GB 17-12-2007 Creacion
// GB 18-12-2007 Completar HTML en base a parametros
// GB 20-02-2008 Nueva interfase
// GB 23-4-2008 Nuevo layout
function buildInfowindowContent( property )
{
    // alert( "Entrando a buildInfowindowContent()");

    sIdx = new String(property.id);
    //var newMoreUrl = 'propiedad.php?IA='+sIdx;
    var newMoreUrl = property.area.toLowerCase().replace(' ','-').replace(' ','-')+'/'+property.type+'-'+property.ambientes+'bedrooms-'+sIdx+'.html';

    // gb 10-9-2009 esto ahora es otro dominio!
    // var prefix = '../'+ pictureDirectory() + '/';
    var prefix = 'http://www.'+ pictureDirectory() + '.com/';

    var urlImagen1 = prefix + 'inmmo/upload/INMO/' + property.foto1_th;
    var urlImagen2 = prefix + 'inmmo/upload/INMO/' + property.foto2_th;
    var urlImagen3 = prefix + 'inmmo/upload/INMO/' + property.foto3_th;
    var urlImagen4 = prefix + 'inmmo/upload/INMO/' + property.foto4_th;
    var urlImagen5 = prefix + 'inmmo/upload/INMO/' + property.foto5_th;

    // gb 23-4-2008 calculo la superficie total
    var sup_total_mts = parseInt(property.sup_int_mts) + parseInt(property.sup_ext_mts);
    // alert( property.sup_int_mts + property.sup_ext_mts);
    var sup_total_pies = parseInt(property.sup_int_pies) + parseInt(property.sup_ext_pies);
    // alert( property.sup_int_pies + property.sup_ext_pies);

    // alert (urlImagen1 + " " + urlImagen2 + " " + urlImagen3 + " " + urlImagen4 + " " + urlImagen5);

    // esto es importante sino da undefined
    var myHtml="";

    // gb 31-3-2009 cambio font
    // gb 10-7-2009 simplifico codigo
    // gb 17-9
    // myHtml += '<span id="styled-popup-title">'+property.direccion_publica+'</span>';
    myHtml += '<span class="styled-popup-title">'+property.direccion_publica+'</span>';

    // IMAGENES

    // PRIMERA
    // gb 5-6-, antes relative, top 10
    if( property.foto1_th )
    {
        myHtml += '<div style="width:205px; height:140px; background-color:#999999; text-align:center; position: absolute; left: 15px; top: 40px">';
        myHtml += '<img src="'+urlImagen1+'" style="height:140px; width:205px; overflow:hidden; border: none" usemap="#p1"></img>';
        myHtml += '<map name="p1">';
        myHtml += '<area shape="rect" coords="0,0,205,140" href="propiedad.php?IA='+sIdx+'" />';
        myHtml += '</map>';
        myHtml += '</div>';
    }

    if( property.foto2_th )
    {
        myHtml += '<div style="width:100px; height:65px; background-color:#999999; text-align:center; position: absolute; left: 15px; top: 200px; border:none">';
        myHtml += '<img src="'+urlImagen2+'" style="height:65px; width:100px; border:none" usemap="#p2"></img>';
        myHtml += '<map name="p2">';
        myHtml += '<area shape="rect" coords="0,0,65,100" href="propiedad.php?IA='+sIdx+'" />';
        myHtml += '</map>';
        myHtml += '</div>';
    }

    if( property.foto3_th )
    {
        myHtml += '<div style="width:100px; height:65px; background-color:#999999; text-align:center; position: absolute; left: 120px; top: 200px">';
        myHtml += '<img src="'+urlImagen3+'" style="height:65px; width:100px; overflow:hidden; border:none" usemap="#p3"></img>';
        myHtml += '<map name="p3">';
        myHtml += '<area shape="rect" coords="0,0,65,100" href="propiedad.php?IA='+sIdx+'" />';
        myHtml += '</map>';
        myHtml += '</div>';
    }

    if( property.foto4_th )
    {
        myHtml += '<div style="width:100px; height:65px; background-color:#999999; text-align:center; position: absolute; left: 15px; top: 273px">';
        myHtml += '<img src="'+urlImagen4+'" style="height:65px; width:100px; overflow:hidden; border:none" usemap="#p4"></img>';
        myHtml += '<map name="p4">';
        myHtml += '<area shape="rect" coords="0,0,65,100" href="propiedad.php?IA='+sIdx+'" />';
        myHtml += '</map>';
        myHtml += '</div>';
    }

    // QUINTA
    if( property.foto5_th )
    {
        myHtml += '<div style="width:100px; height:65px; background-color:#999999; text-align:center; position: absolute; left: 120px; top: 273px">';
        myHtml += '<img src="'+urlImagen5+'" style="height:65px; width:100px; overflow:hidden; border:none" usemap="#p5"></img>';
        myHtml += '<map name="p5">';
        myHtml += '<area shape="rect" coords="0,0,65,100" href="propiedad.php?IA='+sIdx+'" />';
        myHtml += '</map>';
        myHtml += '</div>';
    }

    // features de la propiedad
    myHtml += '<table align="justify" class="styled-popup-info">';

    // location va ahora centrado en la primera linea
    myHtml += '<tr>';		
    myHtml += '<td colspan="2" style="text-align: center">';		
    myHtml += '<span style="font-size:14px"><b>'+_LOCATION+':</b> ' + property.area + '</span>' + '<br />'; 
    myHtml += '</td>';		
    myHtml += '</tr>';

    // la siguente linea con dos columnas
    myHtml += '<tr>';		
    myHtml += '<td>';		
    if ( property.ambientes == 0 )
        myHtml += '<b>'+_BEDROOMS+':</b> ' + ' Studio' + '<br />'; 
    else
        myHtml += '<b>'+_BEDROOMS+':</b> &nbsp;&nbsp;&nbsp;' + property.ambientes + '<br />';
    myHtml += '<b>'+_BATHROOMS+':</b> &nbsp;&nbsp;' + property.banos + '<br />';
    // gb 5-11-2009
    if ( sup_total_mts != 0 )
        myHtml += '<b>'+_SIZE+':</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + sup_total_mts + 'm2 (' + sup_total_pies + 'ft2)<br />';
    else	
        myHtml += '<b>'+_SIZE+':</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + 'N/A<br />';
   

    /* gb 17-9
       myHtml += '<td>';
       myHtml += '<b>Daily:</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;US$ ' + property.precio_diario + '<br />'; 
       myHtml += '<b>Weekly:</b> &nbsp;&nbsp;US$ ' + property.precio_semana + '<br />'; 
       myHtml += '<b>Monthly:</b> US$ ' + property.precio_mes + '<br />'; 
       myHtml += '</td>';
       */

    
    myHtml += '<b>'+_DAILY+':</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + formatCurrency(property.precio_diario) + '<br />';
    myHtml += '<b>'+_WEEKLY+':</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + formatCurrency(property.precio_semana) + '<br />';
    myHtml += '<b>'+_MONTHLY+':</b> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + formatCurrency(property.precio_mes) + '<br />';
    myHtml += '</td>';

    myHtml += '</tr>';

    myHtml += '</table>';		

    myHtml += '<br />';
    myHtml += '<br />';

    myHtml += '<a href=' + newMoreUrl + ' class="styled-popup-more-button">';
    myHtml += '<img src="images/see-more.png">';
    // myHtml += 'View Full Property Details';
    myHtml += '</a>';

    return myHtml;
}

// SINOPSIS
// Rota propiedades en la infowindow
// ASSUPTIONS & BUGS
// Como en Testing y en Produccion difieren los ids, los tenemos que clavar a mano...
// BITACORA
// GB 23-4-2008 Creacion
// GB 10-2-2009 Agregamos rotacion
function openDefaultProperty()
{
    rotarInfowindow();
}

// SINOPSIS
// Rota la propiedad en la infowindow
// ASSUPTIONS & BUGS
// BITACORA
// GB 10-2-2008 Creacion
function rotarInfowindow()
{
    // GB 13-12-2009 con esto aseguro que haya un solo thread?
    // alert( "Entering rotarInfowindow()");
    apagarRotarInfowindow();
    propiedadId = obtenerProximaPropiedad();
    mostrarInfowindow(propiedadId, FAST, 0);
    timeoutId = setTimeout('rotarInfowindow()', rotatingTime);	
}

// SINOPSIS
// Rota al area en la infowindow de areas
// ASSUPTIONS & BUGS
// BITACORA
// GB 16-9-2008 Creacion
function rotarAreaWindow()
{
    // alert( "En rotarAreaWindow()");
    areaId = obtenerProximaArea();
    // ojo aca
    showNeighborhoodDescription( areaId, "", "areawindow" );
    timeoutIdArea = setTimeout('rotarAreaWindow()', 10000 );	
}

// SINOPSIS
// Obtiene la proxima propiedad a rotar 
// ASSUPTIONS & BUGS
// las propiedades estan fijas por id
// BITACORA
// GB 10-2-2008 Creacion
function obtenerProximaPropiedad()
{
    // alert( "nextPropertyIndex = " + nextPropertyIndex );
    // alert( "rotatingProperties.length = " + rotatingProperties.length );
    if ( nextPropertyIndex >= rotatingProperties.length )
        nextPropertyIndex = 0;
    // alert( "Proxima propiedad = " + rotatingProperties[nextPropertyIndex] );
    var propiedadId = rotatingProperties[nextPropertyIndex++];
    return propiedadId;
}

// SINOPSIS
// Obtiene la proxima area a rotar 
// ASSUPTIONS & BUGS
// las areas estan fijas por id
// BITACORA
// GB 16-9-2009 Creacion
function obtenerProximaArea()
{
    if ( nextAreaIndex >= rotatingAreas.length )
        nextAreaIndex = 0;
    // alert( "Proxima propiedad = " + rotatingProperties[nextPropertyIndex] );
    var areaId = rotatingAreas[nextAreaIndex++];
    return areaId;
}

// SINOPSIS
// Muestra propiedades en el mapa teniendo en cuenta filtros
// KNOWN BUGS
// - Solo carga la propiedad de Pza. San Martin como ejemplo, falta el resto
// - Tambien habria que ver como implementar toda la estructura de filtros
// BITACORA 
// GB 1-3-2008 Creacion en base a AG
// function filtrarProperties()
function filtrarPropiedades()
{
    // alert( "En filtrarPropiedades(): entrando" );
    // Borrar los markers
    map.clearOverlays();
    renderMapContent();
}


//Eventos de seleccion de fecha en el calendario:
//Destruye el calendario y llama a filtrarPropiedades
function handleCalendarSelectStart(){
   if(Calendar._C){
       Calendar._C.destroy();
       if(document.getElementById("desde").value != "dd-mm-yyyy" && document.getElementById("hasta").value != "dd-mm-yyyy"){
           filtrarPropiedades();
       }
   }
}
function handleCalendarSelectEnd(){
   if(Calendar._C){
       Calendar._C.destroy();
       if(document.getElementById("desde").value != "dd-mm-yyyy" && document.getElementById("hasta").value != "dd-mm-yyyy"){
           filtrarPropiedades();
       }
   }
}

// SINOPSIS
// Muestra la descripcion del area selecionada
// ASSUMPTIONS & BUGS
// Usamos la Infowindow
// BITACORA
// gb 12-1-2009 creacion
// gb 16-9 se puede mostrar en otra ventana
// gb 13-12-2009 simplifico esta
// function showNeighborhoodDescription( area, mensaje, donde )
function showNeighborhoodDescription( area )
{
    // sIdx = new String(area);
    // esto es importante sino da undefined
    var closeUrl = 'javascript:fadeOutMyPopup();';
    // alert( area );
    var areaName = obtenerNombreArea( area );
    // gb 10-7-2009 for testing, usar con conexion a base de produccion
    var prefix;
    prefix = '';

    // var areaPictureName = '../oasistest' + '/images/area' + '/' + obtenerNombreFotoArea( area );
    // var areaPictureName = '../images/area/' + obtenerNombreFotoArea( area );
    var areaPictureName = prefix + 'images/area/' + obtenerNombreFotoArea( area );
    // alert( areaPictureName );
    var myHtml="";

    // gb version 8
    // gb 17-9
    // myHtml += '<span id="styled-popup-title">'+areaName+'</span>';
    myHtml += '<span class="styled-popup-title">'+areaName+'</span>';

    // AREA IMAGE
    myHtml += '<div style="position: absolute; top: 35px; left: 15px;">';
    myHtml += '<img src="'+areaPictureName+'" style="height:140px; width:205px; overflow:hidden; border: none" usemap="#p1"></img>';
    myHtml += '<map name="p1">';
    myHtml += '<area shape="rect" coords="0,0,205,140" href="#" />';
    myHtml += '</map>';
    myHtml += '</div>';

    // Area Description	
    myHtml += '<div style="position:absolute; top:185px; left: 15px;  font-family:helvetica,sans-serif; font-size:11px; color:#0A1F62; text-align:justify; width: 205px">';

    myHtml += obtenerDescripcionArea( area );

    myHtml += '</div>';

    abrirInfowindow(myHtml, SLOW);
}

// SINOPSIS
// Obtiene la descripcion de un area/barrio
// KNOWN BUGS
// BITACORA 
// GB 2-2-2009 Creacion

function obtenerDescripcionArea( area )
{
    var myHtml = "";

    switch(area) {
        case LASCANITAS:
            myHtml += _TEXTO_LASCANITAS;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_LASCANITAS;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_LASCANITAS;			
            myHtml += '</div>';

            break;

        case PALERMONUEVO:
            myHtml += _TEXTO_PALERMONUEVO;
            myHtml += '<div style="position:relative; top:3px;">';		
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_PALERMONUEVO;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_PALERMONUEVO;
            myHtml += '</div>';
            break;

        case PALERMOHOLL:
            myHtml += _TEXTO_PALERMOHOLL;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_PALERMOHOLL;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_PALERMOHOLL;
            myHtml += '</div>';
            break;

        case PALERMOSOHO:
            myHtml += _TEXTO_PALERMOSOHO;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_PALERMOSOHO;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+':&nbsp;</strong>';
            myHtml += _HIGHLIGHTS_PALERMOSOHO;
            myHtml += '</div>';
            break;

        case PUERTOMADERO:
            myHtml += _TEXTO_PUERTOMADERO;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_PUERTOMADERO;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_PUERTOMADERO;
            myHtml += '</div>';
            break;		

        case PLAZA:
            myHtml += _TEXTO_PLAZA;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_PLAZA;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_PLAZA;
            myHtml += '</div>';
            break;

        case RECOLETA:
            myHtml += _TEXTO_RECOLETA;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_RECOLETA;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_RECOLETA;
            myHtml += '</div>';
            break;

        case SANTELMO:
            myHtml += _TEXTO_SANTELMO;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_SANTELMO;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_SANTELMO;
            myHtml += '</div>';
            break;
        // Mendoza
        case MENDOZA:
            myHtml += _TEXTO_MENDOZA;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_MENDOZA;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_MENDOZA;
            myHtml += '</div>';
            break;
        // Bariloche
        case BARILOCHE:
            myHtml += _TEXTO_BARILOCHE;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_BARILOCHE;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_BARILOCHE;
            myHtml += '</div>';
            break;
        // Salta
        case SALTA:
            myHtml += _TEXTO_SALTA;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_SALTA;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_SALTA;
            myHtml += '</div>';
            break;
        //Around BA
        case AROUNDBA:
            myHtml += _TEXTO_AROUNDBA;
            myHtml += '<div style="position:relative; top:3px;">';
            myHtml += '<strong>'+_LOCATION+': </strong>';
            myHtml += _LOCATION_AROUNDBA;
            myHtml += '</div>';
            myHtml += '<div style="position:relative; top:6px;">';
            myHtml += '<strong>'+_HIGHLIGHTS+': </strong>';
            myHtml += _HIGHLIGHTS_AROUNDBA;
            myHtml += '</div>';
            break;

        default:
            myHtml = _UNKNOWN_AREA;
            break;
    }

    return myHtml;
}

// Setea el fitro de area
function setFiltroArea( valor )
{
    filtroArea = valor;
    /* gb 15-5-2009 no en la version con filtros tipografia diseño 	*/
    document.getElementById("select-area").innerHTML = areaToString(valor);
    // gb 17-6-2009
    // alert ("En setFiltroArea, valor = " + valor + ", select-area = " + areaToString(valor));
    // gb 16-9 cookie por un dia solo!
    // createCookie("filtroArea",valor,0);
    createCookie("filtroArea", valor, 1);
}

// Traduce el codigo de area a string
function areaToString( valor )
{
    var namestr = '<span class="filter-option-not-selected">'+_SEARCH_BYAREA+'</span>';
    switch (valor) {
        case LASCANITAS:
            namestr = '<span class="filter-option-selected">'+NAME_LASCANITAS+'</span>';
            break;
        case PALERMONUEVO:
            namestr = '<span class="filter-option-selected">'+NAME_PALERMONUEVO+'</span>';
            break;
        case PALERMOHOLL:
            namestr = '<span class="filter-option-selected">'+NAME_PALERMOHOLL+'</span>';
            break;
        case PALERMOSOHO:
            namestr = '<span class="filter-option-selected">'+NAME_PALERMOSOHO+'</span>';
            break;
        case PUERTOMADERO:
            namestr = '<span class="filter-option-selected">'+NAME_PUERTOMADERO+'</span>';
            break;
        case PLAZA:
            namestr = '<span class="filter-option-selected">'+NAME_PLAZA+'</span>';
            break;
        case RECOLETA:
            namestr = '<span class="filter-option-selected">'+NAME_RECOLETA+'</span>';
            break;
        case SANTELMO:
            namestr = '<span class="filter-option-selected">'+NAME_SANTELMO+'</span>';
            break;
        case MENDOZA:
            namestr = '<span class="filter-option-selected">'+NAME_MENDOZA+'</span>';
            break;
        case BARILOCHE:
            namestr = '<span class="filter-option-selected">'+NAME_BARILOCHE+'</span>';
            break;
        case SALTA:
            namestr = '<span class="filter-option-selected">'+NAME_SALTA+'</span>';
            break;
        case AROUNDBA:
            namestr = '<span class="filter-option-selected">'+NAME_AROUNDBA+'</span>';
            break;
        default:
            namestr = '<span class="filter-option-not-selected">'+_SEARCH_BYAREA+'</span>';
            break;
    }
    return namestr;
}

// Setea el filtro de precio
function setFiltroPrice( valor )
{
    filtroPrice = valor;
    // gb 15-5-2009 no en la version con filtros tipografia diseño
    document.getElementById("select-price").innerHTML = precioToString(valor);
    // gb 17-6-2009
    // gb 16-9 cookies por un dia solo
    // createCookie("filtroPrice",valor,0);
    createCookie("filtroPrice",valor,1);
}

// Traduce el codigo de precio a string
function precioToString( valor )
{
    var preciostr = '<span class="filter-option-not-selected">'+_SEARCH_BYPRICE+'</span>';
    switch (valor) {
        case 1:
        case "1":
            preciostr = '<span class="filter-option-selected">'+_PRICE_1+'</span>';
            break;
        case 2:
        case "2":
            preciostr = '<span class="filter-option-selected">'+_PRICE_2+'</span>';
            break;
        case 3:
        case "3":
            preciostr = '<span class="filter-option-selected">'+_PRICE_3+'</span>';
            break;
        case 4:
        case "4":
            preciostr = '<span class="filter-option-selected">'+_PRICE_4+'</span>';
            break;
        case 5:
        case "5":
            preciostr = '<span class="filter-option-selected">'+_PRICE_5+'</span>';
            break;
        case 6:
        case "6":
            preciostr = '<span class="filter-option-selected">'+_PRICE_6+'</span>';
            break;
        default:
            preciostr = '<span class="filter-option-not-selected">'+_SEARCH_BYPRICE+'</span>';
            break;

    }
    return preciostr;
}

// Setea el filtro de tamaño (en variable global)
function setFiltroSize( valor )
{
    filtroSize = valor;
    // gb 15-5-2009 no en la version con filtros tipografia diseño
    document.getElementById("select-size").innerHTML = sizeToString(valor);
    // gb 17-6-2009
    // gb cookies por un dia solo
    // createCookie("filtroSize",valor,0);
    createCookie("filtroSize",valor,1);
}

// Traduce el codigo de tamaño a string
function sizeToString( valor )
{
    var sizestr = '<span class="filter-option-not-selected">'+_SEARCH_BYSIZE+'</span>'
    switch (valor) {
        case 0:
        case "0":
            sizestr = '<span class="filter-option-selected">'+_SIZE_0+'</span>';
            break;
        case 1:
        case "1":
            sizestr = '<span class="filter-option-selected">'+_SIZE_1+'</span>';
            break;
        case 2:
        case "2":
            sizestr = '<span class="filter-option-selected">'+_SIZE_2+'</span>';
            break;
        case 3:
        case "3":
            sizestr = '<span class="filter-option-selected">'+_SIZE_3+'</span>';
            break;
        default:
            sizestr = '<span class="filter-option-not-selected">'+_SEARCH_BYSIZE+'</span>';
            break;
    }
    return sizestr;
}

// SINOPSIS
// Setea los combos en cero y vuelve a hacer la busqueda
// Centra el mapa?
// BITACORA
// gb 26-4-2009 Tambien vuelve a rotar las propiedades
function clearSearch()
{
    // alert( "En clearSearch(): entrando" );
    // gb 23-10
    alertMessageOff();

    setFiltroArea( 0 );
    setFiltroPrice( 0 );
    setFiltroSize( 99 );
    setFiltroFecha(0);
    document.getElementById('desde').value = 'dd-mm-yyyy';
    document.getElementById('hasta').value = 'dd-mm-yyyy';

    centerMap();	// con esto dirijo el renderMapContent()
    renderMapContent();
    // gb 13-12-2009
    rotarInfowindow();
}


function sendFecha()
{

    //Recuperamos los valores cargados en el toolTip
    fecha_desde1 = document.getElementById('desde').value;
    fecha_hasta1 = document.getElementById('hasta').value;


    y_desde = fecha_desde1.substr(0,4);
    m_desde = fecha_desde1.substr(5,2);
    d_desde = fecha_desde1.substr(8,2);
    fecha_desde = ( d_desde + "-" + m_desde + "-" + y_desde);

    y_hasta = fecha_hasta1.substr(0,4);
    m_hasta = fecha_hasta1.substr(5,2);
    d_hasta = fecha_hasta1.substr(8,2);
    fecha_hasta = ( d_hasta + "-" + m_hasta + "-" + y_hasta);

    if (fecha_desde=="dd-mm-yyyy" || fecha_hasta=="dd-mm-yyyy")
    {
        //document.getElementById("message-SearchByDate").innerHTML = "You must enter dates From / To";
        //alert("false 1 ");
        return false;
    }
    if (fecha_desde=="" || fecha_hasta=="")
    {
        //document.getElementById("message-SearchByDate").innerHTML = "You must enter dates From / To";
        //alert("false 2");
        return false;
    }
    
    //Se comento ya que funciona incorrectamente 02-05-2010
    //valoresFechas = validarIntervaloFechas(fecha_desde, fecha_hasta);
    //if (valoresFechas == false)
    //{
    //    return false;
    //}

    //Seteamos el filtro para las fecha comprendidas
    // setFiltroFechaDesde(fecha_desde);
    // setFiltroFechaHasta(fecha_hasta);

    //concatenamos para manejar solo un valor
    valorConcat=fecha_desde+"|"+fecha_hasta;
    setFiltroFecha(valorConcat);


    //alert(fecha_desde);
    //ocultamos el toolTip
    //Ext.getCmp('content-anchor-tip').hide();

}

function validarIntervaloFechas(fechaDesde, fechaHasta)
{
    arrFechaDesde = fechaDesde.split('-');
    arrFechaHasta = fechaHasta.split('-');

    fechaErr = false;

    if (arrFechaDesde[0] > arrFechaHasta[0]) {
        fechaErr = true;
    }
    else {
        if(arrFechaDesde[0] == arrFechaHasta[0]) {
            if (arrFechaDesde[1] > arrFechaHasta[1]) {
                fechaErr = true;
            }
            else {
                if (arrFechaDesde[1] == arrFechaHasta[1]) {
                    if (arrFechaDesde[2] > arrFechaHasta[2]) {
                        fechaErr = true;
                    }
                }
            }
        }
    }

    if (fechaErr) {
        //document.getElementById("message-SearchByDate").innerHTML = "From the date can not be more up to date";
        return false;
    }

    return true;
}

/*
Ext.onReady(function(){
    new Ext.ToolTip({
        title: '&nbsp; ',
        id: 'content-anchor-tip',
        target: 'toolTipCall',
        anchor: 'top',
        html: null,
        width: 260,
        autoHide: false,
        closable: false,
        contentEl: 'content-tip', // load content from the page
        listeners: {
            'render': function(){
                this.header.on('click', function(e){
                    e.stopEvent();
                    //Ext.Msg.alert('Link', 'Link to something interesting.');
                    Ext.getCmp('content-anchor-tip').hide();
                }, this, {delegate:'a'});
            }
        }
    });
    Ext.QuickTips.init();
});*/

function closeFecha()
{
    //Seteamos el filtro para las fecha comprendidas
    //setFiltroFechaDesde(0);
    //setFiltroFechaHasta(0);
    setFiltroFecha(0);

    //ocultamos el toolTip
    //Ext.getCmp('content-anchor-tip').hide();
}

// SINOPSIS
// Muestra un mensaje en pantalla
// ASSUMPTIONS & BUGS
// POr ahora usa la infowindow de la home
// BITACORA
// gb 24-4-2008 creacion
// gb 17-9-2009 Saco el color del style asi toma el general
function mostrarMensaje( mensaje )
{
    alertMessageOn( mensaje );
}

// SINOPSIS
// Muestra mensaje en zona de alerta
// BITACORA
// GB 19-10-2009 Creacion
function alertMessageOn( s )
{
    // alert( "En alert Message on ");
    var element = document.getElementById("alert-message");
    element.innerHTML = "<p>"+s+"</p>";
    element.style.display = "block";
}

// SINOPSIS
// Apaga mensaje en zona de alerta
// BITACORA
// GB 19-10-2009 Creacion
function alertMessageOff()
{
    var element = document.getElementById("alert-message");
    element.style.display = "none";
}

// SINOPSIS
// Convierte a formato $$$
// ASSUMPTIONS & BUGS
// BITACORA
// gb 17-9-2009 De la web
function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num))
        num = "0";
    sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10)
        cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
    // return (((sign)?'':'-') + '$' + num + '.' + cents);
    return (((sign)?'':'-') + ((num!=0)?'USD '+num:'N/A'));
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// AREA MARKERS
////////////////////////////////////////////////////////////////////////////////////////////////////

// SINOPSIS
// Crea un marker por Area
// BITACORA 
// GB 14-10-2009 Creacion
function createAreaMarkers()
{	
    // alert( "Debug Message: entering createAreaMarkers()");
    // gb 27-10 no por ahora
    createAreaMarker( centerLasCanitas, LASCANITAS, _CLICK_PROPERTIES + NAME_LASCANITAS);
    createAreaMarker( centerPalermoNuevo, PALERMONUEVO, _CLICK_PROPERTIES + NAME_PALERMONUEVO);
    createAreaMarker( centerPalermoHoll, PALERMOHOLL, _CLICK_PROPERTIES + NAME_PALERMOHOLL);
    createAreaMarker( centerPalermoSoho, PALERMOSOHO, _CLICK_PROPERTIES + NAME_PALERMOSOHO);
    createAreaMarker( centerPuertoMadero, PUERTOMADERO, _CLICK_PROPERTIES + NAME_PUERTOMADERO);
    createAreaMarker( centerPlaza, PLAZA, _CLICK_PROPERTIES + NAME_PLAZA);
    createAreaMarker( centerRecoleta, RECOLETA, _CLICK_PROPERTIES + NAME_RECOLETA);
    createAreaMarker( centerSanTelmo, SANTELMO, _CLICK_PROPERTIES + NAME_SANTELMO);
    createAreaMarker( centerMendoza, MENDOZA, _CLICK_PROPERTIES + NAME_MENDOZA);
    createAreaMarker( centerBariloche, BARILOCHE, _CLICK_PROPERTIES + NAME_BARILOCHE);
    createAreaMarker( centerSalta, SALTA, _CLICK_PROPERTIES + NAME_SALTA);
    createAreaMarker( centerAroundBA, AROUNDBA, _CLICK_PROPERTIES + NAME_AROUNDBA);
}

// SINOPSIS
// A function to create an area marker, add it to the map, and set up the event window
// KNOWN BUGS
// Dont try to unroll this function. It has to be here for the function closure
// Each instance of the function preserves the contends of a different instance
// of the "marker" and "html" variables which will be needed later when the event triggers.    
// INPUT 
// point - coordenadas donde ubicar el marker
// areaId - id del area correspondiente, se corresponde con el utilizado en el filtro
// tooltip - tooltip a mostrar al pasar el mouse por el marker
// BITACORA 
// GB 14-10-2009 Creacion
function createAreaMarker( point, areaId, toolTip ) 
{
    // alert( "Debug Message: entering createAreaMarker()");
    var icon = new GIcon();

    //icon.image = "images/punta/pin-area-bordo-1.png";
    /* 28-10 */ //icon.image = "images/punta/pin-area-bordo-4.png";
    /* 28-10 */ icon.image = "images/map-pin-area-2.gif";

    // para map-pin-area
    icon.iconSize = new GSize(19, 27);
    icon.iconAnchor = new GPoint(10, 26);

    // gb 16-10
    // markerOptions = { icon:icon, title:toolTip };	
    markerOptions = { icon:icon };	

    // Set up our GMarkerOptions object
    var marker = new GMarker( point, markerOptions );

    // filtro desde el area marker
    GEvent.addListener( marker, "click", function() {
            apagarRotarInfowindow();
            setFiltroArea( areaId );
            filtrarPropiedades();
            });

    // gb 16-10 le agrego el tooltip
    var tooltip = new Tooltip(marker,toolTip,10); 
    marker.tooltip = tooltip; 

    // gb 16-10 revisar si esto va aca
    map.addOverlay(marker);
    map.addOverlay(tooltip); 

    GEvent.addListener(marker,'mouseover',function(){ this.tooltip.show(); }); 
    GEvent.addListener(marker,'mouseout',function(){ this.tooltip.hide(); });

    return marker;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////
// TOOLTIPS MODULE
//////////////////////////////////////////////////////////////////////////////////////////////////////////

function Tooltip(marker, text, padding){
    this.marker_ = marker;
    this.text_ = text;
    this.padding_ = padding;
}

Tooltip.prototype = new GOverlay();

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.color = AZUL;
    div.style.background = BLANCO;
    div.style.fontSize='11px';
    div.style.padding='1px';
    div.style.width='99px';
    div.style.height='46px';
    div.style.opacity = 100;
    div.style.filter = 'alpha(opacity=100)';
    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 - this.div_.clientWidth / 2);
    var yPos = markerPos.y - iconAnchor.y - this.div_.clientHeight - this.padding_;
    this.div_.style.top = yPos + 'px';
    this.div_.style.left = xPos + 'px';
}

Tooltip.prototype.show = function(){
    this.div_.style.visibility = 'visible';
}

Tooltip.prototype.hide = function(){
    this.div_.style.visibility = 'hidden';
}
