var showTimer = false;
var hideTimer = false;
var opened = false;
var followTimer;
var maxRight;
var innerBig;

var timerGalery=window.setInterval("topNext();",15000);

function showTopNews(showItem) {
	currItem = showItem; 
	$("img#iTop").fadeOut(200, function() {
		this.style.visibility = "hidden";
		this.src = "";		
		this.src = top_array[currItem].i;
		this.title = top_array[currItem].t;
		this.alt = top_array[currItem].t;
		this.style.visibility = "visible";
		$(this).fadeIn(200);
	});	

	$("a.topHref").each(function() { $(this).attr("href", top_array[currItem].h); });
	$("#top_bg a").html(top_array[currItem].c).attr("href", top_array[currItem].h);
	//$("p#mainLead").html(top_array[currItem].l);
    $("p#mainLead a").html(top_array[currItem].l).attr("href", top_array[currItem].h);

	$("span.container > img").each(function(i) { 
		if (i != currItem) {
			$(this).removeClass("curent");
		} else {
			$(this).addClass("curent");		
		}
	});
}

  

function topPrev() {
	currItem = (currItem == 0) ? totalItems : (currItem - 1);
	showTopNews(currItem);
}

function topNext() {
	currItem = (currItem == totalItems) ? 0 : (currItem + 1);
	showTopNews(currItem);
}

function topArt ( show , cObj ){
	if(cObj) 
		$("#" + cObj).get(0).style.filter = show ? 'alpha(opacity=100)' : 'alpha(opacity=50)';
    $("span#croper_bg").css({visibility: (show ? "visible"  : "hidden") });
    $("span#croper").css({visibility: (show ? "visible"  : "hidden") });

}

function loadTopArt(showItem) {
    if (!showTimer)
        showTimer = setTimeout(function() { showTopNews(showItem) }, 200);
}

function unloadTopArt() {
    if (showTimer) {
        clearTimeout(showTimer); showTimer = false;
    }
}
