var skinArr = ['mfm','5shen','wd','csol','lotro','sxft','6dol','12ha','shumen','pcik','han','wentian','aoa','tz','hhsj','df','dnk','mowu','5jq','wow'];
var cssArr=['daohang','daohang1','daohang2','daohang3','daohang4'];
var initType_2 = false;
var initType_3 = false;
var browserInfo = new browserinfo();

function preLoad(){			
	var url=document.location+"";
	var endIndex = url.indexOf('.ngamebar.com'); 
	
	var prefix = url.substring(7,endIndex);
	
	if(skinCheck(skinArr, prefix))
		document.location='/clubIndex.action';
	else if(strEndWith(url,"17swjz.cn") || strEndWith(url,"17swjz.cn/"))
		document.location='http://17swjz.club.ngamebar.com/clubIndex.action?t=3&clubId=43';	
}

function preLoadCss(){			
	var url=document.location+"";
	var endIndex = url.indexOf('.ngamebar.com'); 
	
	var prefix = url.substring(7,endIndex);
	
	if(skinCheck(cssArr, prefix))
		document.location='/clubGuest.action';//需要更改
	else if(strEndWith(url,"17swjz.cn") || strEndWith(url,"17swjz.cn/"))
		document.location='http://17swjz.club.ngamebar.com/clubIndex.action?t=3&clubId=43';	
}
preLoad();
preLoadCss();

var curGameIndex='#defaultGames';
var curTradeMode = 'TABLE_MODE';
var linkBoard = '';
var tradePageNo = 1;
var tradePageIndex = 1;
var bargainType;
var curTradeRule = '';
var curTradeIdx;

var articlePageIndex_1 = 1;
var articlePageIndex_2 = 1;
var articlePageIndex_3 = 1;

var articlePageNo_1=-1;
var articlePageNo_2=-1;
var articlePageNo_3=-1;

var curType = 1;
var articleFlag = 0;
var cacheRecord;
var tRecordIndex=1;

//for scroll photo news
var scrollSpeed = 10; //速度(毫秒)
var scrollSpace = 10; //每次移动(px)
var scrollWidth = 178; //翻页宽度
var scrollFill = 0; //整体移位
var scrollLock = false;
var timeObj;
var scrollWay="right";
var scrollComp = 0;

//Bargin Type Final Value
var BUSS = 0;
var TENANCY = 1;
var GOLD= 2;
var DOTCART= 3;
var PROP= 4;
var EXCHANGE = 8;
var GOLD_BUY= 9;
var DOTCART_BUY= 10;
var PROP_BUY= 11;
var BUSS_BUY= 12;
var TENANCY_REQUEST= 13;
var DAILIAN_SEND= 14;
var DAILIAN_RECEIVE= 15;
var OTHERS_SELL= 16;
var OTHERS_BUY= 17;


//for IE_6 hack when page load over
function ie6_hack(){
	$('#noticePanel').css('marginLeft', '12px');
	$('#forumIndexPanel').css('marginLeft','-8px');
	$('#clubMsgDiv').css('marginLeft','3px');
	$('#hotNews').css('marginTop','14px');
	$('#scrollArea').css('marginLeft','-4px');
	$('#searchPanel').css('marginTop','10px');
	$('#faqPanel').css('marginLeft','8px');
	$('#tradeTypeMenu').css('marginTop','-8px');
	//$('#searchTxt').css('marginLeft','200px');
	//$('#hotTradeIntro').css('marginLeft','8px');
	//$('#hotTradeIntro .extImg').css('marginLeft','1px');
	
	
	$('#scrollList img').each(function(){
		this.onmouseover=function(){this.style.border='2px solid #bb0101';};
		this.onmouseout=function(){this.style.border='2px solid rgb(67,132,224)';};
	});
	
	$('#scrollList .photoLbl').each(function(){
		this.onmouseover=function(){this.style.color='rgb(67,132,224)';this.style.cursor='pointer';this.style.textDecoration='underline';};
		this.onmouseout=function(){this.style.color='#373737';this.style.textDecoration='none';};
	});
}

