// JavaScript Document
function newmove(str)
{
		if (str==1){
	document.getElementById("right_but_01").className="right_bu1";
	document.getElementById("right_but_02").className="right_bu2s";
	document.getElementById("main_list_01").style.display="";
	document.getElementById("main_list_02").style.display="none";
	
	}
		if (str==2){
	document.getElementById("right_but_01").className="right_bu1s";
	document.getElementById("right_but_02").className="right_bu2";
	document.getElementById("main_list_01").style.display="none";
	document.getElementById("main_list_02").style.display="";
	}
		
}

function main14move(str)
{
		if (str==1){
	document.getElementById("main_14_but_01").className="main_14_bu1";
	document.getElementById("main_14_but_02").className="main_14_bu2s";
	document.getElementById("main_15_1").style.display="";
	document.getElementById("main_15_2").style.display="none";
	
	}
		if (str==2){
	document.getElementById("main_14_but_01").className="main_14_bu1s";
	document.getElementById("main_14_but_02").className="main_14_bu2";
	document.getElementById("main_15_1").style.display="none";
	document.getElementById("main_15_2").style.display="";
	}
		
}

function main140move(str)
{
		if (str==1){
	document.getElementById("right_40_01").className="right_bu1";
	document.getElementById("right_40_02").className="right_bu2s";
	document.getElementById("main_40_01").style.display="";
	document.getElementById("main_40_02").style.display="none";
	
	}
		if (str==2){
	document.getElementById("right_40_01").className="right_bu1s";
	document.getElementById("right_40_02").className="right_bu2";
	document.getElementById("main_40_01").style.display="none";
	document.getElementById("main_40_02").style.display="";
	}
		
}
function main141move(str)
{
		if (str==1){
	document.getElementById("right_41_01").className="right_bu1";
	document.getElementById("right_41_02").className="right_bu2s";
	document.getElementById("main_41_01").style.display="";
	document.getElementById("main_41_02").style.display="none";
	
	}
		if (str==2){
	document.getElementById("right_41_01").className="right_bu1s";
	document.getElementById("right_41_02").className="right_bu2";
	document.getElementById("main_41_01").style.display="none";
	document.getElementById("main_41_02").style.display="";
	}
		
}

function main55move(str)
{
    if(str==1)
	{
		document.getElementById("link1").style.display="block";
		document.getElementById("link2").style.display="none";
		document.getElementById("link3").style.display="none";
		document.getElementById("link4").style.display="none";
	}
	else if(str==2)
	{
		document.getElementById("link1").style.display="none";
		document.getElementById("link2").style.display="block";
		document.getElementById("link3").style.display="none";
		document.getElementById("link4").style.display="none";
	}
	else if(str==3)
	{
		document.getElementById("link1").style.display="none";
		document.getElementById("link2").style.display="none";
		document.getElementById("link3").style.display="block";
		document.getElementById("link4").style.display="none";
	}
	else if(str==4)
	{
		document.getElementById("link1").style.display="none";
		document.getElementById("link2").style.display="none";
		document.getElementById("link3").style.display="none";
		document.getElementById("link4").style.display="block";
	}
}

/*切换图片*/
var IMGConvert = function (imgId, textId, infoId) {
//随便切换
    var wc = this;
    this.constructor = arguments.callee;
    
    this.step = 5;
    this.time = 2000;
    this.cstep = 20;
    this.imgElement = document.getElementById(imgId);
	//this.imgElement.getElementsByTagName('img')[0].style.height=50;
	var imglist = this.imgElement.getElementsByTagName('img');
	//alert(imglist);
	for(inum=0;inum<imglist.length;inum++)
	{
	    DrawImage(imglist[inum]);
	}
    this.textElement = document.getElementById(textId);
    this.infoElement = document.getElementById(infoId);
    this.timer = this.ctimer = this.i = 0;
    
    this.each(this.anchorLists = [], this.imgElement.getElementsByTagName('a'), function (a, b,c) { a.push(b); b.style.display = 'none'; });
    this.each(this.textLists = [], this.textElement.getElementsByTagName('li'), function (a, b, i) {
        a.push(b);
        b.onclick = function () {
            with (wc.reItem(wc.i, wc.textLists).style) {
                backgroundColor = '#000', color = '#FFF';
            }
            wc.convert(i - 1);
        };
    });
    
    if (this.anchorLists.length < 2) return;
    
    this.init();
};

IMGConvert.prototype = {

    each : function (a, b, f) {
        for (var i = 0, l = b.length ; i < l ; i ++) f(a, b[i], i);
    }
    
    , init : function () {
        var wc = this;
        this.anchorLists[0].style.display = 'block';

        this.setText();
        this.timer = window.setTimeout(function () {
            wc.convert();
        }, this.time);
    }
    
    , reItem : function (i, a) {
    //获得元素
	//alert(a.value);
        return i >= a.length ? a[0] :
            i < 0 ? a[a.length - 1] : a[i];
    }
    
    , setText : function () {
    //设置字
        with (this.reItem(this.i - 1, this.textLists).style) {
            backgroundColor = '#FF3300', color = '#FFF';
        }
        with (this.textLists[this.i].style) {
            backgroundColor = '#FFF', color = '#000';
        }
		
        this.infoElement.innerHTML = this.anchorLists[this.i].getElementsByTagName('img')[0].getAttribute('alt').replace(/</ig, '<').replace(/>/ig, '>');
    }
    
    , convert : function (n) {
    //切换
        var wc = this, i = 100, n = 'undefined' == typeof n ? this.i : n;
        
        var a = this.reItem(n, this.anchorLists), b = this.reItem(n + 1, this.anchorLists);

        this.clear(1);
        
        this.i = n + 1 < this.anchorLists.length ? n + 1 : 0;
        
        this.setText();
        
        a.style.zIndex = 2, b.style.zIndex = 1;
        a.style.display = b.style.display = 'block';
        a.style.filter = b.style.filter = 'alpha(opacity=100)';
        a.style.opacity = b.style.opacity = 1.0;
        
        this.timer = window.setInterval(function () {
            if (i < 0) {
                wc.clear();
                wc.ctimer = window.setTimeout(function () {
                    wc.convert();
                }, wc.time);
            }
            
            a.style.filter = 'alpha(opacity=' + i + ')';
            a.style.opacity = i / 100;
            i -= wc.step;
            
        }, this.cstep);
    }
    
    , clear : function (b) {
    //清理
        this.timer && (window.clearInterval(this.timer), (this.timer = 0));
        this.ctimer && (window.clearTimeout(this.ctimer), (this.ctimer = 0));
        this.reItem(this.i - 1, this.anchorLists).style.display = 'none';
        b && (this.reItem(this.i, this.anchorLists).style.display = 'none');
    }
    
};



function DrawImage(ImgD){
var image=new Image();
var iwidth = 304;
var iheight = 220; //定义允许高度，当宽度大于这个值时等比例缩小
image.src=ImgD.src;
if(image.width>0 && image.height>0){

   if(image.width/image.height>= iwidth/iheight){
      if(image.width>iwidth){ 
         ImgD.width=iwidth;
          ImgD.height=(image.height*iwidth)/image.width;
       }else{
       ImgD.width=image.width; 
       ImgD.height=image.height;
       }
}else{
   if(image.height>iheight){ 
    ImgD.height=iheight;
    ImgD.width=(image.width*iheight)/image.height; 
   }else{
    ImgD.width=image.width; 
    ImgD.height=image.height;
   }
}
}
} 

