﻿/* AXCOLLECTION */

// CollectionSearchType enumeration
var CollectionSearchType = { Tag: 0, Explore: 1 };

var exploreColParameterSet = false;
var _collection_Id = "";
var _collection_type = null;
var collectionExplorerStartIndex = 0;
var collectionExplorerTerm = "";
var tempCollectionSearchType = CollectionSearchType.Explore;
var temporderby = "relevance";
var tempGetIt = "";
var tempColCount = 0;
var exlopereCollections = false;

var axCollection = new Object();

axCollection.DisplayCollections = function(id, type) {
    axSearch.ShowTaskHostLayer("collection");
    if (type == VEDataType.VECollection) {
        axSearch.ShowMessage(L_SHOW_COL_MESSAGE);
    }
    else {
        axSearch.ShowMessage(L_SHOW_COL_MESSAGE + ": " + id);
    }
    _collection_Id = id;
    _collection_type = type;

    axSearch.ShowTaskProgress();

    if (collectionsLayer == null) {
        collectionsLayer = new VEShapeLayer();
    }
    else {
        collectionsLayer.DeleteAllShapes();
    }
    var shapeSpec = new VEShapeSourceSpecification(type, id, collectionsLayer);
    map.ImportShapeLayerData(shapeSpec, onCollectionLoad, true);
}
function onCollectionLoad(feed) {
    axSearch.HideTaskProgress();

    var header = "<div class='ve_viewerBodyHdr'><div class='ve_viewerBodyHdrTitle'>" + feed.GetTitle() + "</div>";
    var date = new Date(feed.DateModified);
    header += "<div>" + feed.GetDescription() + "</div><div class='ve_viewerBodyHdrExtra'>" + L_UPTATED + ": " + date.format("dd/M/yyyy") + "</div></div>";

    var content = "<div><ol class='searchResults'>";
    for (var i = 0; i < feed.GetShapeCount(); i++) {

        var shape = feed.GetShapeByIndex(i);
        var index = i + 1;
        var icon = "<span id='resultPinMap_" + index + "' class='bullet_col' onmouseover='changeColPin(this)' onmouseout='changeColPinBack(this)'>" + index + "</span>";

        var custSpec = axMap.SetCustomIcon(icon, index, 3);
        var existingIcon = shape.IconUrl;
        if (existingIcon) {
            if (existingIcon.indexOf("poi_usergenerated.gif") > 0) {
                shape.SetCustomIcon(custSpec);
            }
        }
        else {
            shape.SetCustomIcon(custSpec);
        }

        var url = shape.GetMoreInfoURL();
        var photo_url = shape.GetPhotoURL();
        var description = shape.GetDescription();
        var pts = shape.GetPoints();

        var footer = "<div class='ftr' style='position:absolute;bottom:3px;background-color:#E4EDF3;left:2px;right:2px;height:55px;padding:4px 8px 0px;'>";
        if (_collection_type == VEDataType.VECollection) {
            var permalink = pageURL + pageName + "?cid=" + _collection_Id;
            footer += "<div><a class='VE_Panel_sublink' href='#' onclick=\"axPage.EmailCollection('" + permalink + "')\">" + L_SEND_PER_EMAIL + "</a><\div>";
        }
        else {
            var permalink = pageURL + pageName + "?mapurl=" + _collection_Id;
            footer += "<div><a class='VE_Panel_sublink' href='#' onclick=\"axPage.EmailCollection('" + permalink + "')\">" + L_SEND_PER_EMAIL + "</a><\div>";
        }
        var driving_directions = "<a href='javascript:_SetDrvDir(" + pts[0].Latitude + "," + pts[0].Longitude + ",\"start\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveFrom + "</a> " + L_OR + " <a href='javascript:_SetDrvDir(" + pts[0].Latitude + "," + pts[0].Longitude + ",\"end\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveTo + "</a>";
        footer += driving_directions + "<div>" + L_ZOOMLEVEL_TYPE + ": <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",16);' class='VE_Panel_sublink'>" + L_STREET + "</a>";
        footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",11);' class='VE_Panel_sublink'>" + L_CITY + "</a>";
        footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",6);' class='VE_Panel_sublink'>" + L_REGION + "</a></div><\div>";

        if (url != "" && url != null) {
            shape.SetDescription(description + "<br/><a target='_blank' href='" + url + "'>" + L_MORE_INFO + "</a><div style='height:70px'></div>" + footer);
        }
        else {
            shape.SetDescription(description + "<br/><div style='height:70px'></div>" + footer);
        }
        shape.SetMoreInfoURL("");
        content += "<li onmouseout='_changeColPinBack(" + index + ")' onmouseover='_changeColPin(" + index + ")'><span class='VE_Pushpin_viewer'>" + index + "</span>";
        content += "<h4 onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",12);'><a href='#'>" + shape.GetTitle() + "</a></h4>";
        content += "<p>";
        if (photo_url != "" && photo_url != null) {
            content += "<a><img class='previewArea-image' src='" + photo_url + "'/></a>";
        }
        if (description != "" && description != null) {
            content += description;
        }
        content += "</p>";
        content += "</li>";
    }
    content += "</ol></div>";
    $get("collections_body").innerHTML += header + content;
}