//for IE_6 enhance when trade panel data load over
function ie6_enhance(){
	$('#tradeTbody tr').each(function(){
		this.onmouseover=function(){this.style.backgroundColor='#c5e0e0';};
		this.onmouseout=function(){this.style.backgroundColor='';};
	});
	
	$('#tradeTbody .tradeTitle').each(function(){
		this.onmouseover=function(){this.style.color='rgb(67,132,224)';this.style.cursor='pointer';this.style.textDecoration='underline';};
		this.onmouseout=function(){this.style.color='#373737';this.style.textDecoration='none';};
	});
}

//for firefox hack when page load over
function firefox_hack(){
	//$('#clubInfoPanel span').css('lineHeight','18px');
	$('#gamesPanel').css('marginTop','12px');
}

//for firefox enhance when article panel data load over
function firefox_enhance(){
	$('#forumIndexData tbody td').css('height','15px');
	$('#forumIndexData tbody td').css('lineHeight','15px');
}



function topLink(idx){
	switch(idx){
		case 2:
			document.location = '/clubIndex.action';
			break;
		case 3:
			document.location = '/cwbbs/forum';
			break;
		case 4:
			document.location = '/cwbbs/blog';
			break;
	}
}

function initEvent(){
	/*getEl('tradePage').onkeydown = function(){
		if(event.keyCode != 13) return;
		goTradePage();
	};*/
	
	getEl('searTxt').onkeydown = function(){
		if(event.keyCode != 13) return;
		onsearch();
	};
	
	/*getEl('boardTxt').onkeydown = function(){
		if(event.keyCode != 13) return;
		boardGo();
	};*/
	
	getEl('articlePage_1').onkeydown = function(){
		if(event.keyCode != 13) return;
		goArticlePage(1);
	};
	
	getEl('articlePage_2').onkeydown = function(){
		if(event.keyCode != 13) return;
		goArticlePage(2);
	};
	
	getEl('articlePage_3').onkeydown = function(){
		if(event.keyCode != 13) return;
		goArticlePage(3);
	};
	
	getEl('tradeSearch').onkeydown = function(){
		if(event.keyCode != 13) return;
		searchTrade();
	};
	
	getEl('searchTxt').onfocus = function(){
		getEl('searchTxt').value='';
	}
}

function fillBoard(id){
	getEl('boardTxt').value = getEl('board_'+id).innerText;
	linkBoard = id;
	getEl('boardTxt').onclick();
	getEl('boardTxt').focus();
}

function boardGo(){
	if(linkBoard.length==0)
		return;
	var url = "/cwbbs/forum/f-0-" + linkBoard + "-1-0.html";
	linkBoard = '';
	getEl('boardTxt').value='-- 请 选 择 吧 台 --';
	window.open(url,true);
}

function initStyle(){
	$('#boardDiv span').hover(function(){
		this.style.color = 'rgb(67,132,224)';
		this.style.textDecoration = 'underline';
	},function(){
		this.style.color = '#373737';
		this.style.textDecoration = 'none';
	});
	
	featuredcontentglider.init({
		gliderid: "forumIndexData",
		contentclass: "forumcontent",
		togglerid: "forumIndexMenu",
		remotecontent: "",
		selected: 0,
		persiststate: false,
		speed: 400, 
		direction: "updown",
		autorotate: false
	});
	
	featuredcontentglider.init({
		contentclass: "newscontent",
		remotecontent: "",
		selected: 0, 
		persiststate: false, 
		speed: 400, 
		direction: "leftright", 
		autorotate: false 
	});
}

function onsearch(){
	if(getEl("searTxt").value.length==0){
		alert("搜索内容不能为空！");
		getEl("searTxt").focus();
		return;
	}
	window.open("/search.jsp?q="+getEl("searTxt").value,true);
	getEl('searTxt').value='- - 游戏搜索';
}
function clearKeyWord(){
	if(getEl("searTxt").value=="- - 游戏搜索"){
		getEl('searTxt').value="";
	}
}
function setKeyWord(){
	if(getEl("searTxt").value.length==0){
		getEl('searTxt').value="- - 游戏搜索";
	}
}

