var ballWidth = 90;
var ballHeight = 68;
var BallSpeed = 1;
var maxBallSpeed = 50;
var xMax;
var yMax;
var xPos = 0;
var yPos = 0;
var xDir = 'right'; 
var yDir = 'down'; 
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;
function initializeBall() {
if (document.all) {
xMax = document.body.clientWidth
yMax = document.body.clientHeight
document.all("superball").style.visibility = "visible";
}
else if (document.layers) {
xMax = window.innerWidth;
yMax = window.innerHeight;
document.layers["superball"].visibility = "show";
}
setTimeout('moveBall()',400);
}
function moveBall() {
if (superballRunning == true) {
calculatePosition();
if (document.all) {
document.all("superball").style.left = xPos + document.body.scrollLeft;
document.all("superball").style.top = yPos + document.body.scrollTop;
}
else if (document.layers) {
document.layers["superball"].left = xPos + pageXOffset;
document.layers["superball"].top = yPos + pageYOffset;
}
setTimeout('moveBall()',30);
}
}
function calculatePosition() {
if (xDir == "right") {
if (xPos > (xMax - ballWidth - BallSpeed)) { 
xDir = "left";
}
}
else if (xDir == "left") {
if (xPos < (0 + BallSpeed)) {
xDir = "right";
}
}
if (yDir == "down") {
if (yPos > (yMax - ballHeight - BallSpeed)) {
yDir = "up";
}
}
else if (yDir == "up") {
if (yPos < (0 + BallSpeed)) {
yDir = "down";
}
}
if (xDir == "right") {
xPos = xPos + BallSpeed;
}
else if (xDir == "left") {
xPos = xPos - BallSpeed;
}
else {
xPos = xPos;
}
if (yDir == "down") {
yPos = yPos + BallSpeed;
}
else if (yDir == "up") {
yPos = yPos - BallSpeed;
}
else {
yPos = yPos;
}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//   DIV 菜单开始部分
function ClassMenu(Obj,tcn){
this.intTimeStep=20; 
this.isIe=(window.ActiveXObject)?true:false; 
this.intAlphaStep=(this.isIe)?5:0.05; 
this.curSObj=null; 
this.curOpacity=null; 
this.nowMState=0;
this.nextMState=0;
this.vobjId = Obj;
this.Obj = document.getElementById(Obj); 
this.visshow;
this.tcname = tcn;


this.changeState = function(isshow){
	this.visshow = isshow;
	if (this.visshow){
		this.nextMState = 1;
	}else{
		this.nextMState = 0;
	}
	setTimeout(this.tcname+'.startObjVisible()',50); 
}

this.startObjVisible = function (){
	var objId = this.vobjId;
	var isshow = this.visshow;
	var curSObj= this.Obj;
	if (this.isIe){
		if (isshow && this.nextMState == 1){
			if (this.nowMState == 0){
				this.nowMState = 1;
				curSObj.style.opacity = 0;
				this.setObjshow(); 
			}
		}else if(!isshow && this.nextMState == 0){
			if (this.nowMState == 1){
				this.nowMState = 0;
				curSObj.style.opacity = 100;
				this.setObjhide(); 
			}
		}
	}else{
		if (isshow && this.nextMState == 1){
			if (this.nowMState == 0){
				this.nowMState = 1;
//				curSObj.style.opacity = 0;
//				this.setObjshow(); 
				curSObj.style.display = "";
			}
		}else if(!isshow && this.nextMState == 0){
			if (this.nowMState == 1){
				this.nowMState = 0;
//				curSObj.style.opacity = 100;
//				this.setObjhide(); 
				curSObj.style.display = "none";
			}
		}
	}
} 

this.setObjState = function() 
{ 
	if (this.Obj.style.display==""){
		this.curOpacity=1;
		this.setObjClose();
		}
	else{ 
		if(this.isIe) 
		{ 
			this.Obj.style.cssText='DISPLAY: none;Z-INDEX: 1; FILTER: alpha(opacity=0); POSITION: absolute;'; 
			this.Obj.filters.alpha.opacity=0; 
		}else{ 
			this.Obj.style.opacity=0;
		}
		this.Obj.style.display='';
		this.curOpacity=0;
		this.setObjOpen();
	} 
} 

this.setObjhide = function () 
{ 
	this.curOpacity=1;
	this.setObjClose();
} 

this.setObjshow = function() 
{ 
	if(this.isIe) 
		{ 
			this.Obj.style.cssText='DISPLAY: none;Z-INDEX: 1; FILTER: alpha(opacity=0); POSITION: absolute;'; 
			this.Obj.filters.alpha.opacity=0; 
		}else{ 
			this.Obj.style.opacity=0 
		} 
	this.Obj.style.display=''; 
	this.curOpacity=0; 
	this.setObjOpen(); 
} 

this.setObjOpen = function() 
{ 
if (this.nowMState == 1){
	this.Obj.style.display=''; 
	if(this.isIe) 
	{ 
	this.Obj.filters.alpha.opacity+=this.intAlphaStep; 
	if (this.Obj.filters.alpha.opacity<100) setTimeout(this.tcname+'.setObjOpen()',this.intTimeStep);
	}else{ 
	this.curOpacity+=this.intAlphaStep; 
	this.curSObj.style.opacity =this.curOpacity; 
	if (this.curOpacity<1) setTimeout(this.tcname+'.setObjOpen()',this.intTimeStep);
	} 
}
} 

this.setObjClose = function() 
{ 
if (this.nowMState == 0){
if(this.isIe) 
{ 
this.Obj.filters.alpha.opacity-=this.intAlphaStep*2; 
if (this.Obj.filters.alpha.opacity>0) { 
setTimeout(this.tcname+'.setObjClose()',this.intTimeStep);} 
else {this.Obj.style.display="none";} 
}else{ 
this.curOpacity-=this.intAlphaStep; 
if (this.curOpacity>0) { 
this.Obj.style.opacity =this.curOpacity; 
setTimeout(this.tcname+'.setObjClose()',this.intTimeStep);} 
else {this.Obj.style.display='none';} 
}
}
} 
}

