﻿$(function(){
    //@Mr.Think***变量
    var $cur = 1;//初始化显示的版面
    var $i = 4;//每版显示数
    var $len = $('.showbox>ul>li').length;//计算列表总长度(个数)
    var $pages = Math.ceil($len / $i);//计算展示版面数量
    var $w = $('.ibox').width();//取得展示区外围宽度
    var $showbox = $('.showbox');
    var $num = $('span.num li');
    var $pre = $('span.pre');
    var $next = $('span.next');
    var $autoFun;
	//@Mr.Think***调用自动滚动
    //autoSlide();
//	$pre.hide();
//	$next.hide();
 	//@Mr.Think***向前滚动
    $pre.click(function(){
        $w = $('.ibox').width() - 30;
        if (!$showbox.is(':animated')) {  //判断展示区是否动画
            if ($cur == 1) {   //在第一个版面时,再向前滚动到最后一个版面
                $showbox.animate({
                    left: '-=' + $w * ($pages - 1)
                }, 10000); //改变left值,切换显示版面,500(ms)为滚动时间,下同
                $cur = $pages; //初始化版面为最后一个版面
            }
            else { 
                $showbox.animate({
                    left: '+=' + $w
                }, 10000); //改变left值,切换显示版面
                $cur--; //版面累减
//                $next.removeClass("hiiRight");
//                if($cur==1) 
//                {
//                    $pre.addClass("hiiLeft");
//                }
                
            }
            //$num.eq($cur - 1).addClass('numcur').siblings().removeClass('numcur'); //为对应的版面数字加上高亮样式,并移除同级元素的高亮样式
        }
    });
    //@Mr.Think***向后滚动
    $next.click(function(){
        $w = $('.ibox').width() - 30;
        if (!$showbox.is(':animated')) { //判断展示区是否动画
            if ($cur == $pages) {  //在最后一个版面时,再向后滚动到第一个版面
                $showbox.animate({
                    left: 0
                }, 10000); //改变left值,切换显示版面,500(ms)为滚动时间,下同
                $cur = 1; //初始化版面为第一个版面
            }
            else {
                $showbox.animate({
                    left: '-=' + $w
                }, 10000);//改变left值,切换显示版面
                $cur++; //版面数累加
//                $pre.removeClass("hiiLeft");
//                if($cur==$pages)
//                {
//                    $next.addClass("hiiRight");
//                }
            }
            //$num.eq($cur - 1).addClass('numcur').siblings().removeClass('numcur'); //为对应的版面数字加上高亮样式,并移除同级元素的高亮样式
        }
    });
    //@Mr.Think***数字点击事件
    $num.click(function(){
        if (!$showbox.is(':animated')) { //判断展示区是否动画
            var $index = $num.index(this); //索引出当前点击在列表中的位置值
            $showbox.animate({
                left: '-' + ($w * $index) 
            }, 500); //改变left值,切换显示版面,500(ms)为滚动时间
            $cur = $index + 1; //初始化版面值,这一句可避免当滚动到第三版时,点击向后按钮,出面空白版.index()取值是从0开始的,故加1
            $(this).addClass('numcur').siblings().removeClass('numcur'); //为当前点击加上高亮样式,并移除同级元素的高亮样式
        }
    });
    
    
    //@Mr.Think***停止滚动
    clearFun($showbox);
    clearFun($pre);
    clearFun($next);
//    clearFun($num);
    //@Mr.Think***事件划入时停止自动滚动
    function clearFun(elem){
        elem.hover(function(){
            clearAuto();
        }, function(){
            autoSlide();
        });
    }
    //@Mr.Think***自动滚动
    function autoSlide(){
        $next.trigger('click');
        $autoFun = setTimeout(autoSlide, 10500);//此处不可使用setInterval,setInterval是重复执行传入函数,这会引起第二次划入时停止失效
    }
    //@Mr.Think***清除自动滚动
    function clearAuto(){
        clearTimeout($autoFun);
    }    
    
    
})