function ShowZoomInHint(orderby) {
    axSearch.ShowTaskHostLayer("collection");
    $get("collections_body").innerHTML = L_PLEASE + " <a onclick='map.SetZoomLevel(9);SearchCollections(0,CollectionSearchType.Explore,\"" + orderby + "\",false);' style='cursor:pointer;'>" + L_ZOOMIN + " </a>" + L_ZOOM_COL_TEXT;
}
function SearchCollections(index, type, orderby, setMapView) {
    if (!layerLoadEnded) return;

    axSearch.ShowTaskHostLayer("collection");
    axSearch.ShowTaskArea();

    if (type == CollectionSearchType.Tag && index == 0) {
        var a = $get("header_taskBar_collsearch");
        if (a.value == COL_STRING) {
            return;
        }
    }
    if (shapesLayer != null) {
        shapesLayer.DeleteAllShapes();
    }
    var style = map.GetMapStyle();

    var geoCommunityURL = "http://maps.live.com/GeoCommunity.asjx";
    collectionExplorerStartIndex = index;
    tempCollectionSearchType = type;
    temporderby = orderby;
    searchBusinesses = false;
    exlopereCollections = true;
    if (index == 0) {
        tempColCount = 0;
    }
    var view = map.GetMapView();

    var topleft;
    var bottomright;

    var m = map.GetBirdseyeScene();
    if (m != null) {
        var dc = new _xy1;
        topleft = dc.Decode(view.TopLeftLatLong);
        bottomright = dc.Decode(view.BottomRightLatLong);
    }
    else {
        topleft = view.TopLeftLatLong;
        bottomright = view.BottomRightLatLong;
    }

    if (speedCamerasLayer != null) {
        speedCamerasLayer.DeleteAllShapes();
    }
    if (gasStationLayer != null) {
        gasStationLayer.DeleteAllShapes();
    }
    var getit = "";
    if (type == CollectionSearchType.Tag) {
        var a = $get("header_taskBar_collsearch");
        if (index == 0) {
            collectionExplorerTerm = a.value;
        }
        var filter = collectionExplorerTerm;
        getit = geoCommunityURL + "?action=retrieverss&mkt=en-us&ss=" + filter +
        "&bbox=" + topleft.Longitude + "," + bottomright.Latitude + "," + bottomright.Longitude + "," + topleft.Latitude + "&startindex=" + index + "&order=" + orderby;

        axSearch.ShowMessage(L_COL_RESULTS);
    }
    if (type == CollectionSearchType.Explore) {
        getit = geoCommunityURL + "?action=retrieverss&mkt=en-us&ss=" +
        "&bbox=" + topleft.Longitude + "," + bottomright.Latitude + "," + bottomright.Longitude + "," + topleft.Latitude + "&startindex=" + index + "&order=" + orderby;
    }
    tempGetIt = getit;
    if (collectionsLayer == null) {
        collectionsLayer = new VEShapeLayer();
    }
    else {
        collectionsLayer.DeleteAllShapes();
    }

    var veLayerSpec = new VEShapeSourceSpecification(VEDataType.ImportXML, getit, collectionsLayer);
    map.ImportShapeLayerData(veLayerSpec, onLayerLoaded, setMapView);
    layerLoadEnded = false;
    axSearch.ShowTaskProgress();

    // Save search parameters in hidden value(for printing page)
    $get("search__searchCollections").value = index + "," + type + "," + orderby + "," + setMapView;

    // Hide/Show sort menu
    $get("VEsorting_panel").style.display = "none";
    $get("sorting_panel").style.display = "block";
}

