﻿// JScript 文件
//mouseover滑动门特效
 
      function TableHowverGroup(normalClass,howverClass, arrLabelIDS, arrDivIDS){
          this.m_nclass = normalClass;
          this.m_hclass =  howverClass;
          this.m_labids = arrLabelIDS;
          this.m_itemids = arrDivIDS;
          
          
          //wrap method to function
          this.funcwrap = function(ogrup,current){
                  return function(){
                       for( var k=0; k < ogrup.m_labids.length; k++ ){
                             var strmidk = "#" + ogrup.m_labids[k];
                             if ( ogrup.m_labids[k] == ogrup.m_labids[current] ){
                                $( strmidk ).removeClass( ogrup.m_nclass ).addClass( ogrup.m_hclass );
                             }else{
                                $( strmidk ).removeClass( ogrup.m_hclass ).addClass( ogrup.m_nclass );
                             }
                        }
                        
                       
                        for( var j=0; j < ogrup.m_itemids.length; j++){
                            var strmid = "#" + ogrup.m_itemids[j];                            
                            if ( ogrup.m_itemids[current] == ogrup.m_itemids[j] ){
                                $( strmid ).show();
                            }else{
                                 $( strmid ).hide();
                            }
                        }
                   };
          }
          
          
          
          if ( this.m_labids.length != this.m_itemids.length ){
               alert("要切换的标签和内容ID数量不一至:标签IDS=" + this.m_labids);
               return;
          }
           
          //init 
          for(var i=0; i < this.m_labids.length; i++){
               var strid = this.m_labids[ i ];
               $("#" + strid).hover( this.funcwrap( this,i), function(){} );
          }
    }
    
  //对有图片切换效果
    function TableHowverGroup1(normalImages,howverImages, arrLabelIDS, arrDivIDS){
          this.m_nImages = normalImages;
          this.m_hImages = howverImages;
          this.m_labids = arrLabelIDS;
          this.m_itemids = arrDivIDS;
          
          
          //wrap method to function
          this.funcwrap = function(ogrup,current){
                  return function(){
                       for( var k=0; k < ogrup.m_labids.length; k++ ){
                             var strmidk = "#" + ogrup.m_labids[k];
                             if ( ogrup.m_labids[k] == ogrup.m_labids[current] ){
                                $(strmidk).find("img")[0].src="http://study.788111.com/newtopindex/newindex/images/"+m_hImages[k];
                                 //alert($('strmidk a img').html());
                             }else{
                                $(strmidk).find("img")[0].src="http://study.788111.com/newtopindex/newindex/images/"+m_nImages[k] ;
                             }
                        }
                        
                       
                        for( var j=0; j < ogrup.m_itemids.length; j++){
                            var strmid = "#" + ogrup.m_itemids[j];                            
                            if ( ogrup.m_itemids[current] == ogrup.m_itemids[j] ){
                                $( strmid ).show();
                            }else{
                                 $( strmid ).hide();
                            }
                        }
                   };
          }
          
          
          
          if ( this.m_labids.length != this.m_itemids.length ){
               alert("要切换的标签和内容ID数量不一至:标签IDS=" + this.m_labids);
               return;
          }
           
          //init 
          for(var i=0; i < this.m_labids.length; i++){
               var strid = this.m_labids[ i ];
               $("#" + strid).hover( this.funcwrap( this,i), function(){} );
          }
    }

    
     $(document).ready(
     function()
     {
         setCurrentButton( 0 );  
         setAuto();
    });
    
        
     
     //页面图片轮换
    var imageCount =0;
    var n_current = 0;
    function Mea(value){
        value--;
        n_current=value;
        setBg(value);
        plays(value);
    }
    
    function setBg( value ){
        for(var i=0;i<imageCount;i++)
            document.getElementById("timg"+i+"").className="bbg0";
            document.getElementById("timg"+value+"").className="bbg1";
        } 
        
        
    function plays(value)
    {
 
        try
        {
	        with (au)
	        {
		        filters[0].Apply();
		        for(i=0;i<imageCount;i++)
		        {
		           i==value?children[i].style.display="block":children[i].style.display="none"; 
		        }
		        
		        filters[0].play(); 		
		      }
        }
        catch(e)
        {
	        var d = document.getElementById("au").getElementsByTagName("a");
	        for(i=0;i<imageCount;i++)i==value?d[i].style.display="block":d[i].style.display="none"; 
	        
	        
        }
        
        //display text 
         setCurrentButton(value);
        
        
    }
    
    function setCurrentButton(value){
         var oanchors = document.getElementById("au").getElementsByTagName("a");
         var currentTitle = oanchors[value].title;  
	     var url= oanchors[value].href;
     
        var strid = "#playtext0"; 
        var strTitle =  "<a href=" + url + " title=" + currentTitle +">" + currentTitle +"</a>";
        $(strid).html(  strTitle  );
    }
    
    
    function clearAuto(){clearInterval(autoStart)}
    function setAuto(){
        imageCount = document.getElementById("au").getElementsByTagName("a").length;
        autoStart=setInterval("auto(n_current)", 3000);
    }
    
    function auto(){
        n_current++;
        if( n_current>=imageCount ){
            n_current = 0;
        }else if ( n_current < 0 ){
            n_current = imageCount - 1;
        }
        
        Mea( n_current+1 );
    } 
    
    
    function onprevbuttonclick(leftflag){
        var iplayimg = 0;
        
        if ( leftflag ){
           iplayimg =  n_current - 1;
         }else{
            iplayimg = n_current + 1;
         }
        if( iplayimg>=imageCount ){
            iplayimg = 0;
        }else if ( iplayimg < 0 ){
            iplayimg = imageCount - 1;
        }
      Mea( iplayimg+1 );
    }
       
    
 
