var homeskin = initialfcskin('\u5929\u5357\u5730\u5317\u7121\u6240\u4e0d\u804a', '\u65c5\u806f\u7db2\u7559\u8a00\u7c3f');

function docobjbase(doctype, objid) 
{
	this.dt = doctype||"unknown";
	this.id = objid || "";
	this.docstr= this.dt+"-" + this.id;
	
	this.action = function(loadonce)
	{
	}
}

function docobjmain(doctype, objid) 
{
	this.base = docobjbase;
	this.base(doctype, objid);
	this.parent = new docobjbase(doctype, objid);
	
	this.action = function(loadonce)
	{	
		//render recommend text for the obj
  		xajax_refreshRecommend("divRecommended", this.docstr, 0, 3); 
  		//render popular text for the obj
  		xajax_getHotArticles("divhotarticles", this.docstr, 0, 3);
	}
	
	this.showCommentAndNews = function()
	{
		GetRecentBlogsComments_shell(this.docstr, 0, 3);
	}
	
	this.wayPoint = function(bShow, zlevel)
	{
		bShow = bShow || 0;
		zlevel = parseInt(zlevel) || 7;
		
		var wpsdata = document.getElementById("xmlWaypoints").innerHTML;
								
		if(wpsdata != "")
			setWaypointsObj(wpsdata, bShow, zlevel);		
	}
	
	this.loadfc = function()
	{
		var dct= '- \u7559\u4e0b\u610f\u898b -';
		var ht='\u52d5\u614b';	
  		rendergfcrating(this.docstr, dct, ht);
  	}	
}

function queryobj(doctype, objid, st) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	this.st = st || 0;
		
	this.action = function(loadonce)
	{
		this.wayPoint(1);
				
		//if the result of search is no data, search by google will start automatically, 2010.2.13 			
		var nRelaticArticles = xwpobj.documentElement.getAttribute("totalarticles");
		
		if(nRelaticArticles ==0)
			gajaxsearchglobal(this.id, "waytogo.cc", "", "append");
		else
		{
			if(searchObj == null)
				GOnLoad();
			//search bluesky by the way, 2009.11.3
			blueskySearchObj.execute(this.id);
			setTimeout("keeponSearchObj.execute('"+this.id+"');", 600);		
		}		
		
		setTimeout("loadtopicsforquery()",200);
		setTimeout("showLocation('"+this.id+"');", 400);
				
		GetForumTopicsIteration(null, 0, 3, 23, this.docstr);					
		this.showCommentAndNews();		
		this.parent.action(loadonce);		
	};
}

function topicobj(doctype, objid, topicname, topicll, isLeaf, strTags) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	this.topicname = topicname || "";
	this.topicll = topicll || "";
	this.isLeaf = isLeaf || 0;
	this.strTags = strTags || "";
	
	this.action = function(loadonce, bLoadIntoReserved, bRefreshOption, bWaypointHasSet)
	{	
		bLoadIntoReserved = bLoadIntoReserved || "true";
		bRefreshOption = bRefreshOption || "true";
		bWaypointHasSet = bWaypointHasSet || "false";
		
		if(bLoadIntoReserved=="true")		
			setTimeout("loadtopictoreserved("+(this.id)+");", 200);
		
		if(bRefreshOption=="false")
			return;
					
							
		if(bWaypointHasSet == "false")
			this.wayPoint(1, 11);				
					
		var nRelaticArticles = xwpobj.documentElement.getAttribute("totalarticles");
		
		if(nRelaticArticles ==0)
			gajaxSearchRelaticArticlesOfTopic(this.topicname);
		
		//search bluesky by the way, 2009.11.3
		var strSearch = topicname+","+this.strTags;
		if(searchObj == null)
			GOnLoad();		
		setTimeout("blueskySearchObj.execute('"+strSearch+"');", 450);
		setTimeout("keeponSearchObj.execute('"+strSearch+"');", 500);
			
		
		if(topicll == "")
		{
			setTimeout("showLocation('"+(this.topicname)+"')", 200);
			if(isLeaf==0)
				setTimeout("autoTopicLocation("+(this.id)+",'"+(this.topicname)+"',2500)",400);
		}	
		else 
			setTimeout("panToWayObjLoc('"+(this.topicll)+"', '"+(this.topicname)+"', "+(this.id)+", 0)", 1000);
			
		GetForumTopicsIteration(null, 0, 3, 23, this.docstr);	
		this.showCommentAndNews();				
				
		if(bRefreshOption!="partial")
		{	
			this.loadfc();
			this.parent.action(loadonce);
		}	
	};
}

