var ar = new Array('banner_1','banner_2','banner_3','banner_4','banner_5','banner_6','banner_7','banner_8');
var nowid = 'banner_1';
var current = 1;
var benner = 'banner';
//定义“获得指定dom节点”的函数，因为其重用率高
//function $(d){return document.getElementById(d);}

//控制div逐渐显示
var i = 20;
function change_show(){
	var obj =document.getElementById(nowid);	
	i=i+20; //逐渐显示速度	
	obj.style.filter = "Alpha(Opacity=" + i + ")"; //透明度逐渐变小
	obj.style.opacity = i/100; //兼容FireFox
	obj.style.width = i*2 + "px"; //宽度逐渐变大	
	
	if(i>=354){
		obj.style.width = "709px"; //宽度固定
		
		clearInterval(s);
		i=20;
		//$("nowid").innerHTML = '';
		document.getElementById(nowid).style.marginLeft = "0px";
	}
}

var s;
function clipshow(num, id){
	if(id != nowid) {	
		for (var i=1; i<=8; i++){
			if(num == i){
			    document.getElementById(benner + i).className = "fl banner"+i+" current";
				//document.getElementById(id).style.display="";
				nowid = id;
				
				current = i;
				
				if(s){clearInterval(s);}
				document.getElementById(id).style.display = "block";
				s = setInterval(change_show,1);
				
			}else{
			document.getElementById(benner + i).className = "fl banner" + i;
				
				//h = setInterval(change_hidden,1);
				document.getElementById(ar[i-1]).style.display="none";
			}
		}
	}
}

function previous(){
	current--;
	if(current < 1){
		current = 1;
	}
	
	for (var i=1; i<=8; i++){
		if(current == i){
		    document.getElementById(benner + i).className = "fl banner" + i + " current";
			
			nowid = ar[i-1];
				
			if(s){clearInterval(s);}
			document.getElementById(nowid).style.display = "block";
			s = setInterval(change_show,1);
			//document.getElementById(ar[i-1]).style.display="";			
		}else{
		document.getElementById(benner + i).className = "fl banner" + i;
			document.getElementById(ar[i-1]).style.display="none";
		}
	}
}

function next(){
	current++;
	if(current > 8){
		current = 1;
	}
	
	for (var i=1; i<=8; i++){
		if(current == i){
		    document.getElementById(benner + i).className = "fl banner" + i + " current";			
			nowid = ar[i-1];
				
			if(s){clearInterval(s);}
			document.getElementById(nowid).style.display = "block";
			s = setInterval(change_show,1);
			//document.getElementById(ar[i-1]).style.display="";
		}else{
		document.getElementById(benner + i).className = "fl banner" + i;		
			document.getElementById(ar[i-1]).style.display="none";
		}
	}
}
    $(function() {
        var start = setInterval(next, 5000);
        $("#banner").hover(function() {
            clearInterval(start);
        }, function() {
            start = setInterval(next, 5000);
        })
        for (var i = 1; i <= 8; i++) {
            $("#banner"+i).hover(function() {
                clearInterval(start);
            }, function() {
                start = setInterval(next, 5000);
            })
        }

    })
    $(function() {
        //小图在红点的右边的动画操作
        //根据新添加进来的#home里面新的城市的div的class名称，将这些新名称添加进数组，即可
        var bannerArr_right = new Array('chengdu', 'namucuo');
        //下面做具体的操作
        for (var i = 0; i < bannerArr_right.length; i++) {
            $("." + bannerArr_right[i]).hover(function() {
                if (!$(this).is(":animated")) {
                    $(this).children(".icon_small").stop(true,true).animate({ left: "5px" }, 100).animate({ left: "0px" }, 200).animate({ left: "5px" }, 200).animate({ left: "0px" }, 200).hide(10, function() {
                    $(this).parent().children("span").stop(true, true).css({ "left": 0, "top": -56 }).show();
                    });
                }
            }, function() {
                if (!$(this).is(":animated")) {
                    $(this).children("span").stop(true, true).hide().parent().children(".icon_small").stop(true, true).show();
                }
            })
        }
    })
 	//news
    $(function() {
        $(".news_title li a").hover(function() {
            var $li_index = $(".news_title li a").index(this);
            $(".news div:eq(" + $li_index + ")").siblings().hide().end().show();
            $(".news ul:eq(0)").show();
            $(this).addClass("current");
            $(this).parent().siblings().children().removeClass("current");
        });
    })

    //case
    $(function() {
        $(".case_class li a").hover(function() {
            var $case_index = $(".case_class li a").index(this);
            $(".main_box div.case_list:eq(" + $case_index + ")").siblings(".main_box div.case_list").hide().end().show();
            //$(".news ul:eq(0)").show();
            $(this).addClass("current");
            $(this).parent().siblings().children().removeClass("current");
        });
    })
    //layer
    $(function() {
    $(".case_list ul li").hover(function() {
            var $offset = $(this).position();
            //alert($offset.left + " " + $offset.top);
            $(this).children("div.layer").stop(true,true).css({ "left": $offset.left+130, "top": $offset.top-5 }).show("fast");
        }, function() {
            $(".layer").stop(true,true).hide();
        })
    })

 