axSearch.VESearchCollections = function(index, orderby) {
    ///<summary>Search collections with VESearchService</summary>
    var a = $get("header_taskBar_collsearch");
    if (a.value == COL_STRING || a.value == "") {
        return;
    }

    searchBusinesses = false;
    exlopereCollections = true;

    axSearch.ShowTaskArea();
    axSearch.ShowTaskProgress();

    // Save parameters in hidden value(for printing page)
    $get("search__searchCollections").value = a.value +","+ index +","+ orderby


    collectionExplorerStartIndex = index;
    temporderby = orderby;

    CallPageMethod("SearchCollections", { "query": a.value, "index": index, "sortby": orderby }, axSearch.OnSearchCollection);

    // Hide/Show sort menu
    $get("VEsorting_panel").style.display = "block";
    $get("sorting_panel").style.display = "none";

    axRoute.RemoveDirections();
    $get("TaskHost_disambgid_disambgContainer").style.display = "none";
}
axSearch.OpenCollection = function(a) {
}
var collectionLatLongs = new Array();
axSearch.OnSearchCollection = function(r) {

    axSearch.ShowTaskHostLayer("collection");
    axSearch.HideTaskProgress();

    if (collectionsLayer == null) {
        collectionsLayer = new VEShapeLayer();
        map.AddShapeLayer(collectionsLayer);
    }
    else {
        collectionsLayer.DeleteAllShapes();
    }

    if (r == null || r.length == 0) {
        $get("sorting_panel").style.visibilty = "hidden";
        var t = $get("search_disambgParse_scope");
        t.selectedIndex = 2;
        $get("search_disambgParse_whatBox").style.display = "none";
        $get("search_disambgParse_whatText").style.display = "none";
        $get("search_disambgParse_whereBox").value = searchLocationOnlyTerm;
        axSearch.ShowSearchDisambContainer();
        return;
    }

    var fc = $get("co_toolbar_state");
    if (fc != null) {
        fc.focus();
    }

    $get("collections_body").innerHTML = "";

    var content = "";
    var endPoint = false;
    var count = r[0].TotalCount;
    if (count > 0) {

        // Show result length and current position on the top
        var lbl = $get("menuContrl_TaskHost_WelcomeTask_pc");
        var startResult = (collectionExplorerStartIndex * 10) + 1;
        var endResult = startResult + 9;

        if (endResult >= count) {
            endResult = startResult + (count - startResult);
            endPoint = true;
        }

        var searchTerm = $get("header_taskBar_collsearch").value;
        lbl.innerHTML = format(L_Collection_result, startResult, endResult, count, searchTerm);

        //        content += "<div class='CS_GeoRSS_Panel'><a onclick='Subscribe2Rss();return false'>";
        //        content += "<input type='image' style='border-width: 0px;' src='" + imagesPath + "rssfeed.gif' class='CV_RSS_Icon'/>";
        //        content += "<span class='CS_GeoRSS_Text' style='cursor:pointer;'>" + L_SUBSCRIBE_COL_RSS + "</span></a></div>";
        //        $get("sorting_panel").style.visibilty = "visible";
    }
    else {
        axSearch.ShowMessage(L_NO_SEARCHRESULTS);
        $get("sorting_panel").style.visibilty = "hidden";
    }

    collectionLatLongs.length = 0;

    content += "<div><ol class='searchResults'>";
    for (var i = 0; i < r.length; i++) {

        var collectionItem = r[i];

        var index = i + 1 + (collectionExplorerStartIndex * 10);

        var latlong = new VELatLong(r[i].Latitude, r[i].Longitude);
        collectionLatLongs.push(latlong);

        var shape = new VEShape(VEShapeType.Pushpin, latlong);

        var icon = "<span id='resultPinMap_" + index + "' class='bullet_col' onmouseover='changeColPin(this)' onmouseout='changeColPinBack(this)'>" + index + "</span>";
        // Create icon
        var custSpec = axMap.SetCustomIcon(icon, index.toString(), 3);
        shape.SetCustomIcon(custSpec);

        //shape.SetDescription(r[i].Description);

        var source_url = r[i].SourceUrl;
        var photo_url = r[i].PhotoUrl;
        var description = r[i].Description;
        var shortDesc = r[i].Description; // for popup
        var title = r[i].Title;
        var collectionTitle = r[i].ParentCollectionTitle;

        shape.SetTitle(title);

        if (photo_url != "") {
            shape.SetPhotoURL(photo_url);
        }

        var footer = "";
        var driving_directions = "";

        // Show up to 250 chars of description
        if (shortDesc != null) {
            shortDesc = removeHTMLTags(shortDesc);
            if (!shortDesc) {
                shortDesc = "";
            }
            else {
                if (shortDesc.length > 249)
                    shortDesc = shortDesc.substr(0, 249) + "...";
            }
        }
        else {
            shortDesc = "";
        }
        if (collectionTitle != "" && collectionTitle != null) {
            footer = "<div class='ftr' style='width:100%;position:absolute;bottom:3px;background-color:#E4EDF3;left:2px;right:2px;height:55px;padding:4px 8px 0px;'>";
            driving_directions = "<div>" /*+ formatLink(L_OPEN_COLLECTION, " <a class='VE_Panel_sublink' href='#' onclick='axSearch.OpenCollection('" + source_url + "')>" + collectionTitle + "</a>")*/ + "</div>";
            driving_directions += "<div><a href='javascript:_SetDrvDir(" + latlong.Latitude + "," + latlong.Longitude + ",\"start\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveFrom + "</a> " + L_OR + " <a href='javascript:_SetDrvDir(" + latlong.Latitude + "," + latlong.Longitude + ",\"end\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveTo + "</a></div>";
            footer += driving_directions + "<div style='padding-top:5px'>" + L_ZOOMLEVEL_TYPE + ": <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",16);' class='VE_Panel_sublink'>" + L_STREET + "</a>";
            footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",11);'>" + L_CITY + "</a>";
            footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",6);' class='VE_Panel_sublink'>" + L_REGION + "</a></div></div>";

            if (source_url != "" && source_url != null) {
                shape.SetDescription(shortDesc + "<br/><a target='_blank' href='" + source_url + "'>" + L_MORE_INFO + "</a><div style='height:90px'></div>" + footer);
            }
            else {
                shape.SetDescription(shortDesc + "<br/><div style='height:90px'></div>" + footer);
            }
        }
        else {
            footer = "<div class='ftr' style='width:100%;position:absolute;bottom:3px;background-color:#E4EDF3;left:2px;right:2px;height:55px;padding:4px 8px 0px;'>";
            driving_directions += "<div><a href='javascript:_SetDrvDir(" + latlong.Latitude + "," + latlong.Longitude + ",\"start\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveFrom + "</a> " + L_OR + " <a href='javascript:_SetDrvDir(" + latlong.Latitude + "," + latlong.Longitude + ",\"end\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveTo + "</a></div>";
            footer += driving_directions + "<div style='padding-top:5px'>" + L_ZOOMLEVEL_TYPE + ": <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",16);' class='VE_Panel_sublink'>" + L_STREET + "</a>";
            footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",11);'>" + L_CITY + "</a>";
            footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",6);' class='VE_Panel_sublink'>" + L_REGION + "</a></div></div>";

            if (source_url != "" && source_url != null) {
                shape.SetDescription(shortDesc + "<br/><a target='_blank' href='" + source_url + "'>" + L_MORE_INFO + "</a><div style='height:70px'></div>" + footer);
            }
            else {
                shape.SetDescription(shortDesc + "<br/><div style='height:70px'></div>" + footer);
            }
        }

        content += "<li onmouseout='_changeColPinBack(" + index + ")' onmouseover='_changeColPin(" + index + ")'>";
        content += "<table><tr><td valign='top' width='28'>";
        content += "<span class='VE_Pushpin_viewer'>" + index + "</span>";
        content += "</td><td>";
        content += "<h4 onclick='axMap.SetCenterAndZoom(" + latlong.Latitude + "," + latlong.Longitude + ",12);'><a href='#'>" + title + "</a></h4>";
        content += "<p>";
        if (photo_url != "" && photo_url != null) {
            content += "<a><img class='previewArea-image' src='" + photo_url + "'/></a>";
        }
        if (description != "" && description != null) {
            content += description;
        }
        content += "</p>";
        content += " </td></tr></table>";
        content += "</li>";

        collectionsLayer.AddShape(shape);

    }


    map.SetMapView(collectionLatLongs);

    content += "</ol></div>";

    var pager = "<div class='pageList' style='padding-top: 20px;'>";
    if (collectionExplorerStartIndex > 0) {
        pager += "<a href='javascript:axSearch.VESearchCollections(" + (collectionExplorerStartIndex - 1) + ",temporderby)' class=\"prevPage\">" + L_BACK + "</a>";
    }
    if (count > 10 && endPoint == false) {
        pager += "<a href='javascript:axSearch.VESearchCollections(" + (collectionExplorerStartIndex + 1) + ",temporderby)' class=\"nextPage\">" + L_FORWARD + "</a>";
    }
    pager += "</div>";

    $get("collections_body").innerHTML += content + pager;
    tempColCount = count;

}


