
function initMainBanner(timer) {
   $('#mainBanner ul li').css({opacity: 0.0});
   $('#mainBanner ul li:first').css({opacity: 1.0});
   window.setInterval('startMainBanner();', timer);	
}

function startMainBanner() {	
   var current = ($('#mainBanner ul li.show') ? $('#mainBanner ul li.show') : $('#mainBanner ul li:first'));
   var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('#mainBanner ul li:first') : current.next()) : $('#mainBanner ul li:first'));	
   next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
   current.animate({opacity: 0.0}, 1000).removeClass('show');	
}

$(document).ready(function() { initMainBanner(3000); });



function DisplayMenu2(index) {
        for (i=1; i<=8; i++)
        if (index == i) {
        thisMenu = eval("menu" + index + ".style");
        thisMenu.display = "";
        } 
        else {
        otherMenu = eval("menu" + i + ".style"); 
        otherMenu.display = "none"; 
        }
        }




function changeContents(layerId, moveLength, direction, delay) {

   var This = this;

   this.obj = $('#' + layerId)[0];
   this.length = $('#' + layerId).find('>li').length;
   this.moveLength = moveLength;
   this.direction = direction;
   this.delay = delay;
   this.timer = null;

   this.obj.onmouseover = function () { if(This.delay) window.clearInterval(This.timer); }
   this.obj.onmouseout = function () { if(This.delay) This.timer = window.setInterval(function () { eval('This.move' + ((This.direction=='prev')?'Prev':'Next') + '();'); } , This.delay); }

   if((direction=='prev')&&moveLength&&delay) this.movePrev();
   if((direction=='next')&&moveLength&&delay) this.moveNext();

}

changeContents.prototype.getFirstChild = function(obj) {   

   var fObj = obj.firstChild;   

   while(fObj.nodeType!=1) fObj = fObj.nextSibling;     

   return fObj;   

}

changeContents.prototype.getLastChild = function(obj) {   

   var lObj = obj.lastChild;   

   while(lObj.nodeType!=1) lObj = lObj.previousSibling;   
  
   return lObj;   

}

changeContents.prototype.movePrev = function() {   
   
   var This = this;

   if(this.length>this.moveLength) {   

    if((this.delay&&this.timer)||(!this.delay&&!this.timer)) {

     var saveObj = this.getLastChild(this.obj);   
     this.obj.removeChild(this.getLastChild(this.obj));   
     this.obj.insertBefore(saveObj, this.getFirstChild(this.obj));   

	}

   }  
   
   if(this.delay&&(this.timer==null)) this.timer = window.setInterval(function () { This.movePrev(); } , this.delay);

}   

changeContents.prototype.moveNext = function() {   
     
   var This = this;

   if(this.length>this.moveLength) {   

    if((this.delay&&this.timer)||(!this.delay&&!this.timer)) {

     var saveObj = this.getFirstChild(this.obj);   
     this.obj.removeChild(this.getFirstChild(this.obj));   
     this.obj.appendChild(saveObj);   

	}

   }

   if(this.delay&&(this.timer==null)) this.timer = window.setInterval(function () { This.moveNext(); } , this.delay);
   
}

