

// JScript File

    function createTTRemember(n,p,t,s,f){
        var value = "&p=" + p + "&tmode=" + t + "&smode=" + s;
        value = "string=" + escape(value).toLowerCase() + "&forum=" + f;
        //alert(value);
        createCookie(n + "ttRemember", value);
        return true;
    }

	function jumpTime(s) {
		document.cookie = dbName + "timefilter="+s.options[s.selectedIndex].value+ "; path=/"		
		self.location.replace(basicForumURL);
	}
	function jumpSmode(s) {
	    var sval = s.options[s.selectedIndex].value;
	    createTTRemember(dbName,1,tmode,sval,theCurrentForumID);
	    self.location.replace(basicForumURL);
	}
	
	function jumpTmode(s) {
	    var tval = s.options[s.selectedIndex].value;
	    selectTmode(tval);
	}
	
	function selectTmode(tval){
	    createTTRemember(dbName,1,tval,smode,theCurrentForumID);
	    self.location.replace(basicForumURL);
	}
	
    function reloadParent(radWindow){
        //alert("reloadParent");
        
        var arg = radWindow.argument;
        //alert(arg);
        if(typeof(arg) == 'string'){
            if (arg == 'true' || arg == 'reload' || arg == 'del') {
                refreshButton.click();
                arg = null;
            } //self.location.replace(self.location.href);
        }

    }

    var JQMenuLink;

    function SetForumRead(self, lastVisit) {

        JQMenuLink = self;

        $(self).css('cursor', 'wait');
        setTimeout("hideOptionalMenu('markread')", 200);
        
        JQCallWebService("tt.aspx/ReadTrackForum", String.format("{{'forumID':'{0}','lastVisit':'{1}'}}", theCurrentForumID, lastVisit),
            function() {
                setTimeout("$(JQMenuLink).css('cursor', 'default'); $(OptionalMenu.get_childListElement()).show();", 400);
            }
        
        );
     }

     function SetForumSubscription(self, action) {

        JQMenuLink = self;

        $(self).css('cursor', 'wait');
        setTimeout("hideOptionalMenu('subscription')", 200);
        
        JQCallWebService("tt.aspx/SubscribeToForum", String.format("{{'forumID':{0},'action':{1}}}", theCurrentForumID, action),
            function(rtn) {
                
                setTimeout(String.format("updateSubscriptionMenuItem({0});", action), 400);
            }

        );
     }

     function hideOptionalMenu(itemToHide) {

         OptionalMenu.close();

         $(OptionalMenu.get_childListElement()).hide();
         
         OptionalMenu.findItemByValue(itemToHide).blur();
     }

     function updateSubscriptionMenuItem(action) {

         $(JQMenuLink).css('cursor', 'default');

         $(OptionalMenu.get_childListElement()).show();

         var imgBaseLocation = clientScriptPathInfo.ApplicationPath + '/' + pageThemeImageURL;
         
         var subscriptionItem = OptionalMenu.findItemByValue('subscription');
         
         subscriptionItem.set_text((action == -1) ? SubscribeMenuText : UnSubscribeMenuText);
         
         subscriptionItem.set_imageUrl(imgBaseLocation +
            ((action == -1) ? 'menuSubscribe.gif' : 'menuUnSubscribe.gif'));

         if (action > -2 && action < 4) {
             //alert(action);
             for (var i = 0; i < 4; i++) {
                 var subItem = OptionalMenu.findItemByValue('Sub' + i.toString());
                 
                 if (action == i) {
                    subItem.set_imageUrl(imgBaseLocation + 'menuSubscription.gif');
                 } else {
                    subItem.set_imageUrl(imgBaseLocation + 'blank.gif');
                 }
                 
             }

         }

         $(subscriptionItem.get_linkElement()).unbind('click').attr('onclick', '')
            .click(function() {
                if (action == -1) return false; else SetForumSubscription(this, -1);

            });
                     
     }