var layerLoadEnded = true;

function onLayerLoaded(feed) {
    axSearch.ShowTaskHostLayer("collection");
    axSearch.HideTaskProgress();

    var fc = $get("co_toolbar_state");
    if (fc != null) {
        fc.focus();
    }

    $get("collections_body").innerHTML = "";

    var content = "";
    var count = feed.GetShapeCount();
    if (count > 0) {
        content += "<div class='CS_GeoRSS_Panel'><a onclick='Subscribe2Rss();return false'>";
        content += "<input type='image' style='border-width: 0px;' src='" + imagesPath + "rssfeed.gif' class='CV_RSS_Icon'/>";
        content += "<span class='CS_GeoRSS_Text' style='cursor:pointer;'>" + L_SUBSCRIBE_COL_RSS + "</span></a></div>";
        $get("sorting_panel").style.visibilty = "visible";
    }
    else {
        axSearch.ShowMessage(L_NO_SEARCHRESULTS);
        $get("sorting_panel").style.visibilty = "hidden";
    }
    //DisableSearchProgress();

    content += "<div><ol class='searchResults'>";
    for (var i = 0; i < count; i++) {

        var shape = feed.GetShapeByIndex(i);
        var index = i + 1 + (collectionExplorerStartIndex * tempColCount);
        var icon = "<span id='resultPinMap_" + index + "' class='bullet_col' onmouseover='changeColPin(this)' onmouseout='changeColPinBack(this)'>" + index + "</span>";

        // Create icon
        var custSpec = axMap.SetCustomIcon(icon, index, 3);
        shape.SetCustomIcon(custSpec);
        var url = shape.GetMoreInfoURL();
        var photo_url = shape.GetPhotoURL();
        var description = shape.GetDescription();
        var shortDesc = shape.GetDescription();

        var pts = shape.GetPoints();

        content += "<li onmouseout='_changeColPinBack(" + index + ")' onmouseover='_changeColPin(" + index + ")'><span class='VE_Pushpin_viewer'>" + index + "</span>";
        content += "<h4 onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",12);'><a href='#'>" + shape.GetTitle() + "</a></h4>";
        content += "<p>";
        if (photo_url != "" && photo_url != null) {
            content += "<a><img class='previewArea-image' src='" + photo_url + "'/></a>";
        }
        if (description != "" && description != null) {

            content += description;
        }
        content += "</p>";
        content += "</li>";

        var footer = "<div class='ftr' style='position:absolute;bottom:3px;background-color:#E4EDF3;left:2px;right:2px;height:55px;padding:4px 8px 0px;'>";
        var driving_directions = "<div><a href='javascript:_SetDrvDir(" + pts[0].Latitude + "," + pts[0].Longitude + ",\"start\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveFrom + "</a> " + L_OR + " <a href='javascript:_SetDrvDir(" + pts[0].Latitude + "," + pts[0].Longitude + ",\"end\");' class='VE_Panel_sublink'>" + L_ContextMenu_DriveTo + "</a></div>";
        footer += driving_directions + "<div style='padding-top:5px'>" + L_ZOOMLEVEL_TYPE + ": <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",16);' class='VE_Panel_sublink'>" + L_STREET + "</a>";
        footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",11);'>" + L_CITY + "</a>";
        footer += " | <a href='#' onclick='axMap.SetCenterAndZoom(" + pts[0].Latitude + "," + pts[0].Longitude + ",6);' class='VE_Panel_sublink'>" + L_REGION + "</a></div></div>";

        // Show up to 250 chars of description
        if (shortDesc != null) {
            shortDesc = removeHTMLTags(shortDesc);
            if (!shortDesc) {
                shortDesc = "";
            }
            else {
                if (shortDesc.length > 249)
                    shortDesc = shortDesc.substr(0, 249) + "...";
            }
        }
        else {
            shortDesc = "";
        }

        if (url != "" && url != null) {
            shape.SetDescription(shortDesc + "<br/><a target='_blank' href='" + url + "'>" + L_MORE_INFO + "</a><div style='height:70px'></div>" + footer);
        }
        else {
            shape.SetDescription(shortDesc + "<br/><div style='height:70px'></div>" + footer);
        }
        shape.SetMoreInfoURL("");

    }
    content += "</ol></div>";

    var pager = "<div class='pageList' style='padding-top: 20px;'>";
    if (collectionExplorerStartIndex > 0) {
        pager += "<a href='javascript:SearchCollections(" + (collectionExplorerStartIndex - 1) + ",tempCollectionSearchType,temporderby,false)' class=\"prevPage\">" + L_BACK + "</a>";
    }
    if (feed.GetShapeCount() > 9) {
        pager += "<a href='javascript:SearchCollections(" + (collectionExplorerStartIndex + 1) + ",tempCollectionSearchType,temporderby,false)' class=\"nextPage\">" + L_FORWARD + "</a>";
    }
    pager += "</div>";

    $get("collections_body").innerHTML = content + pager;
    tempColCount = count;


    layerLoadEnded = true;

}

