var ie = (window.navigator.appName == "Microsoft Internet Explorer");
var selectedWriterType;
var selectedType;
var currentText = "";
var index = 0;
var loading = null;
var selectedArticle = null;
var issueColor,eachTimeCharCount;
var tempTitle = null;
var empty = "<img src=\"i/dot.gif\" width=\"100%\" height=\"5\" />";
function openArticle(articleId){
	openIt = true;
	if(selectedArticle == articleId && selectedType == 1) openIt = false;
		closeAll();
	if(openIt){
		selectedType = 1;
		selectedArticle = articleId;
		document.getElementById("tr"+articleId).style.backgroundColor = "#000000";
		eA = document.getElementById("a"+articleId);
		eA.style.color = "#F83E0D";
		tempTitle = eA.innerHTML;
		eA.innerHTML = "<img src=\"i/dot.gif\" width=\"5\" height=\"1\">Yazı özeti yükleniyor";
		document.getElementById("w"+articleId).style.color = issueColor;
		document.getElementById("articleContent").src = "getarticle.php?id="+articleId;
	}
}
function openWriter(articleId){
	selectedWriterType = 1;
	openIt = true;
	if(selectedArticle == articleId && selectedType == 2) openIt = false;
		closeAll();
	if(openIt){
		selectedType = 2;
		selectedArticle = articleId;
		document.getElementById("tr"+articleId).style.backgroundColor = "#000000";
		eW = document.getElementById("w"+articleId);
		eW.style.color = issueColor;
		tempTitle = eW.innerHTML;
		eW.innerHTML = "<img src=\"i/dot.gif\" width=\"12\" height=\"1\">Yazar sayfası yükleniyor";
		document.getElementById("a"+articleId).style.color = "#F83E0D";
		document.getElementById("articleContent").src = "getwriter.php?id="+articleId;
	}
}
function openWriter2(writerId){
	selectedWriterType = 2;
	openIt = true;
	if(selectedArticle == writerId) openIt = false;
		closeAll2();
	if(openIt){
		selectedArticle = writerId;
		document.getElementById("tr"+writerId).style.backgroundColor = "#000000";
		eW = document.getElementById("w"+writerId);
		eW.style.color = issueColor;
		tempTitle = eW.innerHTML;
		eW.innerHTML = "<img src=\"i/dot.gif\" width=\"12\" height=\"1\">Yazar sayfası yükleniyor";
		document.getElementById("articleContent").src = "getwriter.php?id="+writerId+"&writerid=1";
	}
}
function closeAll(){
	if(selectedArticle != null){
		eA = document.getElementById("a"+selectedArticle);
		eW = document.getElementById("w"+selectedArticle);
		if(tempTitle != null){
			if(selectedType == 1){
				eA.innerHTML = tempTitle;
			}else{
				eW.innerHTML = tempTitle;
			}
			tempTitle = null;
		}
		document.getElementById("tr"+selectedArticle).style.backgroundColor = "#b3b3b3";
		eA.style.color = "#000000";
		eW.style.color = "#000000";
		document.getElementById("f"+selectedArticle).innerHTML = empty;
		if(loading != null){
			clearInterval(loading);
			loading = null;
		}
		selectedType = 0;
	}
	selectedArticle = null;
}
function closeAll2(){
	if(selectedArticle != null){
		eW = document.getElementById("w"+selectedArticle);
		if(tempTitle != null){
			eW.innerHTML = tempTitle;
			tempTitle = null;
		}
		document.getElementById("tr"+selectedArticle).style.backgroundColor = "#b3b3b3";
		eW.style.color = "#000000";
		document.getElementById("f"+selectedArticle).innerHTML = empty;
		if(loading != null){
			clearInterval(loading);
			loading = null;
		}
	}
	selectedArticle = null;
}

function doHover(id,flag){
	if(id != selectedArticle || flag == true) document.getElementById("tr"+id).style.backgroundColor = issueColor;
}

function doHover2(id,flag){
	document.getElementById("tr"+id).style.backgroundColor = flag;
}

function doNormal(id,flag){
	if(id != selectedArticle || flag == true) document.getElementById("tr"+id).style.backgroundColor = '#b3b3b3';
}

function startLoadingArticle(text){
	document.getElementById("f"+selectedArticle).innerHTML = "<span id=\"fContent\" class=\"articleText\" style=\"position:relative;left:5px; width:95%; color:#C1C1C1\"></span>";
	currentText = text;
	if(ie){
		currentWidth = eval("parent.document.getElementById('"+window.name+"').style.posWidth");
	}else{
		currentWidth = eval("parent.document.getElementById('"+window.name+"').style.width");
		currentWidth = currentWidth.substr(0,currentWidth.length-2);
	}
	eachTimeCharCount = Math.round(currentWidth * 0.12);
	index = 0;	
	loading = setInterval("doLoad()",5);
}
var tempText;
function startLoadingWriter(text){
	document.getElementById("f"+selectedArticle).innerHTML = "<span id=\"fContent\" class=\"articleText\" style=\"position:relative;left:5px; width:99%; color:#C1C1C1\"></span>";
	tempText = currentText = text;
	if(ie){
		currentWidth = eval("parent.document.getElementById('"+window.name+"').style.posWidth");
	}else{
		currentWidth = eval("parent.document.getElementById('"+window.name+"').style.width");
		currentWidth = currentWidth.substr(0,currentWidth.length-2);
	}
	eachTimeCharCount = Math.round(currentWidth * 0.12);
	index = 0;	
	loading = setInterval("doLoad()",5);
}

function doLoad(){
	finished = false;
	if(index+eachTimeCharCount >= currentText.length){
		newEntry = currentText.substr(index);
		finished = true;
	}else{
		newEntry = currentText.substr(index,eachTimeCharCount);
		index += eachTimeCharCount;
	}
	document.getElementById("fContent").innerHTML += newEntry;
	if(finished){
		document.getElementById("fContent").innerHTML += "</p>";
		if(selectedType == 1){
			document.getElementById("a"+selectedArticle).innerHTML = tempTitle;
			document.getElementById("fContent").innerHTML = currentText + "</p>"
		}else{
			tableHTML = "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"40%\" background=\"i/red.gif\" height=\"5\"><img src=\"i/dot.gif\" width=\"1\" height=\"5\"></td><td width=\"+0%\" background=\"i/black.gif\" rowspan=\"3\"><img src=\"i/dot.gif\"></td></tr><tr>";
			if(selectedWriterType == 1) tableHTML += "<td><iframe id=\"waList\" width=\"100%\" scrolling=\"yes\" frameborder=\"0\" allowtransparency=\"true\" src=\"list.php?wa="+selectedArticle+"&issueColor="+issueColor.substr(1)+"\"></iframe></td>";
			if(selectedWriterType == 2) tableHTML += "<td><iframe id=\"waList\" width=\"100%\" scrolling=\"yes\" frameborder=\"0\" allowtransparency=\"true\" src=\"list.php?wa2="+selectedArticle+"&issueColor="+issueColor.substr(1)+"\"></iframe></td>";
			tableHTML += "</tr><tr><td background=\"i/red.gif\" height=\"5\"><img src=\"i/dot.gif\" width=\"1\" height=\"5\"></td></tr></table><br>";
			document.getElementById("fContent").innerHTML += tableHTML;
			document.getElementById("w"+selectedArticle).innerHTML = tempTitle;
		}
		document.getElementById("fContent").style.color="#000000";
		clearInterval(loading);
		loading = null;
	}
}
