
var intRollingTime  = 5000;		// ½½¶óÀÌµå ½Ã°£
var intRollingVert  = 4;		// ½½¶óÀÌµå °¹¼ö ÁöÁ¤
var intThumbWidht   = 105;
var slideVert;
var objSlide;
var slideRotage		= "top";
var bnrSlide;
var bnrNowRow		= 1;
var bnrRowCount		= 0;

// js onload ÇÔ¼ö¿Í °°ÀÌ loding ½Ã Àû¿ëÇÒ ½ºÅ©¸³Æ®
$jquery(document).ready(function() {		
	// ½½¶óÀÌµå ÃÑ ¼ö·®
    slideVert		= $jquery("#divHotThumList").children().length;

	intRollingVert	= ( intRollingVert > slideVert )? slideVert : intRollingVert;
	
	// ÇÖÀÌ½´ ¼ö·®À» È®ÀÎ ÇÏ¿© ½½¶óÀÌµå¿¡ onclick ÇÔ¼ö °­Á¦ Ãß°¡
	// ½½¶óÀÌµå ¼ö·®°ú ÇÖÀÌ½´ ¼ö·®ÀÌ °°¾Æ¾ß ÇÔ.
	// Å¬¸¯½Ã ÇÖÀÌ½´¸¦ º¯°æÇÑ´Ù. display : block , none
	if ( slideVert > 0 ){
		for(var i = 0 ; i < slideVert; i++){
			$jquery("#divHotThumList").find("p[class=ThumCenter]").eq(i).css("cursor","pointer"); 
			$jquery("#divHotThumList").find("p[class=ThumCenter]").eq(i).bind("mouseover", new Function('fnHotissueChange('+i+', this)')  );
		}
	}

	if(  slideVert > 0  ) {
		fnSlideRotate('');
	}
});


// ½½¶óÀÌµå Å¬¸¯¿¡ µû¸¥ ÇÖÀÌ½´ display º¯°æ
function fnHotissueChange(intview, obj){
	if ( $jquery("#divHotissueContent div").length > 0 ){		
		for(var i = 0 ; i < $jquery("#divHotissueContent div").length; i++){
			var op = (  i == intview  )? "block":"none";
			$jquery("#divHotissueContent").find("div").eq(i).css("display",op);			
		}
	}

	for(var i = 0 ; i < $jquery("#divHotThumList").children().length; i++){
		$jquery("#divHotThumList").find("p[class=ThumCenter]").eq(i).css("border","1px solid #EEEEEE");
	}
	$jquery(obj).css("border","1px solid #5CACC0");
}

function fnSlideRotate()
{
	// º¸¿©ÁÙ ½½¶óÀÌµå º¸´Ù ¸¹Àº °æ¿ì ¼û±è
	for (var i = intRollingVert; i < slideVert; i++) {
        $jquery($jquery("#divHotThumList").children()[i]).css("opacity", "0");
    }

	if(  slideRotage == "top"  )
		objSlide	= setInterval(fnSlideUpRotate, intRollingTime);
	else
		objSlide	= setInterval(fnSlideUpRotate, intRollingTime);

	$jquery("#divTodayThumb").mouseover( fnSlideStop );
    $jquery("#divTodayThumb").mouseout( fnSlideMove );
}

function fnSlideUpRotate()
{
    // animate('½ÇÇàÇÒ °á°ú°ª','È¿°ú½Ã°£','linear/swing', 'animate Àû¿ëÈÄ ½ÇÇàÇÒ ÇÔ¼ö')
    $jquery($jquery("#divHotThumList").children()[0]).animate({ opacity: 0 }, 1000, "swing", function() {

        $jquery($jquery("#divHotThumList").children()[0]).animate({ marginLeft: -intThumbWidht }, 1000, "swing", function() {

			$jquery($jquery("#divHotThumList").children()[0]).css("margin", 0);

			$jquery("#divHotThumList").append($jquery($jquery("#divHotThumList").children()[0]));

			$jquery($jquery("#divHotThumList").children()[intRollingVert - 1]).animate({ opacity: 1 }, 1000, "swing");
        });
    });

	var NowObj = $jquery($jquery("#divHotThumList").children()[1]).find("p[class=ThumCenter]");
	var hotissue = NowObj.attr("id").split("_");

	fnHotissueChange(hotissue[1], NowObj);
}

function fnSlideBtnUpRotate()
{
    // animate('½ÇÇàÇÒ °á°ú°ª','È¿°ú½Ã°£','linear/swing', 'animate Àû¿ëÈÄ ½ÇÇàÇÒ ÇÔ¼ö')
    $jquery($jquery("#divHotThumList").children()[0]).animate({ opacity: 0 }, 1000, "swing", function() {

		$jquery($jquery("#divHotThumList").children()[0]).css("margin-left", 0);

		$jquery("#divHotThumList").append($jquery($jquery("#divHotThumList").children()[0]));

		$jquery($jquery("#divHotThumList").children()[intRollingVert - 1]).animate({ opacity: 1 }, 1000, "swing");
    });
}

function fnSlideBtnDownRotate()
{
    // Hide della prima news
    $jquery($jquery("#divHotThumList").children()[intRollingVert-1]).animate({ opacity: 0 }, 1000, "swing", function() {

		$jquery($jquery("#divHotThumList").children()[intRollingVert - 2]).css("margin-right", 0);

		$jquery("#divHotThumList").prepend($jquery($jquery("#divHotThumList").children()[slideVert - 1]));

		$jquery($jquery("#divHotThumList").children()[0]).animate({ opacity: 1 }, 1000, "swing");
	});
}

function fnSlideStop(){
	clearInterval(objSlide);
}

function fnSlideMove(){
	fnSlideRotate();
}


/*
¹è³Ê ·Ñ¸µ
*/
function fnBnrRolling(intRow){
	if( intRow < 0 ) return;
	bnrRowCount = intRow;

	fnBnrRollingTime();
}
function fnBnrRollingTime(){
	bnrSlide	= setInterval(fnBnrRollingStart, 3000);
}
function fnBnrRollingStart(){
	tempRow	  = bnrNowRow + 1;
	bnrNowRow = (  bnrNowRow == bnrRowCount  )? 1 : tempRow;
	fnBnrChange(bnrNowRow);
}
function fnBnrRollingStop(){
	clearInterval(bnrSlide);
}