﻿var Submain = {
    ObjectID : null,
    Target : '',
    PageNo : 1,
    PageSize : 2,
    GetItemRanking : function(page) {
        Main_Items.getItemRanking(page, 'ItemRanking', Util.AjaxCallback);
    },
    GetFrontierReviews : function(page) {
        Main_Frontiers.GetFrontierReviews(page, 10, 'Frontiers_FrontierReviews', Util.AjaxCallback);
    },
    GetCategoryReviews : function(categoryid, page) {
        Main_Reviews.GetCategoryReviews(categoryid, page, 10, 'ReviewSubmain_ReviewNow', Util.AjaxCallback);
    },
    GetItemList : function(taxonomyid, page) {
        Main_Items.GetItemList(taxonomyid, page, 5, 'ItemSubmain_ItemList', Util.AjaxCallback);
    },
    GetCollectionList : function(page) {
        Main_Collections.GetCollectionList(page, 5, 'CollectionSubmain_CollectionList', Util.AjaxCallback);
    },
    GetTalkNow : function(page) {
        Opinity.Controls.Submain.CtlTalks.GetCollectionTalks(page, 8, 'ItemSubmain_TalkNow', Util.AjaxCallback);
    },    
    ShowItemTalk : function(id) {
        if($('ITEM-' + id + '-TALK').style.display != 'inline') {
            $('ITEM-' + id + '-TALK').setStyle({display:'inline'});
            $('BTN-ITEM-' + id + '-TALK').setStyle({background:'url(/images/submain/bg_item_talk_on.gif) no-repeat',color:'#ffffff',cursor:'default'});
            $('BTN-ITEM-' + id + '-TALK').innerHTML = $('BTN-ITEM-' + id + '-TALK').innerHTML.replace(/<strong.*<\/strong>/gi,'');
            $('BTN-ITEM-' + id + '-TALK').innerHTML += '<strong style="background:url(/images/submain/bg_item_talk_on_r.gif) no-repeat;"></strong>';
            
            if($('ITEM-' + id + '-REVIEW')) {
                $('ITEM-' + id + '-REVIEW').setStyle({display:'none'});
                $('BTN-ITEM-' + id + '-REVIEW').setStyle({background:'url(/images/submain/bg_item_talk_off.gif) no-repeat',color:'#585858',cursor:'pointer'});
                $('BTN-ITEM-' + id + '-REVIEW').innerHTML = $('BTN-ITEM-' + id + '-REVIEW').innerHTML.replace(/<strong.*<\/strong>/gi,'');
                $('BTN-ITEM-' + id + '-REVIEW').innerHTML += '<strong style="background:url(/images/submain/bg_item_talk_off_r.gif) no-repeat;"></strong>';
            }
        }
    },
    ShowItemReview : function(id) { 
        if($('ITEM-' + id + '-REVIEW').style.display != 'inline') {
            $('ITEM-' + id + '-REVIEW').setStyle({display:'inline'});
            $('BTN-ITEM-' + id + '-REVIEW').setStyle({background:'url(/images/submain/bg_item_review_on.gif) no-repeat',color:'#ffffff',cursor:'default'});
            $('BTN-ITEM-' + id + '-REVIEW').innerHTML = $('BTN-ITEM-' + id + '-REVIEW').innerHTML.replace(/<strong.*<\/strong>/gi,'');
            $('BTN-ITEM-' + id + '-REVIEW').innerHTML += '<strong style="background:url(/images/submain/bg_item_talk_on_r.gif) no-repeat;"></strong>';

            if($('ITEM-' + id + '-TALK')) {
                $('ITEM-' + id + '-TALK').setStyle({display:'none'});
                $('BTN-ITEM-' + id + '-TALK').setStyle({background:'url(/images/submain/bg_item_talk_off.gif) no-repeat',color:'#585858',cursor:'pointer'});
                $('BTN-ITEM-' + id + '-TALK').innerHTML = $('BTN-ITEM-' + id + '-TALK').innerHTML.replace(/<strong.*<\/strong>/gi,'');
                $('BTN-ITEM-' + id + '-TALK').innerHTML += '<strong style="background:url(/images/submain/bg_item_talk_off_r.gif) no-repeat;"></strong>';
            }
        }
    },
    GetCollectionItems : function(collectionid, page) {
        Main_Collections.GetCollectionItems(collectionid, page, 7, 'COLLECTION-ITEMS-' + collectionid, Util.AjaxCallback);
    },
    GetCollectionTop3Items : function(collectionid, page) {
        Main_Collections.GetCollectionTop3Items(collectionid, page, 6, 'COLLECTIONTOP3-ITEMS-' + collectionid, Util.AjaxCallback);
    },
    FrontierTalks : function(id, page) {
        this.ObjectID = id;
        CtlFrontierTalks.GetFrontierTalks(id, page, 10, 'FrontierSubmain_Talks', Util.AjaxCallback);
    },
    GoFrontier : function(id) {
        this.ObjectID = id;
        if(id != '00000000-0000-0000-0000-000000000000')
            document.location.href = '/Frontiers/' + id + ((this.Target != 'Running') ? '?Menu=' + this.Target : "");
        else
            document.location.href = '/Frontiers' + ((this.Target != 'Running') ? '?Menu=' + this.Target : "");
    },
    Frontiers : function(page) {
        Main_Frontiers.GetFrontiers(this.Target, page, 2, 'FrontierSubmain_Top_Frontiers', Util.AjaxCallback);
    },
    FrontierWinners : function(id) {
        $('EventWinners').update('');
        $('EventWinners').setStyle({display:'inline',left:Util.X-450 + 'px', top:Util.Y + 'px'});
        CtlEventWinners.GetFrontierWinners(id, 'EventWinners', Util.AjaxCallback);
    }
}


var Navigation = {
    TaxonomyID : null,
    Depth : -1,
    Init : function(id, index) {
    
    },
    Show : function(index) {
        var x = Util.X - 500;
        var pos = Util.GetAbsolutePos($('Navigation' + index));
        var pos2 = Util.GetAbsolutePos($('Navigation'));        
            
        if($('Navigation_Layer' + index).style.display != 'inline') {
            this.Depth = index;
            
            for(i=0;;i++) {
                if($('Navigation_Layer' + i)) $('Navigation_Layer' + i).setStyle({display:'none'});
                else
                    break;
            }
            
            $('Navigation_Layer' + index).setStyle({display:'inline',left:pos.x - pos2.x +'px'});
        }
        else {
            $('Navigation_Layer' + index).setStyle({display:'none'});
        }
    }
}