//品牌显示
jQuery(function($){
  $("#pthink").mouseover(function(e){
	$("#pphone").removeClass("a2");
	$("#pthink").addClass("a2");
	$("#pidea").removeClass("a2");
	
	$("#pthink_area").show();
	$("#pidea_area").hide();
	$(".pop_phone").hide();
		
	$("#pthink_area").mouseover(function (){
	  $("#pthink_area").show();
	  $("#pthink").addClass("a2");
	}).mouseout(function(){
	  $("#pthink_area").hide();
	  $("#pthink").removeClass("a2");
	});
  });
  
  $("#pidea").mouseover(function(e){
	$("#pphone").removeClass("a2");
	$("#pthink").removeClass("a2");
	$("#pidea").addClass("a2");
	
	$("#pthink_area").hide();
	$("#pidea_area").show();
 	$(".pop_phone").hide();

	$("#pidea_area").mouseover(function (){
	  $("#pidea_area").show();
	  $("#pidea").addClass("a2");
	}).mouseout(function(){
	  $("#pidea_area").hide();
	  $("#pidea").removeClass("a2");
	});
  });
   
  $("#pphone").mouseover(function(e){
	$("#pphone").addClass("a2");
	$("#pthink").removeClass("a2");
	$("#pidea").removeClass("a2");
	$("#pthink_area").hide();
	$("#pidea_area").hide();
	$(".pop_phone").show();
	
	$(".pop_phone").mouseover(function (){
	  $(".pop_phone").show();
	  $("#pphone").addClass("a2");
	}).mouseout(function(){
	  $(".pop_phone").hide();
	  $("#pphone").removeClass("a2");
	});
  });
	
});




$(document).ready(function () {
/**
 * 语言选择框弹出
 */
    $('#language').hover(
        function () {
            $(this).find(".all-languages").toggle();
        }
    );
/**
 * 产品导航弹出
 */
    $("#max-service").hover(
        function () {
            $(".all-service").toggle();
        }
    );
/**
 * 下拉菜单
 */
    $(".menu ul.menu-list > li").hover(
        function () {
            $(this).find("> a").addClass("hover");
            $(this).find(".menu-sublist").slideDown(100);
        },
        function () {
            $(this).find("> a").removeClass("hover");
            $(this).find(".menu-sublist").slideUp(100);
        }
    );

/**
 * 首页slide轮换
 * currentIndex: 当前slide的index
 * slideCount: slide的数量
 */
    var currentIndex = 1;
    var slideCount = 3;

/**
 * 显示选定slide
 */
    function getSlideShow() {
        $("#slide .slide-box").hide();
        $("#slide #slide-box-" + currentIndex).fadeIn();
        $("#slide-show a.slide-show-content").removeClass("current");
        $("#slide-show a.slide-show-content:eq(" + (currentIndex - 1) + ")").addClass("current");
    }


/**
 * 控制上一张还是下一张，到达极值后，循环显示
 * @param {string} direction 轮换方向 默认为next
 */
    function getNextSlideShow(direction) {
        if (!direction || direction == "next") {
            currentIndex++;
            if (currentIndex >= (slideCount + 1)) {
                currentIndex = 1;
            }
        }
        else if (direction == "previous") {
            currentIndex--;
            if (currentIndex <= 0) {
                currentIndex = slideCount;
            }
        }
        getSlideShow();
    }

    $("#slide-show a.slide-show-content").click(
        function () {
            currentIndex = parseInt($(this).attr("id").replace("slide-show-",""));
            getSlideShow();
            return false;
        }
    );

    $("#slide-show a#slide-show-previous").click(
        function () {
            getNextSlideShow("previous");
            return false;
        }
    );

    $("#slide-show a#slide-show-next").click(
        function () {
            getNextSlideShow();
            return false;
        }
    );

    //setInterval(getNextSlideShow, 6000);

/**
 * 首页update-new轮换
 */
    var currentNewsIndex = 1;
    var newsCount = 10;
    var startUpdateNews;

    function hideUpdateNews() {
        $("p#update-news-" + currentNewsIndex).show().css("top", "2").css("opacity", "1").animate({
                top: '15',
                opacity: 0
            }, 400);
    }

    function showUpdateNews() {
        $("p#update-news-" + currentNewsIndex).show().css("top", "-8px").css("opacity", "0").animate({
                top: '2',
                opacity: 1
            }, 400);
    }

    function getNextUpdateNews(direction) {
        hideUpdateNews();

        if (!direction || direction == "next") {
            currentNewsIndex++;
            if (currentNewsIndex >= (newsCount + 1)) {
                currentNewsIndex = 1;
            }
        }
        else if (direction == "previous") {
            currentNewsIndex--;
            if (currentNewsIndex <= 0) {
                currentNewsIndex = newsCount;
            }
        }

        showUpdateNews();
    }
    
    startUpdateNews = setInterval(getNextUpdateNews, 6000);

    $("a#update-news-control-up").click(
        function () {
            getNextUpdateNews("previous");
            return false;
        }
    );

    $("a#update-news-control-down").click(
        function () {
            getNextUpdateNews();
            return false;
        }
    );
    
    $("#update-news-control").mouseenter(
        function () {
            clearInterval(startUpdateNews);
        }
    ).mouseleave(
        function () {    
            startUpdateNews = setInterval(getNextUpdateNews, 6000);
        }
    )
})
/**================================
 * 验配中心服务网点省份选择按钮脚本
 */
function item_over(itemID){
	itemClassName = itemID.className;
	if(itemClassName=="click"){
		itemID.className = "click";
	}else if(itemClassName==""){
		itemID.className = "over";
	}
}
function item_out(itemID){
	itemClassName = itemID.className;
	if(itemClassName=="click"){
		itemID.className = "click";
	}else if(itemClassName=="over"){
		itemID.className = "";
	}
}

//无刷新读取验配中心列表（前台）
function item_click(itemID,itemValue,classID){
	for(var i = 1 ; i < 31 ; i ++){
		document.getElementById("p_"+i).className = "";
	}
	itemClassName = itemID.className;
	itemID.className = "click";
	getCenterList(itemValue,classID);
}

function getCenterList(itemValue,classID){
　　$.ajax({
　　　　type:"GET",
　　　　url:"ajax/getCenterList.asp?Provice="+itemValue+"&class="+classID,
　　　　success:function(comments_data){
　　　　　　$("#servies_table").html(comments_data);
　　　　}
　　});
}

//无刷新读取验配中心列表（后台）
function sys_click(itemID,itemValue,classID){
	for(var i = 1 ; i < 31 ; i ++){
		document.getElementById("p_"+i).className = "";
	}
	itemClassName = itemID.className;
	itemID.className = "click";
	sys_getCenterList(itemValue,classID);
}

function sys_getCenterList(itemValue,classID){
　　$.ajax({
　　　　type:"GET",
　　　　url:"../ajax/getCenterList_sys.asp?Provice="+itemValue+"&class="+classID,
　　　　success:function(comments_data){
　　　　　　$("#servies_table").html(comments_data);
　　　　}
　　});
}

//无刷新读取丽声发展历程（前台）
function history_click(itemID,yearID){
	for(var i = 1996 ; i < 2012 ; i ++){
		document.getElementById("P_"+i).className = "";
	}
	itemID.className = "click";
	getHistoryList(yearID);
}

function getHistoryList(yearID){
　　$.ajax({
　　　　type:"GET",
　　　　url:"../ajax/getHistoryList.asp?yearID="+yearID,
　　　　success:function(comments_data){
　　　　　　$("#history_table").html(comments_data);
　　　　}
　　});
}
