function GetMoreInfoMapView(i) {
    //document.getElementById("mapcanvas_" + i).style.height = "210px";
   // document.getElementById("mapcanvas_" + i).style.width = "210px";
   
   // Scripps wants this removed for now - Joey Avino - 7/22/09
   //document.getElementById( "mapcanvas_" + i ).parentNode.style.backgroundImage = 'url( /images/listings_map-mapview.png )';
    var mapinfo = document.getElementById("mapinfo_" + i).innerHTML
    var x = mapinfo.indexOf(':');
    var lat = mapinfo.substring(0, x)
    var lng = mapinfo.substring(x + 1, mapinfo.length);
    //alert("mapinfo:" + mapinfo + "\nLat:" + lat + "\nLng:" + lng);

    var map = new GMap2(document.getElementById("mapcanvas_" + i));
    map.setCenter(new GLatLng(lat, lng), 13);

    map.addOverlay(new GMarker(new GLatLng(lat, lng)));

    map.setUIToDefault();
    
    var mapLinkText = '#map_wrapper_'+ i + ' li.mapview > a';
    var streetLinkText = '#map_wrapper_'+ i + ' li.streetview > a';
    $( mapLinkText ).css( { 'color':'#a41d20', 'font-weight':'bold' } );
    $( streetLinkText ).css( { 'color':'#ea6822', 'font-weight':'normal' } );
}

function GetMoreInfoStreetView(i) {
    //document.getElementById("mapcanvas_" + i).style.height = "210px";
    //document.getElementById("mapcanvas_" + i).style.width = "210px";
    document.getElementById( "mapcanvas_" + i ).parentNode.style.backgroundImage = 'url( /images/listings_map-streetview.png )';
    var mapinfo = document.getElementById("mapinfo_" + i).innerHTML
    var x = mapinfo.indexOf(':');
    var lat = mapinfo.substring(0, x)
    var lng = mapinfo.substring(x + 1, mapinfo.length);
    //alert("mapinfo:" + mapinfo + "\nLat:" + lat + "\nLng:" + lng);

    var loc = new GLatLng(lat, lng);
    panoramaOptions = { latlng: loc };
    myPano = new GStreetviewPanorama(document.getElementById("mapcanvas_" + i), panoramaOptions);
    GEvent.addListener(myPano, "error", handleNoFlash);
    
    var mapLinkText = '#map_wrapper_'+ i + ' li.mapview > a';
    var streetLinkText = '#map_wrapper_'+ i + ' li.streetview > a';
    $( mapLinkText ).css( { 'color':'#ea6822', 'font-weight':'normal'  } );
    $( streetLinkText ).css( { 'color':'#a41d20', 'font-weight':'bold' } );
}

function handleNoFlash(errorCode) {
    //alert("errorCode:" + errorCode);
    if (errorCode == 600) {
        alert("Street View is not available for this listing.");
        return;
    }
    if (errorCode == 603) {
        alert("Error: Flash doesn't appear to be supported by your browser.");
        return;
    }
}

function showSortDropDown(){
    document.getElementById( 'listings_sort_selection_drop-down' ).style.display = 'block';
    document.getElementById( 'sort_by_drop-down' ).style.backgroundPosition = "0 -19px";
}

function Results_SortChange( item ){ /* pass sort by item from drop-down pop-up */
    console.log( item );
}

   $(document).ready(function(){
     $( 'span#sort_by_drop-down' ).bind( 'click', function( e ){
            $( 'div#listings_sort_selection_drop-down' ).css( { 'display':'block' } );
               
         } ).css( { 'cursor':'pointer' } );
     $( 'div#listings_sort_selection_drop-down > span.dimensions_close' ).bind( 'click', 
                function( e ){ $( this ).parent().css( { 'display':'none' } ) } );
     $( 'div#listings_sort_selection_drop-down li' ).bind( 'click', function( e ){ Results_SortChange( $( this ).attr( 'id' ) ); } );
   });