function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}
var naa, movenum=1;
function moveElement(elementID,stepupId,nextId,as,interval) {
var elem = document.getElementById(elementID);
var boxwidth= document.getElementById(elementID).parentNode.clientWidth;
var lis = elem.getElementsByTagName("li");
var lislength =lis.length;
var xposmax = Math.ceil(lislength/3);
  if (elem.movement) {
    clearTimeout(elem.movement);
  }
var stepup = document.getElementById(stepupId);
var next = document.getElementById(nextId);
if(as=="lt"){
naa=-boxwidth*movenum;
}
if(as=="rt"){
naa=-boxwidth*(movenum-2);
}
if(as=="lt"&&movenum>(xposmax-1)){
naa=-(boxwidth*(xposmax-1));
num=xposmax;
}
if(as=="rt"&&movenum<2){
naa=0;
movenum=1;
}
  if (!elem.style.left) {
    elem.style.left = "0px";
  }
  var xpos = parseInt(elem.style.left);
if (xpos == naa) {
if(as=="lt"&&movenum<xposmax){
movenum++;
}
if(as=="rt"&&movenum>1){
movenum--;
}
if(movenum>(xposmax-2))
{
stepup.className="left"
next.className="noright"
}
if(movenum<2)
{
stepup.className="noleft"
next.className="right"
}
if(movenum>=2&&movenum<=(xposmax-1))
{
stepup.className="left"
next.className="right"
}
return true;
}
  if (xpos > naa) {
    var dist = Math.ceil((xpos - naa)/10);
    xpos = xpos - dist;
  }
    if (xpos < naa) {
    var dist = Math.ceil((naa - xpos)/10);
    xpos = xpos + dist;
  }
  elem.style.left = xpos + "px";
  var repeat = "moveElement('"+elementID+"','"+stepupId+"','"+nextId+"','"+as+"','"+interval+"')";
  elem.movement = setTimeout(repeat,interval);
}

function prepareSlideshow() {
	var links = document.getElementById("cardShow").getElementsByTagName("span");
	var elemqq = document.getElementById("hot_container");
	elemqq = setInterval("moveElement('hot_container','stepup','next','lt',30)",5000);
    links[0].onmousedown = function() {
		moveElement("hot_container","stepup","next","lt",30);
		clearInterval(elemqq);
      }
	links[1].onmousedown = function() {
        moveElement("hot_container","stepup","next","rt",30);
		clearInterval(elemqq);
      }
}
addLoadEvent(prepareSlideshow);

//index banner

var autohidden;
function bannerHidden(elemObj,elemsubObj,interval){
	var elem = document.getElementById(elemObj);
	var elemsub = document.getElementById(elemsubObj);
	if(!elem) return false;
	if(!elemsub) return false;
	if (elem.movement) {clearTimeout(elem.movement);}
	var ypos = parseInt(elem.clientHeight);
	//ypos=ypos-10;
	var dist = Math.ceil((500-ypos)/15);
    ypos = ypos - dist;
	if(ypos<100){
		clearTimeout(elem.movement);
		elem.style.display="none";
		elemsub.style.display="block";
	}
	//alert(ypos);
	elem.style.height=ypos+"px";
	//alert(elem.clientHeight);
	var repeat = "bannerHidden('"+elemObj+"','"+elemsubObj+"','"+interval+"')";
	elem.movement = setTimeout(repeat,interval);
}
autohidden = setTimeout(function(){bannerHidden('banner','subad',8);},2000)