function ExploreCollections(orderby, t) {
    exlopereCollections = true;
    searchBusinesses = false;

    axSearch.ShowTaskHostLayer("collection");
    axSearch.ShowTaskArea();

    try {
        if (t.className == "sortLabelActive") return;
        if (t.id != 'undefined') {
            if (t.id.indexOf("col_rel") > 0) {
                t.className = "sortLabelActive";
                $get("collection_col_dis").className = "sortLabelUnActive";
                $get("collection_col_dat").className = "sortLabeUnActive";
            }
            if (t.id.indexOf("col_dis") > 0) {
                t.className = "sortLabelActive";
                $get("collection_col_rel").className = "sortLabelUnActive";
                $get("collection_col_dat").className = "sortLabelUnActive";
            }
            if (t.id.indexOf("col_dat") > 0) {
                t.className = "sortLabelActive";
                $get("collection_col_rel").className = "sortLabelUnActive";
                $get("collection_col_dis").className = "sortLabelUnActive";
            }
        }
    }
    catch (e) { }

    axSearch.ShowMessage(L_EXPLORE_COL_TEXT);
    var z = map.GetZoomLevel();
    var style = map.GetMapStyle();
    if (z < 9 && style != VEMapStyle.Birdseye && style != VEMapStyle.BirdseyeHybrid && !exploreColParameterSet) {
        ShowZoomInHint(orderby);
    }
    else {
        if (exploreColParameterSet) {
            setTimeout("SearchCollections(0, CollectionSearchType.Explore,'relevance',false);", 1000)
            exploreColParameterSet = false;
        }
        else {
            SearchCollections(0, CollectionSearchType.Explore, orderby, false);
        }
    }
}