// JScript 文件
$(document).ready(function(){

//菜单
            var li = $("#me-1 > li");
        
                $("#me-1").find("li").each(function(i){
                $(this).hover(
                    function(){
                        $(this).addClass("selLi");
                        if($(this).attr("id")=="liProducts")
                        {
                            $("ul .c2").show();
                        }
                        else
                        {                        
                            $(this).find("ul").show();
                        }
                    },
                    function(){
                        $(this).removeClass("selLi");
                        if($(this).attr("id")=="liProducts")
                        {
                            $("ul .c2").hide();
                        }
                        else
                        {                        
                            $(this).find("ul").hide();
                        }
                    }
                    );
            });    
        
            $("#me-1 .c2").find("li").each(function(i){
                $(this).hover(
                    function(){
                        $(this).addClass("selLi");
                        //$(this).find("ul").show().each(function(i){li.eq(i).hover(function(){$(this).find("ul").show();},function(){$(this).find("ul").hide(); })});
                        //$(this).find("ul .c2").show().each(function(i){li.eq(i).hover(function(){},function(){})});
                        $(this).find("ul").show();
                    },
                    function(){
                        $(this).removeClass("selLi");
                        //$(this).find("ul .c2").hide();
                        $(this).find("ul").hide();
                    }
                    );
            });
            
            $("#me-1 li ul").find("li").each(function(i){
                $(this).hover(
                    function(){
                        $(this).removeClass("selLi");
                        $(this).addClass("subLi");
                    },
                    function(){
                        $(this).removeClass("subLi");
                    }
                    );
            });
            
            //下拉框
            $('.select').jcombox({ theme: 'mytheme' , set: true ,fx: 'slide'}); 
				$("#a_selected").click(function(){
				    alert($("#slct1").jcSelected());
				});
				
		    $("#aOpenImg").click(function(){
	            $("#img2").show();
	            return false;
	        });
	        $("#aYuanTu").click(function(){
	            $("#img2").show();
	            return false;
	        });
	        $("#aCloseImg").click(function(){
	            $("#img2").hide();
	        });
	        
	       
        });
        
        function changeFriendLink(url)
        {
            window.open(url,"_blank");
        }
        
        function getfilesize(para)  
        {  
           var myfile=new ActiveXObject("scripting.filesystemobject");  
           var fi=myfile.GetFile(para);  
           return fi.size/1024/1024+"M";
        }
        
        function ChgTab(id)
        {
        if(id == "tab1")
        {
            var tab = document.getElementById('tabBg');
            tab.style.backgroundImage = "url(images/tab/tab-1_03.gif)";
            document.getElementById('pnl1').style.display = "";
            document.getElementById('pnl2').style.display = "none";
            document.getElementById('pnl3').style.display = "none";
            document.getElementById('pnl4').style.display = "none";
            document.getElementById('pnl5').style.display = "none";
        }
        else if(id == "tab2")
        {
            var tab = document.getElementById('tabBg');
            tab.style.backgroundImage = "url(images/tab/tab-2_03.gif)";
            document.getElementById('pnl1').style.display = "none";
            document.getElementById('pnl2').style.display = "";
            document.getElementById('pnl3').style.display = "none";
            document.getElementById('pnl4').style.display = "none";
            document.getElementById('pnl5').style.display = "none";
        }
        else if(id == "tab3")
        {
            var tab = document.getElementById('tabBg');
            tab.style.backgroundImage = "url(images/tab/tab-3_03.gif)";
            document.getElementById('pnl1').style.display = "none";
            document.getElementById('pnl2').style.display = "none";
            document.getElementById('pnl3').style.display = "";
            document.getElementById('pnl4').style.display = "none";
            document.getElementById('pnl5').style.display = "none";
        }
        else if(id == "tab4")
        {
            var tab = document.getElementById('tabBg');
            tab.style.backgroundImage = "url(images/tab/tab-4_03.gif)";
            document.getElementById('pnl1').style.display = "none";
            document.getElementById('pnl2').style.display = "none";
            document.getElementById('pnl3').style.display = "none";
            document.getElementById('pnl4').style.display = "";
            document.getElementById('pnl5').style.display = "none";
        }
        else
        {
            var tab = document.getElementById('tabBg');
            tab.style.backgroundImage = "url(images/tab/tab-5_03.gif)";
            document.getElementById('pnl1').style.display = "none";
            document.getElementById('pnl2').style.display = "none";
            document.getElementById('pnl3').style.display = "none";
            document.getElementById('pnl4').style.display = "none";
            document.getElementById('pnl5').style.display = "";
        }
    }
    
    function toBreakWord(id,intLen){
    var obj=id;
    
    var strContent=obj.innerText;
    var strTemp="";  
    while(strContent.length>intLen){  
    strTemp+=strContent.substr(0,intLen)+"<br>";    
    strContent=strContent.substr(intLen,strContent.length);
    }  
    strTemp+=""+strContent;
    alert(strTemp);  
    obj.innerHTML=strTemp;
    }  
    
    
