//Í¼Æ¬¹ö¶¯¿ò1 (¶ÀÁ¢js)
var _sto = setInterval;
var timer1;
window.setInterval = function(callback,timeout,param) {
    var args = Array.prototype.slice.call(arguments,2);
    var _cb = function() {
        callback.apply(null,args);
    }
    timer1 = _sto(_cb,timeout);
}

function moveElement(elementId, final_x, final_y, interval) {
    var elem = document.getElementById(elementId);
    if(elem.movement) {
		clearTimeout(elem.movement);
	}
	if(!elem.style.left) {
		elem.style.left = '0px';
	}
	if(!elem.style.top) {
		elem.style.top = '0px';
	}
	var xpos = parseInt(elem.style.left);
	var ypos = parseInt(elem.style.top);
    if (xpos == final_x && ypos == final_y) {return true;}
    if (xpos < final_x) {
		var dist = Math.ceil((final_x - xpos)/15);
	    xpos = xpos + dist;
	}
	if (xpos > final_x) {
		var dist = Math.ceil((xpos - final_x)/15);
	    xpos = xpos - dist;
	}
	if (ypos < final_y) {
		var dist = Math.ceil((final_y - ypos)/15);
		ypos = ypos + dist;
	}
	if (ypos > final_y) {
		var dist = Math.ceil((ypos - final_y)/15);
		ypos = ypos - dist;
	}
	elem.style.left = xpos + 'px';
	elem.style.top = ypos + 'px';
	var repeat = "moveElement('" + elementId + "'," + final_x + "," + final_y + "," + interval + ")";
    elem.movement = setTimeout(repeat, interval);
}

var $now = 1;

function autoScroll(id1, id2, $len, $dis) {
    for(i=0; i<$len; i++) {
	    id2[i].className = '';
	}
	id2[$now].className = 'act';
	var dis = -$now*$dis;
	moveElement(id1, 0, dis, 10);
	$now++;
	if($now >= $len) {
        $now = 0;
	}
}


function autoImg1(elem_id, list_id, list_id2, dis) {
    var id = document.getElementById(elem_id);
	var l_id = document.getElementById(list_id);
	var l_id2 = document.getElementById(list_id2);
	var ls_id = l_id.getElementsByTagName('a');
	var ls_id2 = l_id2.getElementsByTagName('a');
	if(!id || !ls_id[0]) {return false;}
	
    var arr = []

	for(i=0; i<ls_id2.length; i++) {
		var temp = i + 5;
        arr[i] = ls_id[i];
		arr[temp] = ls_id2[i]
	}	
	var len = arr.length;

	
	for(i=0; i<len; i++) {
	    var diss = -i*dis;
		arr[i].y = diss;
		arr[i].value = i;
		arr[i].onmouseover = function() {
            moveElement(elem_id, 0, this.y, 10);
			changeStyle(this.value); 
		}
	}
	arr[0].className = 'act';

	function changeStyle(num) {
        for(i=0; i<len; i++) {
            arr[i].className = '';
		}
		arr[num].className = 'act';
    }

	l_id.onmouseover = function() {
        if(timer1) { clearInterval(timer1); }
	}

    l_id.onmouseout = function() {
        window.setInterval(autoScroll, 4000, elem_id, arr, len, dis);
	}

	l_id2.onmouseover = function() {
        if(timer1) { clearInterval(timer1); }
	}

    l_id2.onmouseout = function() {
        window.setInterval(autoScroll, 4000, elem_id, arr, len, dis);
	}

	window.setInterval(autoScroll, 4000, elem_id, arr, len, dis);      
}



