ci = 1;
ai = 4;
function change_image (i) {
	if(parseInt(i,10)) {
		document.getElementById("data").style.backgroundImage = "url('/images/people/" + i + ".jpg')";
	}
}

$(function () {
	var p = 0,
		q = $("#quiz"),
		w = q.width(),
		i = q.children(".items"),
		c = i.children().width(w).length;
	i.width(w * c);
	q.children(".menu")
		.bind("click", function (e) {
			e.preventDefault();
			var t = $(e.currentTarget).blur();
			if(t.hasClass("left")) {
				p++;
				if(p >= c) {
					p --;
					i.css("left", "-" + w*(p-1) + "px").children(".item:eq(0)").appendTo(i);
				}
				change_image(i.children(".item:eq(" + p + ")").attr("rel"));
				i.stop().animate({"left": "-" + w*p }, 500);
			}
			else {
				p--;
				if(p < 0) {
					p ++;
					i.css("left", "-" + w*(p+1) + "px").children(".item:last-child").prependTo(i);
				}
				change_image(i.children(".item:eq(" + p + ")").attr("rel"));
				i.stop().animate({"left": "-" + w*p }, 500);
			}
	});
	change_image(i.children(".item:eq(0)").attr("rel"));

	var k = 0,
		n = $("#news"),
		d = $("#news").children(".hnews"),
		m = d.length;

	d.filter(":gt(0)").hide();
	n.children(".scroll")
		.bind("click", function (e) {
			// if(inter) clearInterval(inter);
			e.preventDefault();
			var t = $(e.currentTarget).blur();
			if(t[0].id == "right_scroll") { 
				k ++; 
				if(k >= m) k = 0;
			}
			else { 
				k --;
				if(k < 0) k = (m-1);
			}
			d.filter(":visible").fadeOut();
			d.filter(":eq(" + k + ")").fadeIn();
	});
	var inter = setInterval(function () {
		$("#news .scroll:eq(0)").click();
		$("#quiz .left").click();
	}, 10000);

	var mh = 0, h = [];
	$(".home_columns .column")
		.each(function () { var ch = $(this).height(); h.push(ch); mh = Math.max(mh, ch); })
		.children("li:last-child").height(function (i, j) { return j + (mh - h[i]); });
});