function loadTradeByType(idx){
	var spans = getEl('tradeTypeMenu').getElementsByTagName('span');
	if(curTradeMode == 'GUIDE_MODE')
		return;
	
	var spans = getEl('tradeTypeMenu').getElementsByTagName('span');
	if(spans[idx-1].style.color=='gray') return;
	
	for(var i=0;i<spans.length;i++)
		spans[i].style.color = 'white';
	
	spans[idx-1].style.color = 'rgb(182,227,254)';
	
	var order = '';
	var gameId = '';
	var key='';
	var pageSize=15;
	
	tradePageIndex = 1;
	bargainType = fixBargainType(curTradeIdx,idx);
	
	if(bargainType<0) return;
	var params="bt="+bargainType+"&gameId="+gameId+"&order="+order+"&"+"key="+key+"&pageSize="+pageSize+"&pageIndex="+tradePageIndex;
	
	jQuery.ajax({
	 	type: "GET",
	 	url: "/auctionList.action",
	 	data: params,
	 	dataType:'json',
		success: fillTradeTable
	}); 
}

function fixBargainType(idx,type){
	if(idx==1){
		switch(type){
			case 1:		return GOLD;
			case 2:	return BUSS;
			case 3:	return DOTCART;
			case 4:	return PROP;
			case 5:	return OTHERS_SELL;
		}	
	}else if(idx==2){
		switch(type){
			case 1:		return GOLD_BUY;
			case 2:	return BUSS_BUY;
			case 3:	return DOTCART_BUY;
			case 4:	return PROP_BUY;
			case 5:	return OTHERS_BUY;
		}
	}//end of else
}

function filteTradeByGame(){
	if(bargainType<0) return;
	var order= '';
	var key='';
	var pageSize=15;
	var gId = 'TBF';
	tradePageIndex = 1;
	
	var params="bt="+bargainType+"&gameId="+gId+"&order="+order+"&"+"key="+key+"&pageSize="+pageSize+"&pageIndex="+tradePageIndex;
	
	jQuery.ajax({
	 	type: "GET",
	 	url: "/auctionList.action",
	 	data: params,
	 	dataType:'json',
		success: fillTradeTable
	}); 
}

function tradeGuide(){
	$('#tradeData').slideUp('fast',function(){
		$('#tradeGuide').slideDown('fast');
		curTradeMode = 'GUIDE_MODE';
		
		if(curTradeRule=='')  curTradeRule =  'commerceRule';
 		
 		$('#serviceRule').hide();
 		$('#tenancyRule').hide();
 		getEl('commerceRadio').checked='checked';
 		$('#commerceRule').show();
	});
	
	$('#tradeMenu span').each(function(){
		this.style.color = 'white';
	});
	
	$('#tradeTypeMenu span').each(function(){
		this.style.color = 'gray';
	});
}

function showRuleByType(type){
	switch(type){
		case 1:
			if(curTradeRule == 'commerceRule') return;
			$('#'+curTradeRule).fadeOut('fast',function(){
				$('#commerceRule').fadeIn('fast');
			});
			curTradeRule = 'commerceRule';
			break;
		case 2:
			if(curTradeRule == 'tenancyRule') return;
			$('#'+curTradeRule).fadeOut('fast',function(){
				$('#tenancyRule').fadeIn('fast');
			});
			curTradeRule = 'tenancyRule';
			break;
		case 3:
			if(curTradeRule == 'serviceRule') return;
			$('#'+curTradeRule).fadeOut('fast',function(){
				$('#serviceRule').fadeIn('fast');
			});
			curTradeRule = 'serviceRule';
			break;
	}
}


function toggleUserLevel(type,idx,path){
	//TODO
	/*
	if(type==1){
		$('#userLevelDiv').css('background','url("/cwbbs/forum/images/'+path+'") no-repeat');
		$('#userLevelDiv').css('top',(420+idx*22)+'px');	
		$('#userLevelDiv').css('left',(mousePos.x+30)+'px');
		$('#userLevelDiv').show();	
	}else{
		$('#userLevelDiv').hide();
	}*/
}

