function GetObject(id) { return document.getElementById(id); }
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 classNormal(){
var focusBtnList = GetObject('focus_change_btn').getElementsByTagName('li');
for(var i=0; i<focusBtnList.length; i++) {
focusBtnList[i].className='';
}
}
function focusChange() {
var focusBtnList = GetObject('focus_change_btn').getElementsByTagName('li');
focusBtnList[0].onmouseup = function() {
moveElement('focus_change_list',0,0,5);
classNormal()
focusBtnList[0].className='current'
}
focusBtnList[1].onmouseup = function() {
moveElement('focus_change_list',-376,0,5);
classNormal()
focusBtnList[1].className='current'
}
focusBtnList[2].onmouseup = function() {
moveElement('focus_change_list',-752,0,5);
classNormal()
focusBtnList[2].className='current'
}
focusBtnList[3].onmouseup = function() {
moveElement('focus_change_list',-1128,0,5);
classNormal()
focusBtnList[3].className='current'
}

focusBtnList[4].onmouseup = function() {
moveElement('focus_change_list',-1504,0,5);
classNormal()
focusBtnList[4].className='current'
}

}
setInterval('autoFocusChange()', 5000);
function autoFocusChange() {
var focusBtnList = GetObject('focus_change_btn').getElementsByTagName('li');
for(var i=0; i<focusBtnList.length; i++) {
if (focusBtnList[i].className == 'current') {
var currentNum = i;
}
}
if (currentNum==0 ){
moveElement('focus_change_list',-376,0,5);
classNormal()
focusBtnList[1].className='current'
}
if (currentNum==1 ){
moveElement('focus_change_list',-752,0,5);
classNormal()
focusBtnList[2].className='current'
}
if (currentNum==2 ){
moveElement('focus_change_list',-1128,0,5);
classNormal()
focusBtnList[3].className='current'
}
if (currentNum==3 ){
moveElement('focus_change_list',-1504,0,5);
classNormal()
focusBtnList[4].className='current'
}

if (currentNum==4 ){
moveElement('focus_change_list',0,0,5);
classNormal()
focusBtnList[0].className='current'
}
}
//¶¥²¿¹ã¸æ
var intervalId = null; 
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){ 
  this.stayTime=nStayTime*500 || 3000; 
  this.maxHeigth=nMaxHth || 90; 
  this.minHeigth=nMinHth || 3; 
  this.state=sState || "down" ; 
  var obj = document.getElementById(id); 
  if(intervalId != null)window.clearInterval(intervalId); 
  function openBox(){ 
   var h = obj.offsetHeight; 
   obj.style.height = ((this.state == "down") ? (h+20) : (h-20))+"px"; 
    if(obj.offsetHeight>this.maxHeigth-15){ 
    window.clearInterval(intervalId); 
    intervalId=window.setInterval(closeBox,this.stayTime); 
    } 
    if (obj.offsetHeight<this.minHeigth+25){ 
    window.clearInterval(intervalId); 
    obj.style.display="none"; 
    } 
  } 
  function closeBox(){ 
   slideAd(id,this.stayTime,"up",nMaxHth,nMinHth); 
  } 
  intervalId = window.setInterval(openBox,1); 
}


//right go

var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
	try{
	divTop = parseInt(document.getElementById("scrollAd").style.top,10)
	divLeft = parseInt(document.getElementById("scrollAd").style.left,10)
	divHeight = parseInt(document.getElementById("scrollAd").offsetHeight,10)
	divWidth = parseInt(document.getElementById("scrollAd").offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById("scrollAd").style.top = parseInt(document.documentElement.scrollTop,10) + docHeight + 2;//  divHeight
	document.getElementById("scrollAd").style.left = parseInt(document.documentElement.scrollLeft,10) + docWidth - divWidth
	document.getElementById("scrollAd").style.visibility="visible"
	objTimer = window.setInterval("moveDiv()",10)
	}
	catch(e){}
}

function resizeDiv()
{
	i+=1
	if(i>800) closeDiv()
	try{
	divHeight = parseInt(document.getElementById("scrollAd").offsetHeight,10)
	divWidth = parseInt(document.getElementById("scrollAd").offsetWidth,10)
	docWidth = document.documentElement.clientWidth;
	docHeight = document.documentElement.clientHeight;
	document.getElementById("scrollAd").style.top = docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)
	document.getElementById("scrollAd").style.left = docWidth - divWidth + parseInt(document.documentElement.scrollLeft,10)
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
	if(parseInt(document.getElementById("scrollAd").style.top,10) <= (docHeight - divHeight + parseInt(document.documentElement.scrollTop,10)))
	{
	window.clearInterval(objTimer)
	objTimer = window.setInterval("resizeDiv()",1)
	}
	divTop = parseInt(document.getElementById("scrollAd").style.top,10)
	document.getElementById("scrollAd").style.top = divTop - 1
	}
	catch(e){}
}
function closeDiv()
{
	document.getElementById('scrollAd').style.visibility='hidden';
	if(objTimer) window.clearInterval(objTimer)
}
//right go


//window.onload=function(){

//getMsg();
//}
//window.onresize =function(){
//resizeDiv();
//}
//window.onerror = function(){}
