function $(id) { return document.getElementById(id); }
 
function autoiFocus() {
	for (var i=1; i<=3; i++) {
		if ($('font_' + i).style.display == 'block') 	var currentNum = i+1;
	}
	
		if (currentNum == 4) currentNum = 1;
	for (var j=1; j<=3; j++) {
		if (j == currentNum) {
			if (j != 1 && j < 4) {
				moveElement('ifocus_piclist', 0, -291*(j-1), 5);
			} else {
				moveElement('ifocus_piclist', 0, 0, 5);
			}
			
			$('font_' + j).style.display = 'block';
			$('smallimg_' + j).className = 'current';
		} else {
			$('font_' + j).style.display = 'none';
			$('smallimg_' + j).className = 'normal';
		}
	}
}
setInterval('autoiFocus()',5000);

function moveElement(elementID,final_x,final_y,interval) {
  if (!document.getElementById) return false;
  if (!document.getElementById(elementID)) return false;
  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)/10);
    xpos = xpos + dist;
  }
  if (xpos > final_x) {
    var dist = Math.ceil((xpos - final_x)/10);
    xpos = xpos - dist;
  }
  if (ypos < final_y) {
    var dist = Math.ceil((final_y - ypos)/10);
    ypos = ypos + dist;
  }
  if (ypos > final_y) {
    var dist = Math.ceil((ypos - final_y)/10);
    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);
}

function chgthis(id) {
	
	for (var j=1; j<=3; j++) {
		if (j == id) {			
			$('font_' + j).style.display = 'block';
			$('smallimg_' + j).className = 'current';
		} else {
			$('font_' + j).style.display = 'none';
			$('smallimg_' + j).className = 'normal';
		}
	}
	moveElement('ifocus_piclist', 0, -291*(id-1), 5);
}