function VEExploreCollections(orderby, t) {
    exlopereCollections = true;
    searchBusinesses = false;
    
    axSearch.ShowTaskHostLayer("collection");
    axSearch.ShowTaskArea();

    if (t.className == "sortLabelActive") return;
    if (t.id != 'undefined') {
        if (t.id.indexOf("VEcol_rel") > 0) {
            t.className = "sortLabelActive";
            $get("collection_VEcol_dis").className = "sortLabelUnActive";
        }
        if (t.id.indexOf("VEcol_dis") > 0) {
            t.className = "sortLabelActive";
            $get("collection_VEcol_rel").className = "sortLabelUnActive";
        }
    }

    //axSearch.ShowMessage(L_EXPLORE_COL_TEXT);
    var z = map.GetZoomLevel();
    var style = map.GetMapStyle();
    if (z < 9 && style != VEMapStyle.Birdseye && style != VEMapStyle.BirdseyeHybrid && !exploreColParameterSet) {
        ShowZoomInHint(orderby);
    }
    else {
        if (exploreColParameterSet) {
            setTimeout("axSearch.VESearchCollections(0, 'relevance');", 1000)
            exploreColParameterSet = false;
        }
        else {
            axSearch.VESearchCollections(0, orderby);
        }
    }

    
}

function Subscribe2Rss() {
    window.open(tempGetIt, "");
}