function auctionDetails(id){
	if(bargainType==BUSS)//出售角色
		window.open("/auctionDetailsForRenderRole.action?aId="+id,true);
	else if(bargainType==BUSS_BUY)//购买角色
		window.open("/auctionDetailsForRequestRole.action?aId="+id,true);
	else if(bargainType==GOLD)//出售金币
		window.open("/auctionDetailsForSellGold.action?aId="+id,true);
	else if(bargainType==GOLD_BUY)//购买金币
		window.open("/auctionDetailsForBuyGold.action?aId="+id,true);
	else if(bargainType==DOTCART)//出售点卡
		window.open("/auctionDetailsForSellCard.action?aId="+id,true);
	else if(bargainType==DOTCART_BUY)//购买点卡 
		window.open("/auctionDetailsForBuyCard.action?aId="+id,true);
	else if(bargainType==PROP)//出售装备
		window.open("/auctionDetailsForSellEquipment.action?aId="+id,true);
	else if(bargainType==PROP_BUY)//购买装备
		window.open("/auctionDetailsForBuyEquipment.action?aId="+id,true);
	else if(bargainType==DAILIAN_SEND)//出售代练
		window.open("/auctionDetailsForRenderRole.action?aId="+id,true);
	else if(bargainType==DAILIAN_RECEIVE)//购买代练
		window.open("/auctionDetailsForRequestRole.action?aId="+id,true);
	else if(bargainType==TENANCY)//出租
		window.open("/auctionDetailsForRenderRole.action?aId="+id,true);
	else if(bargainType==TENANCY_REQUEST)//求租
		window.open("/auctionDetailsForRequestRole.action?aId="+id,true);
	else if(bargainType==EXCHANGE)//交换
		window.open("/auctionDetailsForExchangeRole.action?aId="+id,true);
	
	else if(bargainType==OTHERS_SELL)//出售其它物品
		window.open("/auctionDetailsForSellOtherThings.action?aId="+id,true);
	else if(bargainType==OTHERS_BUY)//求购其它物品
		window.open("/auctionDetailsForBuyOtherThings.action?aId="+id,true);
}

function searchTrade(){
	var keyWord = encodeURI(getEl('tradeSearch').value);
	if(keyWord.length==0){
		alert('请输入搜索关键字!');
		getEl('tradeSearch').focus();
	}
	tradePageIndex = 1;
	var order = '';
	var gameId = '';
	var key= keyWord;
	var pageIndex=tradePageIndex;
	var pageSize=15;
	
	var params="bt="+bargainType+"&gameId="+gameId+"&order="+order+"&"+"key="+key+"&pageSize="+pageSize+"&pageIndex="+tradePageIndex;

	jQuery.ajax({
	 	type: "GET",
	 	url: "/auctionList.action",
	 	data: params,
	 	dataType:'json',
		success: fillTradeTable
	}); 
	
	getEl('tradeSearch').value='';
}

function goTradeByPage(index){
	tradePageIndex = index;
	var order = '';
	var gameId = '';
	var key='';
	var pageIndex=tradePageIndex;
	var pageSize=15;
	
	var params="bt="+bargainType+"&gameId="+gameId+"&order="+order+"&"+"key="+key+"&pageSize="+pageSize+"&pageIndex="+pageIndex;
	
	jQuery.ajax({
	 	type: "GET",
	 	url: "/auctionList.action",
	 	data: params,
	 	dataType:'json',
		success: fillTradeTable
	}); 
}

function goTradePage(){
	var pageValue = getEl('tradePage').value;
	if(isNaN(pageValue)||pageValue==0||pageValue<0){
		 alert('请输入非0正整数！');
		 getEl('tradePage').value = '';
		 getEl('tradePage').focus();
		 return;
	}
	
	if(pageValue>tradePageNo){
		alert('无此页！');
		return;
	}
	
	goTradeByPage(pageValue);
}

function nextTradePage(){
	if(tradePageIndex>=tradePageNo)
		return;
	
	tradePageIndex++;
	goTradeByPage(tradePageIndex);
}

function preTradePage(){
	if(tradePageIndex==1)
		return;
	
	tradePageIndex--;
	goTradeByPage(tradePageIndex);
}

