// JavaScript Document

function mov1()
{
	document.getElementById("jb1").style.display = "block";
	document.getElementById("jb2").style.display = "none";
	document.getElementById("jb3").style.display = "none";
	document.getElementById("jb4").style.display = "none";
	}

function mov2()
{
	document.getElementById("jb1").style.display = "none";
	document.getElementById("jb2").style.display = "block";
	document.getElementById("jb3").style.display = "none";
	document.getElementById("jb4").style.display = "none";
	}

function mov3()
{
	document.getElementById("jb1").style.display = "none";
	document.getElementById("jb2").style.display = "none";
	document.getElementById("jb3").style.display = "block";
	document.getElementById("jb4").style.display = "none";
	}

function mov4()
{
	document.getElementById("jb1").style.display = "none";
	document.getElementById("jb2").style.display = "none";
	document.getElementById("jb3").style.display = "none";
	document.getElementById("jb4").style.display = "block";
	}
	
//以下是滚动图片js代码
var moveing = false;
var stopscroll=true;
var cartoon_list=document.getElementById("cartoon_list");
var curMenuNum=1;
var leftOrRight=true;
function scrollUp(listWidth,menuNum,conWidth)
{
	if(stopscroll==false) return;
	if(curMenuNum==menuNum){
			if(curMenuNum<=1)
			{
				leftOrRight=true;
			}else
			{
				leftOrRight=false;
			}	
	}
	if(curMenuNum<=1){
		leftOrRight=true;
	}
	if(leftOrRight){
		nexts('cartoon_previous_btn','cartoon_next_btn','cartoon_list','cartoon_highlight',listWidth,conWidth);
		curMenuNum++;
	}else{
		previouss('cartoon_previous_btn','cartoon_next_btn','cartoon_list','cartoon_highlight',conWidth);
		curMenuNum--;
		}
}
function init(listWidth,menuNum,conWidth,time)
{
	/*//alert(listWidth);
	//var pp=substractNum20(243);
	//var li1=document.getElementById("li1");
	//with(li1){
	style.width=pp+'px';
	}*/
	var menuNum=menuNum-1;
	cartoon_list.onmouseover=new Function("stopscroll=false");
	cartoon_list.onmouseout=new Function("stopscroll=true");
	var MyMar=setInterval("scrollUp("+listWidth+","+menuNum+","+conWidth+")",time);
}


function $(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) {
		moveing=false;
		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 nexts(previousBtn,nextBtn,scrollID,highlightID,listWidth,conWidth) {
	if(moveing) return;
	moveing = true;
	var vTop = parseInt(document.getElementById(scrollID).style.top);
	var vLeft = parseInt(document.getElementById(scrollID).style.left);
	if (listWidth+vLeft <= conWidth*6){ return moveing=false;}
	if(listWidth+vLeft<= conWidth*6*2) {
		$(nextBtn).className = 'last_btn';
	}
	var finalLeft = vLeft - conWidth*6;
	moveElement(scrollID,finalLeft,vTop,5);
	
	
}

function previouss(previousBtn,nextBtn,scrollID,highlightID,conWidth) {
	if(moveing) return;
	moveing = true;
	var vTop = parseInt($(scrollID).style.top);
	var vLeft = parseInt($(scrollID).style.left);
	if (vLeft >= 0){return moveing=false;}
	if(vLeft == -conWidth*6) {
		$(previousBtn).className = 'first_btn';
	}
	var finalLeft = vLeft + conWidth*6;
	moveElement(scrollID,finalLeft,vTop,5);
	
	
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}

function substractNum20(num){
	return num-20;
	}
	

