﻿namespace('nnet.sd');

nnet.sd.CategoryPage = $j.klass({
    initialize: function(page) {
        try {
            this.Panel = null;
            this.Map = null;
            this.CategoryHTML = page;
            this.Panel = $j('#'+sVars.SD_CategoryContainerPanelID);
            if (GBrowserIsCompatible()) {
                // Google map stuff
                if (this.Map == null) this.Map = new GMap2(document.getElementById(sVars.SD_CategoryContainerPanelID));
                this.Map.setCenter(new GLatLng(sVars.SiteLatitude, sVars.SiteLongitude), sVars.SiteMapZoom);
            }
        } catch (e) { logE("sd.CategoryPage.initialize", e); }
    },

    startup: function() {
        try {
//            this.Panel = $j('#CategoryContainer');
//            if (GBrowserIsCompatible()) {
//                // Google map stuff
//                if (this.Map == null) this.Map = new GMap2(document.getElementById('CategoryContainer'));
//                this.Map.setCenter(new GLatLng(NNet.SiteLatitude, NNet.SiteLongitude), NNet.SiteMapZoom);
//            }
        } catch (e) { logE("sd.CategoryPage.startup", e); }
    },


    //ServiceCategoryPage
    display: function() {
        try {
            if (GBrowserIsCompatible()) {
                var marker = new GMarker(new GLatLng(NNet.SiteLatitude, NNet.SiteLongitude), 0);
                this.Map.addOverlay(marker);
                var markerWidth = contentWidth * 0.87;
                var markerHeight = contentHeight - 190;
                var opts = { maxWidth: markerWidth, maxHeight: markerHeight, noCloseOnClick: true, autoScroll: true, onOpenFn: this.creatTabs() };
                //marker.openInfoWindowHtml(this.CategoryHTML, opts);
                marker.openInfoWindowHtml(document.getElementById("ServiceCategoryPage"), opts);
                
                //$j('#category-marker > ul').tabs();
            }
            SD.show(sVars.CATEGORY_CONTENT_VIEW_STATE);
        } catch (e) { logE("sd.CategoryPage.display", e); }
    },
    
    creatTabs: function() {
        try {
            //setTimeout("$j('#category-marker > ul').tabs();", 0);
            //$j('#category-marker > ul').tabs()
//            var tabs = new Ext.TabPanel({
//            renderTo: 'category-tabs',
//                activeTab: 0,
//                items: [
//                    { contentEl: 'category-tab-description', title: 'Local Services' },
//                    { contentEl: 'category-tab-listing', title: 'Latest Listing' },
//                    { contentEl: 'category-tab-feedback', title: 'Latest Feedback' }
//                ]
//            });

        } catch (e) { logE("sd.CategoryPage.creatTabs", e); }
    },

    edit: function() {
        try {
            new nnet.PopUpWindow({ url: '/Directory/CategoryPage/Edit?ProcessID='+NNet.ProcessID, minWidth: 600 }).show();
        } catch (e) { logE("sd.CategoryPage.edit", e); }
    },

   

    hide: function() {
        this.Panel.hide();
    },

    show: function() {
        this.Panel.show();
    }


});