function beginTradePage(){
	
	if(tradePageIndex==1)
		return;
	
	tradePageIndex=1;
	goTradeByPage(tradePageIndex);
}

function endTradePage(){
	if(tradePageIndex>=tradePageNo)
		return;
	
	tradePageIndex=tradePageNo;
	goTradeByPage(tradePageIndex);
}

function tradeRelease(){
	switch(bargainType){
		case BUSS:					window.open("/gotoBuyRolePage.action",false); 	break;
		case BUSS_BUY:			window.open("/gotoSellRolePage.action",false);	break;
		case GOLD:					window.open("/gotoBuyGoldPage.action",false);	break;
		case GOLD_BUY:			window.open("/gotoGoldPage.action",false);			break;
		case DOTCART:				window.open("/gotoBuyCardPage.action",false);	break;
		case DOTCART_BUY:	window.open("/gotoCardPage.action",false);			break;
		case PROP:						window.open("/gotoBuyEquipmentPage.action",false);		break;
		case PROP_BUY:			window.open("/gotoEquipmentPage.action",false);			break;
		case DAILIAN_SEND:		window.open("/gotoMentorRequestRolePage.action",false);	break;
		case DAILIAN_RECEIVE:	window.open("/gotoMentorRenderPage.action",false);			break;
		case TENANCY:					window.open("/gotoRentRequestRolePage.action",false);			break;
		case TENANCY_REQUEST:	window.open("/gotoRentRenderRolePage.action",false);	break;
		case EXCHANGE:		window.open("/gotoExchangeRolePage.action",false);						break;
		case OTHERS_SELL:		window.open("/gotoBuyOtherThingsPage.action",false);		break;
		case OTHERS_BUY:		window.open("/gotoOtherThingsPage.action",false);		break;
	}
}

function getBargainType(id){
	switch(id){
		case 1:		return DOTCART; 
		case 2:	return DOTCART_BUY; 
		case 3:	return TENANCY_REQUEST;	
		case 4:	return TENANCY;	
		case 5:	return EXCHANGE;
		case 6:	return DAILIAN_RECEIVE;	
		case 7:	return DAILIAN_SEND;		
		default:	return -1;
	}
}

function shiftGame(idx){
	switch(idx){
		case 0:
			if(curGameIndex=='#defaultGames') return;
			$(curGameIndex).fadeOut('fast',function(){
				$('#defaultGames').fadeIn('fast');
				curGameIndex = '#defaultGames';
			});
			break;
		case 1:
			if(curGameIndex=='#coopGames') return;
			$(curGameIndex).fadeOut('fast',function(){
				$('#coopGames').fadeIn('fast');
				curGameIndex = '#coopGames';
			});
			break;
		case 2:
			if(curGameIndex=='#pcGames') return;
			$(curGameIndex).fadeOut('fast',function(){
				$('#pcGames').fadeIn('fast');
				curGameIndex = '#pcGames';
			});
			break;
		case 3:
			if(curGameIndex=='#ngGames') return;
			$(curGameIndex).fadeOut('fast',function(){
				$('#ngGames').fadeIn('fast');
				curGameIndex = '#ngGames';
			});
			break;
	}
}

function menuStyle(id,type){
	switch(id){
		case 2:
			$('#clubIcon').css('background',type==1?'url("/images/home/club.jpg") no-repeat':'');
			break;
		case 3:
			$('#forumIcon').css('background',type==1?'url("/images/home/forum.jpg") no-repeat':'');
			break;
		case 4:
			$('#blogIcon').css('background',type==1?'url("/images/home/blog.jpg") no-repeat':'');
			break;
	}
}

function nextArticlePage(type){
	if(type==1)
		loadArticlePage(type,articlePageIndex_1,true);
	else if(type==2)
		loadArticlePage(type,articlePageIndex_2,true);
	else if(type==3)
		loadArticlePage(type,articlePageIndex_3,true);
}

function preArticlePage(type){
	if(type==1)
		loadArticlePage(type,articlePageIndex_1,false);
	else if(type==2)
		loadArticlePage(type,articlePageIndex_2,false);
	else if(type==3)
		loadArticlePage(type,articlePageIndex_3,false);
}

