var current = null;
var def = 12;
var max = 20;
var min = 6;
var count = null;
var to = null;

function bigger() {
	if (current == null)
		current = def;
	if (current < max)
		document.getElementById("bodytext").className = "size"+(++current);
}

function smaller() {
	if (current == null)
		current = def;
	if (current > min)
		document.getElementById("bodytext").className = "size"+(--current);

}

function send(lng, dp, fl, pg) {
	window.open("send.php?lng="+lng+"&dp="+dp+"&fl="+fl+"&pg="+pg, "send", "width=400,height=300");
}

function toggle(id) {
	document.getElementById("sub" + id).className = (document.getElementById("sub" + id).className == "open" ? "" : "open");
}

function prev(id) {
	if (document.getElementById("article" + id)) {
		document.getElementById("article" + id).className = "article";
	}
	next((id - 2 > 0 ? id - 2 : count - (id - 2)));
}

function next(id) {
	if (document.getElementById("article" + id)) {
		document.getElementById("article" + id).className = "article";
	}

	if (id == count && count > 1) {
		fadeToDiv(document.getElementById("article1"));
		id = 1;
	} else if (id <= count - 1)
		fadeToDiv(document.getElementById("article" + ++id));

	if (to)
		clearTimeout(to);
	to = setTimeout("next(" + id + ")", 11000);
}

function fadeToDiv(divToRevealObj) {
  setOpacity(divToRevealObj.id, 0);
  divToRevealObj.className = "article current";
  fadeInDiv(divToRevealObj.id,0);
}
function fadeInDiv(divId, opacity) {
  if (opacity <= 100) {
	setOpacity(divId, opacity);
	opacity += 5;
	fade = window.setTimeout("fadeInDiv('"+divId+"',"+opacity+")", 110);
  }
}
function setOpacity(divId, opacity) {
  var div = document.getElementById(divId);
  opacity = (opacity == 100)?99.999:opacity;
  div.style.filter = "alpha(opacity:"+opacity+")";
  div.style.KHTMLOpacity = opacity/100;
  div.style.MozOpacity = opacity/100;
  div.style.opacity = opacity/100;
}
onload = function() {
	count = document.getElementById("articles").className.replace(/[^\d]/g, "");
	count = (isNaN(count) ? 0 : count*1);
	next(1);
};


function show(id) {
  document.getElementById("data" + id).style.zIndex =200;
//  document.getElementById("data" + id).className = "shown";
}
function hide(id) {
//  document.getElementById("data" + id).className = "";
}