adressArray=new Array();
articleNumArray=new Array();
function ViewResponse(a){
var myresponse = document.getElementById(("ResList"+a));
if(myresponse.style.display=="block"){
myresponse.style.display="none";
}else{
myresponse.style.display="block";
}

}
function dlcView(a,b){
var viewelement = document.getElementById(b);
viewelement.innerHTML = a-1000000000; 
}
function getMovie(movieName){
if (navigator.appName.indexOf("Microsoft") != -1) {
	return window[movieName];
}else {
	return document[movieName]
}
}
function dlcount(a,b){
pluginName=getMovie("externalFlash");
pluginName.dl_c(articleNumArray[a]);
location.href=adressArray[b];
}
function res(a){
pluginName=getMovie("externalFlash");
pluginName.res(a);
window.scrollTo(0,0);
}
function viewNew(a){
pluginName=getMovie("externalFlash");
pluginName.viewNew(a);
window.scrollTo(0,400);
}
function viewOld(a){
pluginName=getMovie("externalFlash");
pluginName.viewOld(a);
window.scrollTo(0,400);
}
function delThread(a,b){
pluginName=getMovie("externalFlash");
pluginName.delThread(a,b);
window.scrollTo(0,0);
}
function delRes(a,b){
pluginName=getMovie("externalFlash");
pluginName.delRes(a,b);
window.scrollTo(0,0);
}
function createPack(a){
bbsPack=document.createElement('ul');
bbsPack.id="bbspack";
objBody=document.getElementById("bbs");
objBody.appendChild(bbsPack);
}
function clearALL(a){
objBody.removeChild(bbsPack);
}
//文字列を数字に変える
function stringToNumber(a) {
	temporaryNumber2 = 0;
	iSTN = 0;
	while (iSTN<a.length) {
	temporaryNumber1=a.charCodeAt(a.length-iSTN-1)-30;
		temporaryNumber2 += temporaryNumber1*Math.pow(10, iSTN);
		iSTN += 1;
	}
	return temporaryNumber2;
}
function viewThread(a){
//スレッドを作成
var thread=document.createElement('li');
var threadObj=a;
thread.className="threadItem";
thread.id = threadObj.stringNumber;
var temparticleList=document.createElement('ul');
temparticleList.className="articleList";
var temparticleListB=document.createElement('ul');
temparticleListB.className="articleList";
temparticleListB.id="ResList"+thread.id;
var i=0;
while(i<threadObj.articleArray.length){
	var article=document.createElement('li');
	var tempArticle=threadObj.articleArray[i];
//bbs------------------------------------
//bbspack----------------------------
//ThreadItem-----------------------
//non-named----------------
//Thread/ResponseTop
//subtitle
//articleMain--------
//bbsicon
//bbsstatus
//bbsmessage
//articleMain--------
//non-named----------------
//ThreadDiv-----------------------
//bbspack----------------------------
//bbs------------------------------------
//
	if(i===0){
		article.className="article";
		var html1="<div class='head'>■[No."+(stringToNumber(thread.id)-210000000000)+"] ";
		var html1_2="<span class='Title'>"+tempArticle.title+"</span></div>";
		var html1_3="<div class='subtitle'>"+tempArticle.date+"　　<button onclick='res("+thread.id+");'>Response</button>";
		var html1_5="<button onclick='delThread("+thread.id+","+tempArticle.number+");'>Delete this thread</button>";
		var html1_7="<button onclick='ViewResponse("+thread.id+");'>View Response</button></div>";
		var html2="<div class='articleMain'><div class='bbsicon'>";
	}else{
		article.className="responseArticle";
		var html1="<div class='headTab'></div><div class='head'>■[Res:"+threadObj.articleArray[0].title+"] ";
		var html1_2="<span class='Title'>"+tempArticle.title+"</span></div>";
		var html1_3="<div class='subTab'></div><div class='subtitle'>"+tempArticle.date+"　　<button onclick='res("+thread.id+");'>Response</button>";
		var html1_5="<button onclick='delRes("+thread.id+","+tempArticle.number+");'>Delete this response</button></div>";
		var html1_7="";
		var html2="<div class='articleMain'><div class='mainTab'></div><div class='bbsicon'>";
	}


	if(tempArticle.icon=="undefined"||tempArticle.icon=="null"||tempArticle.icon===undefined){
		var html2_5="<img src='http://pxtone.haru.gs/fileup/allicon/icon22.jpg' /></div>";
	}else{
		var html2_5="<img style='margin:5px;' src='http://pxtone.haru.gs/fileup/allicon/icon"+tempArticle.icon+".png' /></div>";
	}
	if(tempArticle.website=="＊：設定しなくてもかまいません"||tempArticle.website===""||tempArticle.website=="null"){
		var html3="<div class='bbsstatus'><p><b>Name:"+tempArticle.writer+"</b><br /><br />";
	}else{
		var html3="<div class='bbsstatus'><p><b>Name:"+tempArticle.writer+"</b><br /><a href="+tempArticle.website+" target='_top'>Website</a><br />";
	}
	if(tempArticle.filesize=="undefined"){
		var html4="添付ファイルなし";
		var html5="</p></div>";
		var html5_3="";
	}else{
		adressArray.push("http://pxtone.haru.gs/fileup/file/"+tempArticle.fileadress);
		articleNumArray.push((thread.id+"_"+tempArticle.number));
		var dln=0;
		var html4="添付ファイル：<a href='javascript:void(0);' onclick='dlcount("+(articleNumArray.length-1)+","+(adressArray.length-1)+");'>";
		var html5=tempArticle.filetype+"("+Math.floor(tempArticle.filesize/100)/10+"kb)</a><br />";
		var html5_3="ダウンロード数：<span id='"+thread.id+"_"+tempArticle.number+"'>読み込み中</span></p></div>";
	}
	var html5_5="<div class='supporter'>♪<br />♪<br />♪<br />♪<br />♪</div>";
	if(tempArticle.autograph=="undefined"||tempArticle.autograph===undefined){
		var html6="<div class='bbsmessage'><p>"+tempArticle.message+"<br /></p></div>";
	}else{
		var html6="<div class='bbsmessage'><p>"+tempArticle.message+"<br /></p><hr />"+tempArticle.autograph+"</div>";
	}
	var html7="</div>";
	article.innerHTML=html1+html1_2+html1_3+html1_5+html1_7+html2+html2_5+html3+html4+html5+html5_3+html5_5+html6+html7;
if(i===0){
	temparticleList.appendChild(article);
}else{
	temparticleListB.appendChild(article);
}
	i++;
}
thread.appendChild(temparticleList);
temparticleListB.style.display="none";
thread.appendChild(temparticleListB);

bbsPack.appendChild(thread);
}