function goArticlePage(type){
	var index = getEl('articlePage_'+type).value;
	
	if(isNaN(index)||index==0||index<0){
		 alert('请输入非0正整数！');
		 getEl('articlePage_'+type).value = '';
		 getEl('articlePage_'+type).focus();
		 return;
	}

	if(type==1)
		articlePageIndex_1 = index;
	else if(type==2){
		articlePageIndex_2 = index;
		initType_2 = true;
	}else if(type==3){
		initType_3 = true;
		articlePageIndex_3 = index;
	}
	
	articleFlag = 2;
	curType = type;
	params = "type="+type+'&pIdx='+index;
	//lockButton();
	jQuery.ajax({
	 	type: "GET",
	 	url: "/loadForumMsg.action",
	 	data: params,
	 	dataType:'json',
		success: fillArticleTable
		//complete: unLockButton
	}); 
}

function loadArticlePage(type,idx,dir){
	var params = "";
	var index = 1;
	if(type==1){
		//normal articles
		if(dir)
			index = ++articlePageIndex_1;
		else{
			if(articlePageIndex_1==1){
				alert('已经到首页！');
				return;
			}
			
			index = --articlePageIndex_1;
		}//end of else
	}else if(type==2){
		//elite articles
		if(dir)
			index = ++articlePageIndex_2;
		else{
			if(articlePageIndex_2==1){
				alert('已经到首页！');
				return;
			}
			
			index = --articlePageIndex_2;
		}//end of else
	}else if(type==3){
		//hot articles
		if(dir)
			index = ++articlePageIndex_3;
		else{
			if(articlePageIndex_3==1){
				alert('已经到首页！');
				return;
			}
			
			index = --articlePageIndex_3;
		}//end of else
	}
	
	articleFlag = 1;
	curType = type;
	params = "type="+type+'&pIdx='+index;
	//lockButton();
	jQuery.ajax({
	 	type: "GET",
	 	url: "/loadForumMsg.action",
	 	data: params,
	 	dataType:'json',
		success: fillArticleTable
		//complete: unLockButton
	}); 
}

function preCheck(type){
	if(type==2){
		if(initType_2) return;
		goArticlePage(2);
	}else if(type==3){
		if(initType_3) return;
		goArticlePage(3);
	}
}

/*function lockButton(){
	getEl('articleLoading_'+curType).style.visibility='visible';
	
	$('#forumIndexData .go').each(function(){
		this.disabled = true;
	});
	$('#forumIndexData .pre').each(function(){
		this.disabled = true;
	});
	$('#forumIndexData .next').each(function(){
		this.disabled = true;
	});
}*/

/*function unLockButton(){
	getEl('articleLoading_'+curType).style.visibility='hidden';
	getEl('articlePage_'+curType).value = '';
	
	$('#forumIndexData .go').each(function(){
		this.disabled = false;
	});
	$('#forumIndexData .pre').each(function(){
		this.disabled = false;
	});
	$('#forumIndexData .next').each(function(){
		this.disabled = false;
	});
}*/

function fillArticleTable(o){
	switch(curType){
		case 1:
			if(o.length==0){
				if(articleFlag==1){
					articlePageIndex_1--;
					alert('已经到最后一页！');
				}else if(articleFlag==2){
					alert('无此页！');
					getEl('articlePage_1').value = 1;
					goArticlePage(1);
				}
				return;
			}
			
			var tbObj = getEl('newArticleTbody');
			clearTable(tbObj);
			buildArticleTable(tbObj,o);
			getEl('articlePageInfo_1').innerText = '当前第 '+articlePageIndex_1+' 页';
			break;
		case 2:
			if(o.length==0){
				if(articleFlag==1){
					articlePageIndex_1--;
					alert('已经到最后一页！');
				}else if(articleFlag==2){
					alert('无此页！');
					getEl('articlePage_2').value = 1;
					goArticlePage(2);
				}
				return;
			}
			
			var tbObj = getEl('wellArticleTbody');
			clearTable(tbObj);
			buildArticleTable(tbObj,o);
			getEl('articlePageInfo_2').innerText = '当前第 '+articlePageIndex_2+' 页';
			break;
		case 3:
			if(o.length==0){
				if(articleFlag==1){
					articlePageIndex_1--;
					alert('已经到最后一页！');
				}else if(articleFlag==2){
					alert('无此页！');
					getEl('articlePage_3').value = 1;
					goArticlePage(3);
				}
				return;
			}
			
			var tbObj = getEl('hotArticleTbody');
			clearTable(tbObj);
			buildArticleTable(tbObj,o);
			getEl('articlePageInfo_3').innerText = '当前第 '+articlePageIndex_3+' 页';
			break;
	}
	
	if(browserInfo.Name=='Firefox')
		firefox_enhance();
		
	synArticleButton();
}

