
var intRollingTime  = 3000;		// ½½¶óÀÌµå ½Ã°£
var intRollingVert  = 4;		// ½½¶óÀÌµå °¹¼ö ÁöÁ¤
var intThumbHeight  = 45;
var slideVert;
var objSlide;
var slideRotage		= "top";

/* ¼­¿ï UCC ¸ÞÀÎ ·Ñ¸µ */
var sUccVert = 1;
function fnPrevContents(argTotal){
	if (  argTotal < 1  ) return false;

	var strdisplay;

	sUccVert = ( sUccVert == 1 ) ? argTotal : sUccVert-1;
	for(idx=1; idx<=argTotal; idx++){
		strdisplay = ( sUccVert == idx )? "block" : "none";
		document.getElementById("SeoulUccBox"+idx).style.display = strdisplay;
	}
}
function fnNextContents(argTotal){
	if (  argTotal < 1  ) return false;

	var strdisplay;

	sUccVert = ( sUccVert == argTotal ) ? 1 : sUccVert+1;
	for(idx=1; idx<=argTotal; idx++){
		strdisplay = ( sUccVert == idx )? "block" : "none";
		document.getElementById("SeoulUccBox"+idx).style.display = strdisplay;
	}
}

/* ¼­¿ï Ä«Å÷ ¸ÞÀÎ ·Ñ¸µ */
var sToonVert = 1;
function fnToonPrevContents(argTotal){
	if (  argTotal < 1  ) return false;

	var strdisplay;

	sToonVert = ( sToonVert == 1 ) ? argTotal : sToonVert-1;
	for(idx=1; idx<=argTotal; idx++){
		strdisplay = ( sToonVert == idx )? "block" : "none";
		document.getElementById("SeoulToonBox"+idx).style.display = strdisplay;
	}
}
function fnToonNextContents(argTotal){
	if (  argTotal < 1  ) return false;

	var strdisplay;

	sToonVert = ( sToonVert == argTotal ) ? 1 : sToonVert+1;
	for(idx=1; idx<=argTotal; idx++){
		strdisplay = ( sToonVert == idx )? "block" : "none";
		document.getElementById("SeoulToonBox"+idx).style.display = strdisplay;
	}
}


// js onload ÇÔ¼ö¿Í °°ÀÌ loding ½Ã Àû¿ëÇÒ ½ºÅ©¸³Æ®
$jquery(document).ready(function() {		
	// ½½¶óÀÌµå ÃÑ ¼ö·®
    slideVert		= $jquery("#divFunThumList").children().length;

	intRollingVert	= ( intRollingVert > slideVert )? slideVert : intRollingVert;
	
	// ÇÖÀÌ½´ ¼ö·®À» È®ÀÎ ÇÏ¿© ½½¶óÀÌµå¿¡ onclick ÇÔ¼ö °­Á¦ Ãß°¡
	// ½½¶óÀÌµå ¼ö·®°ú ÇÖÀÌ½´ ¼ö·®ÀÌ °°¾Æ¾ß ÇÔ.
	// Å¬¸¯½Ã ÇÖÀÌ½´¸¦ º¯°æÇÑ´Ù. display : block , none
	if ( slideVert > 0 ){
		for(var i = 0 ; i < slideVert; i++){
			$jquery("#divFunThumList").find("p[class=ThumCenter]").eq(i).css("cursor","pointer"); 
			$jquery("#divFunThumList").find("p[class=ThumCenter]").eq(i).bind("mouseover", new Function('fnHotissueChange('+i+', this)')  );
		}
	}

	if(  slideVert > 0  ) {
		fnSlideRotate('');
	}
});


// ½½¶óÀÌµå Å¬¸¯¿¡ µû¸¥ ÇÖÀÌ½´ display º¯°æ
function fnHotissueChange(intview, obj){
	if ( $jquery("#divTodayHotissue div").length > 0 ){		
		for(var i = 0 ; i < $jquery("#divTodayHotissue div").length; i++){
			var op = (  i == intview  )? "block":"none";
			$jquery("#divTodayHotissue").find("div").eq(i).css("display",op);			
		}
	}

	for(var i = 0 ; i < $jquery("#divFunThumList").children().length; i++){
		$jquery("#divFunThumList").find("p[class=ThumbLeft]").eq(i).html("&nbsp;");
		$jquery("#divFunThumList").find("p[class=ThumbRight]").eq(i).html("&nbsp;");
	}
	$jquery(obj).prev().html('<img src="http://image2.pullbbang.com/pull30/fun/fun09_06_01.gif" width="9" height="45" alt="" />');
	$jquery(obj).next().html('<img src="http://image2.pullbbang.com/pull30/fun/fun09_06_02.gif" width="9" height="45" alt="" />');
}

function fnSlideRotate()
{
	// º¸¿©ÁÙ ½½¶óÀÌµå º¸´Ù ¸¹Àº °æ¿ì ¼û±è
	for (var i = intRollingVert; i < slideVert; i++) {
        $jquery($jquery("#divFunThumList").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("#divFunThumList").children()[0]).animate({ opacity: 0 }, 1000, "swing", function() {

        $jquery($jquery("#divFunThumList").children()[0]).animate({ marginTop: -intThumbHeight }, 1000, "swing", function() {

			$jquery($jquery("#divFunThumList").children()[0]).css("margin", 0);

			$jquery("#divFunThumList").append($jquery($jquery("#divFunThumList").children()[0]));

			$jquery($jquery("#divFunThumList").children()[intRollingVert - 1]).animate({ opacity: 1 }, 1000, "swing");
        });
    });

	var NowObj = $jquery($jquery("#divFunThumList").children()[1]).find("p[class=ThumCenter]");
	var hotissue = NowObj.attr("id").split("_");

	fnHotissueChange(hotissue[1], NowObj);
}

function fnSlideBtnUpRotate()
{
    // animate('½ÇÇàÇÒ °á°ú°ª','È¿°ú½Ã°£','linear/swing', 'animate Àû¿ëÈÄ ½ÇÇàÇÒ ÇÔ¼ö')
    $jquery($jquery("#divFunThumList").children()[0]).animate({ opacity: 0 }, 1000, "swing", function() {

		$jquery($jquery("#divFunThumList").children()[0]).css("margin", 0);

		$jquery("#divFunThumList").append($jquery($jquery("#divFunThumList").children()[0]));

		$jquery($jquery("#divFunThumList").children()[intRollingVert - 1]).animate({ opacity: 1 }, 1000, "swing");
    });
}

function fnSlideBtnDownRotate()
{
    // Hide della prima news
    $jquery($jquery("#divFunThumList").children()[intRollingVert-1]).animate({ opacity: 0 }, 1000, "swing", function() {

		$jquery($jquery("#divFunThumList").children()[intRollingVert - 2]).css("margin-bottom", 0);

		$jquery("#divFunThumList").prepend($jquery($jquery("#divFunThumList").children()[slideVert - 1]));

		$jquery($jquery("#divFunThumList").children()[0]).animate({ opacity: 1 }, 1000, "swing");
	});
}

function fnSlideStop(){
	clearInterval(objSlide);
}

function fnSlideMove(){
	fnSlideRotate();
}