function catobj(doctype, objid, cattopicid) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	
	this.action = function(loadonce)
	{	
		setTimeout("loadtopictoreserved("+cattopicid+");", 200);
		ShowAuthorWebPads(null, 0, 10, objid);
		
		GetForumTopicsIteration(null, 0, 3, 23, this.docstr);	
		this.showCommentAndNews();	
					
		this.wayPoint();
		this.loadfc();
		this.parent.action(loadonce);		
	};
}

function userobj(doctype, objid) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	
	this.action = function(loadonce)
	{	
		//xajax_loadCmtFromBlog(objid, "xajax_renderCommentOfUserblog");
		
		GetForumTopicsIteration(null, 0, 3, 23, this.docstr);
		xajax_loadCmtFromBlog(this.id, "xajax_getRecentBlogsComments");		
		this.wayPoint();
		
		//GetRecentBlogsComments(null, 0, 3, this.docstr);
		this.loadfc();
		this.parent.action(loadonce);		
	};
}

function monthobj(doctype, objid) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	
	this.action = function(loadonce)
	{		
		xajax_getHotTopicImageOfMonth("divmonthhottopicimg",objid, 295);
		
		GetForumTopicsIteration(null, 0, 3, 23, this.docstr);	
		//show month news 2009.10.30
		GetNewsFeed(null, 0, 2, this.docstr);					
		this.wayPoint();
		this.parent.action(loadonce);		
	};
}	

function homepageobj(doctype, objid) 
{
	this.base = docobjmain;
	this.base(doctype, objid);
	this.parent = new docobjmain(doctype, objid);
	
	this.loadfc = function()
	{		
		//左邊邊攔留言簿
			
		google.friendconnect.container.renderWallGadget(
 		{id: 'div-1228638736764',
   		site: '10224843841355873816',
   		'view-params':{"scope":"ID","features":"video,comment","docId": "unknown"}
		//'view-params':{"scope":"ID","features":"video,comment","docId": (gadgets.util.getUrlParameters()["cat"] || "unknown")}		
		},
  		homeskin);
  	        
  		
  		//Render the member gadget into a div	
  		google.friendconnect.container.renderMembersGadget({ id: 'div-1228632358198', site: '10224843841355873816'}, homeskin);	
  		
  		//右邊攔activities
  		
		homeskin['HEIGHT'] = '200';
		google.friendconnect.container.renderOpenSocialGadget(
 		{ id: 'div-7010868631668414669',
   			url:'http://www.google.com/friendconnect/gadgets/activities.xml',
   			height: 200,
   			site: '10224843841355873816',
   			'view-params':{"scope":"SITE"}
 			},
  			homeskin);
  			
	}
	
	this.action = function(loadonce)
	{
		ShowAuthorWebPads(null, 0, 10, -1);
		
		//2008.11.20 load hot image of topic for current month and the latest article
		//2009.11.11 only load hot image once
		if(loadonce=="first")
		{
			xajax_getHotTopicImageOfMonth("divmonthhottopicimg", objid, 295);
			xajax_getImageFromJournalID("divarticleimg", -1, 295);
			setTimeout("xajax_refreshFBWall()", 600);
		 						
			//this.loadfc();//2010.1.15 comment out
			
			//initial google open social api to get recent activities 2009.4.7; 2010.7.30 reopen
  			google.friendconnect.container.loadOpenSocialApi({site: '10224843841355873816',	onload: function(securityToken) { initGFCAllData(); }});  	
		}
		
				
		setTimeout("loadRecentWaypoints(-1)", 500);
		//xajax_getCampaignSimpleBoard("divcampaignsimpleboard");
		
		//it's necessary to deal with loadnews only in homepage, 2009.12.9
		xajax_loadNewsFeed("xajax_getNewsFeed,"+encodeURI(this.docstr)+",0,3");
		GetRecentBlogsComments(null, 0, 3, this.docstr);
		setTimeout("GetRecentBlogsComments_shell('"+(this.docstr)+"')",300000);	
		
		//comment out on 2010.9.7
		//GetForumTopicsIteration(null, 0, 3, 23, this.docstr);	
				
		//2010.4.22, 2010.5.3 comment out because the activities is at the end.
		//setTimeout("xajax_listInterestingTopics('divit', 566)", 600);
				
		//only for the end of the year, 2009.12.11
		//setTimeout("ShowRecommendYearArticlesIteration(null, 0, 5)", 200);
		//setTimeout("ShowHotYearArticlesIteration(null, 0, 5)", 250);	
		
		this.parent.action(loadonce);		
	};
}