function buildArticleTable(tbObj,data){
	for(var i=0;i<data.length;i++){
		row=tbObj.insertRow(-1);
		
		cell = row.insertCell(-1);
		cell.innerHTML = '<a target="_blank" href="/cwbbs/forum/t-0-'+data[i].id+'-1.html" class="articleTitle">'+data[i].title+'</a>';
		
		/*cell = row.insertCell(-1);
		cell.align='center';
		cell.innerHTML = data[i].author;
		
		
		cell = row.insertCell(-1);
		cell.align='center';
		cell.innerHTML = data[i].redate.substring(3,14);
		
		cell = row.insertCell(-1);
		cell.align='center';
		cell.innerHTML = data[i].hit+" / "+data[i].reply;*/
		//cell.innerHTML = data[i].hit;
		
		//cell = row.insertCell(-1);
		//cell.align='center';
		//cell.innerHTML = data[i].reply;
		
		//cell = row.insertCell(-1);
		//cell.innerHTML = '<a target="_blank" class="articleBoard" href="/cwbbs/forum/f-0-'+data[i].boardCode+'-1-0.html"">'+data[i].board+'</a>';
		
		//cell = row.insertCell(-1);
		//cell.style.paddingLeft='20px';
		//cell.align='center';
		//cell.innerHTML = data[i].date;
	}
}

function showTradeImg(path){ 
	if(path=='') return;
	
	if (browserInfo.Version == 6.0){ window.open(path); return;}
	getEl('previewImg').src=path;
}

function closePreview(){
	getEl('previewImg').src='';
}

//function showClubTheme(skin){window.open('http://'+skin+'.ngamebar.com');}

function showGroup(gId){ window.open('/showTheme.action?gId='+gId);}
function showNews(nId,canshu){ window.open('/readNews.action?newsID='+nId+'&canshu='+canshu);}
function showvideo(id,path,type){window.open('/showvideo.action?id='+id+'&path='+path+'&type='+type);}
function playvideo(id){window.open('/playVideo.action?id='+id);}
function exitLogin(){
	jQuery.ajax({
	 	type: "GET",
	 	url:  '/cwbbs/exit.jsp',
	 	dataType:'html'
	});
	
	jQuery.ajax({
	 	type: "GET",
	 	url: '/logUserOut.action',
	 	dataType:'html',
	 	success: function(o){
	 		$("#loginFrame").src="/cwbbs/gamebar_login.jsp";
	 		$("#servers").css("display","none");
	 		if(!window.frames["loginFrame"].document.getElementById('loginArea'))
	 			window.location.reload();
	 	}
	});
}


function preBeginArticlePage(type){
	switch(type){
		case 1:
		if(articlePageIndex_1==1) return;
		else	getEl('articlePage_1').value=1;
		break;
		case 2:
		if(articlePageIndex_2==1) return;
		else	getEl('articlePage_2').value=1;
		break;
		case 3:
		if(articlePageIndex_3==1) return;
		else	getEl('articlePage_3').value=1;
		break;
	}
	
	goArticlePage(type);
}

function nextEndArticlePage(type){
	var params = 'pageSize=20&type='+type;
	jQuery.ajax({
	 	type: "GET",
	 	url: "/findArticleEndPage.action",
	 	data: params,
	 	dataType:'html',
		success: function(o){
			var index = parseInt(o);
			switch(type){
				case 1:getEl('articlePage_1').value=index;articlePageNo_1 = index;
				break;
				case 2:getEl('articlePage_2').value=index;articlePageNo_2 = index;
				break;
				case 3:getEl('articlePage_3').value=index;articlePageNo_3 = index;
				break;
			}
	
			goArticlePage(type);
		}
	}); 
}

var clubTimeObj;
var clubScrollSpeed=10;
var clubLock = 0;
function clubIconUp(){
	if(clubLock>0) return;
	clubLock = 50;
	clubTimeObj=setInterval('clubGoUp()',clubScrollSpeed)
}

function clubGoUp(){
	clubLock-=2;
	if(clubLock==0) clearInterval(clubTimeObj);
}

function clubGoDown(){
	clubLock-=2;
	if(clubLock==0) clearInterval(clubTimeObj);
}

function clubIconDown(){
	if(clubLock>0) return;
	clubLock = 50;
	clubTimeObj=setInterval('clubGoDown()',clubScrollSpeed)
}


function synArticleButton(){
	switch(curType){
		case 1:
			$('#article_first_1').removeClass();
			$('#article_pre_1').removeClass();
			$('#article_next_1').removeClass();
			$('#article_last_1').removeClass();
			
			$('#article_first_1').addClass('pre_begin');
			$('#article_pre_1').addClass('pre');
			$('#article_next_1').addClass('next');
			$('#article_last_1').addClass('next_end');
		
			if(articlePageIndex_1==1){
				$('#article_first_1').removeClass();
				$('#article_pre_1').removeClass();
				$('#article_first_1').addClass('first_disable');
				$('#article_pre_1').addClass('pre_disable');
			}
			
			if(articlePageIndex_1==articlePageNo_1&&articlePageNo_1>0){
				$('#article_next_1').removeClass();
				$('#article_last_1').removeClass();
				$('#article_next_1').addClass('next_disable');
				$('#article_last_1').addClass('end_disable');
			}
			break;
		case 2:
			$('#article_first_2').removeClass();
			$('#article_pre_2').removeClass();
			$('#article_next_2').removeClass();
			$('#article_last_2').removeClass();
			
			$('#article_first_2').addClass('pre_begin');
			$('#article_pre_2').addClass('pre');
			$('#article_next_2').addClass('next');
			$('#article_last_2').addClass('next_end');
		
			if(articlePageIndex_2==1){
				$('#article_first_2').removeClass();
				$('#article_pre_2').removeClass();
				$('#article_first_2').addClass('first_disable');
				$('#article_pre_2').addClass('pre_disable');
			}

			if(articlePageIndex_2==articlePageNo_2&&articlePageNo_2>0){
				$('#article_next_2').removeClass();
				$('#article_last_2').removeClass();
				$('#article_next_2').addClass('next_disable');
				$('#article_last_2').addClass('end_disable');
			}
			break;
		case 3:
			$('#article_first_3').removeClass();
			$('#article_pre_3').removeClass();
			$('#article_next_3').removeClass();
			$('#article_last_3').removeClass();
			
			$('#article_first_3').addClass('pre_begin');
			$('#article_pre_3').addClass('pre');
			$('#article_next_3').addClass('next');
			$('#article_last_3').addClass('next_end');
		
			if(articlePageIndex_3==1){
				$('#article_first_3').removeClass();
				$('#article_pre_3').removeClass();
				$('#article_first_3').addClass('first_disable');
				$('#article_pre_3').addClass('pre_disable');
			}
			
			if(articlePageIndex_3==articlePageNo_3&&articlePageNo_3>0){
				$('#article_next_3').removeClass();
				$('#article_last_3').removeClass();
				$('#article_next_3').addClass('next_disable');
				$('#article_last_3').addClass('end_disable');
			}
	}
}

function showMsg(id,width,height,o){
    var msgurl="/cwbbs/message/message.jsp?msgId="+id;
  	var url = 'cancelNote.action';
  	var params = "msgId="+id;
	try{o.parentNode.removeChild(o);}catch(e){};
	window.open(msgurl,"_blank","toolbar=no,scroll=auto,location=no,directories=no,status=no,menubar=no,top=120,left=120,width="+width+",height="+height);
}

