// JavaScript Document


//--------header start--------



$(function () {
	$(window).load(function(){
		positioncont();
		positioncont2();
	    $(window).resize(function () {
	        positioncont();
	        positioncont2();
	    });
	});
	function positioncont(){
        var windowwid = $(window).width();
        if (windowwid > 992) {//PC
        	$(".klynav").show();
        	$(".klynavbg").hide();
        	$(".klynav ul li p").hide();
        	$(".inPro-one img").attr("src",$(".inPro-one img").attr("pcImg"));
        	
        	$(".klysearch-btn").unbind("click").bind("click",function(){
        		$(".klysearch-wrap").stop().fadeToggle(300);
        	});
        	$(".klynav ul li a").each(function () {
        	    $(this).attr("href", $(this).attr("pclink"));
        	});
                
        	$(".klynav ul li").hover(function(){
        	    if ($(this).find("p").length > 0) {
        	        $(this).find("p").stop().slideDown();
        	    }
        	}, function () {
        	    if ($(this).find("p").length > 0) {
        	        $(this).find("p").stop().slideUp();
        	    }
        	});
        	
        	
        } else {//MOBILE
            $(".klynav,.klynavbg").hide();
            $(".klynav-btn").removeClass("cur");
        	$(".klynav-btn").unbind().bind("click",function(){
        		$(this).toggleClass("cur");
        		$(".klynav").slideToggle(300);
        		$(".klynavbg").fadeToggle(300);
        		$(".klysearch-wrap").fadeOut(300);
        	});

        	$(".footer ul li h4").unbind("click").bind("click", function () {
        	    if ($(this).parent().find(".footerNav").is(":hidden")) {
        	        $(this).addClass("cur");
        	        $(this).parent().find(".footerNav").slideDown();
        	    }
        	    else {
        	        $(this).removeClass("cur");
        	        $(this).parent().find(".footerNav").slideUp();
        	    }
        	});

        	$(".klynav ul li").each(function () {
        	    if ($(this).find("p").length > 0) {
        	        $(this).find("a").eq(0).attr("href", "javascript:;");
        	    }
        	    $(this).find("a").removeClass("cur");
        	});

        	$(".klynav li a:first-child").click(function () {
        	    if ($(this).next().is(":hidden")) {
        	        $(".klynav li p").slideUp(300);
        	        $(".klynav li a").removeClass("cur");
        	        $(this).addClass("cur");
        	        $(this).next().slideDown(300);
        	    } else {
        	        $(this).removeClass("cur");
        	        $(this).next().slideUp(300);
        	    }
        	    
        	});
        	
        	$(".klysearch-btn").unbind("click").bind("click", function () {
	    		if ($(".klysearch-wrap").is(":hidden")) {
		            $(".klysearch-wrap").fadeIn(300);
		            $(".klynav").slideUp(300);
		            $(".klynavbg").fadeOut(300);
		            $(".klynav-btn").removeClass("cur");
		       	}else{
		            $(".klysearch-wrap").fadeOut(300);
		        };
		    });
        	
        	$(".inPro-one img").attr("src",$(".inPro-one img").attr("mobImg"));
        };
    };
    //--------header end--------
    //--------video start--------
		
	$(".videotop a").on("click",function(){
		var hei = $(this).height();
		var wid = $(this).width();
		$("#videobox1").width(wid).height(hei);
		$(this).parent().hide();
		var player;
		var fielp = $(this).attr("rel");
	    function loadHandler() {
	        player = CKobject.getObjectById("p1");
	    }
	    $("#videobox1").CkPlayer({
	        mode: 2,
	        video: fielp,
	        image: "",
	        auto: true,
	        playerId: "p1",
	        loaded: "loadHandler",
	        player: "res/ckplayer/ckplayer.swf"
	    });
	});
	$(".videolist a").on("click",function(){
		var player;
		var fielp = $(this).attr("rel");
		$(".recruitmentfloat").fadeIn();
	    function loadHandler() {
	        player = CKobject.getObjectById("p2");
	    }
	    $("#videobox2").CkPlayer({
	        mode: 2,
	        video: fielp,
	        image: "",
	        auto: true,
	        playerId: "p2",
	        loaded: "loadHandler",
	        player: "res/ckplayer/ckplayer.swf"
	    });
	});
	$(".recclosebtn").on("click",function () {
        $(".recruitmentfloat").fadeOut(300);
        $(".tianjiatvwrap .videobox").html("");
    });
	//--------video end--------
	//--------klysinglepage01 start--------

	$(".college-switch a").on("click",function(){
		var index = $(this).index();
		$(this).addClass("cur").siblings().removeClass("cur");
		$(".college-con").eq(index).show().siblings().hide();
	});
	
	function positioncont2(){
        var windowwid = $(window).width();
        if (windowwid > 767) {//PC
        	
        	$(".collegeTop img").attr("src",$(".collegeTop img").attr("pcImg"));
        	
        }else{//MOBILE

        	$(".collegeTop img").attr("src",$(".collegeTop img").attr("mobImg"));
        };
    }
	//--------klysinglepage01 end--------
	//--------klyprodetail01 start--------
	$(".productdetail-switch a").on("click", function () {
	    var index = $(this).index();
	    $(this).addClass("cur").siblings().removeClass("cur");
	    $(".productdetail-con").eq(index).show().siblings(".productdetail-con").hide();
	});

	$(".productdetail-con").each(function () {
	    var boxval = $(this).text();
	    var index = $(this).index()-1;
	    if ($(this).find("img").length != 0 || $.trim(boxval) != "") {
	    } else {
	        $(".productdetail-switch a").eq(index).hide();
	    }
	});

	//--------klysinglepage01 end--------
	//--------zhaopin start--------
	var oldx = 0;
    var zpwinscroll = $(window).scrollTop();
    $(".hsh_zp04 li").eq(oldx).find("h3").addClass("cur");
    $(".hsh_zp04 li").eq(oldx).find(".zhaoptext04").show();
    $(document).on("click", ".hsh_zp04 li h3",
    function () {
        var thisoffsetTop = $(this).offset().top;
        var _this = $(this);
        if ($(this).next().is(":hidden")) {
            $(this).addClass('cur').parent().siblings().find("h3").removeClass("cur");
            $(this).next().slideDown(500);
            $(this).parents("ul").children("li").eq(oldx).find(".zhaoptext04").slideUp(500, function () {
                thisoffsetTop = _this.offset().top;
                if ($(window).width() < 992) {
                    $("html,body").animate({
                        scrollTop: thisoffsetTop - 70
                    }, 500);
                }
                else {
                    $("html,body").animate({
                        scrollTop: thisoffsetTop
                    }, 500);
                }
            });
            oldx = _this.parents("li").index();
        }
        else {
            $(this).removeClass("cur");
            $(this).next().slideUp();
            if (oldx == 0) {
                oldx = -1;
            } else {
                oldx = 0;
            };
            
        };
    });
    //--------zhaopin end--------
    //--------newsdetail start--------
    var ShareBottom, shareBtm;
    function ShareScroll() {
        if ($(".detailtext11").length > 0) {
            if ($(window).scrollTop() > $(".detailtext11").offset().top) {
                ShareBottom = $(window).height() - ($(".detailpage11").offset().top - $(window).scrollTop()) + 75;
                shareBtm = $(window).height() - $(".Share11").outerHeight();


                if (ShareBottom > shareBtm) {
                    //下拉到一定程度
                    $(".Share11").css({ "position": "fixed", "bottom": ShareBottom, "top": "auto", left: ($(window).width() - $(".detailtext11").outerWidth()) / 2 });
                }
                else {
                    //正常情况下

                    $(".Share11").css({ "position": "fixed", "bottom": "auto", "top": 0, left: ($(window).width() - $(".detailtext11").outerWidth()) / 2 });

                }

            } else {

                $(".Share11").css({ "position": "absolute", "top": $(".detailtext11").offset().top, left: ($(window).width() - $(".detailtext11").outerWidth()) / 2 });

            }
        }
    };

    if ($(window).width() > 768) {
        ShareScroll();

        $(window).bind("scroll", function () {
            ShareScroll();
        });

        $(window).resize(function () {
            ShareScroll();
        })

    }
    else {

    };
    $(function() {
        var ShareBottom, shareBtm;
        function ShareScroll() {
            if ($(".detailtext11").length > 0) {
                if ($(window).scrollTop() > $(".detailtext11").offset().top) {
                    ShareBottom = $(window).height() - ($(".detailpage11").offset().top - $(window).scrollTop()) + 75;
                    shareBtm = $(window).height() - $(".Share11").outerHeight();
                    if (ShareBottom > shareBtm) {
                        $(".Share11").css({
                            "position": "fixed",
                            "bottom": ShareBottom,
                            "top": "auto",
                            left: ($(window).width() - $(".detailtext11").outerWidth()) / 2
                        });
                    } else {
                        $(".Share11").css({
                            "position": "fixed",
                            "bottom": "auto",
                            "top": 0,
                            left: ($(window).width() - $(".detailtext11").outerWidth()) / 2
                        });
                    }
                } else {
                    $(".Share11").css({
                        "position": "absolute",
                        "top": $(".detailtext11").offset().top,
                        left: ($(window).width() - $(".detailtext11").outerWidth()) / 2
                    });
                }
            }
        };
        if ($(window).width() > 768) {
            ShareScroll();
            $(window).bind("scroll",
            function() {
                ShareScroll();
            });
            $(window).resize(function() {
                ShareScroll();
            })
        } else {};

        $(document).on("click", ".detailback11",function() {
            var curpageHref = window.location.host;
            var prevpageHref = document.referrer;
            var windowHref=window.location.href.replace(/(.*\/)\w*(\.html)/g,"$1");
            if (prevpageHref.indexOf(curpageHref) > 0) {
                //$(this).attr("href", "javascript:history.back();");
            } else {
                window.location.href = windowHref;
                return false;
            };
        });
    });
    //--------newsdetail end--------
    //--------newslist start--------
    if ($(".hotnews07").length > 0) {
        var mySwiper = new Swiper('.hotnews07', {
            effect: 'slide',
            loop: true,
            autoplay: 5000,
            speed: 1200,
            pagination: '.hotnewsbtn07',
            prevButton: '',
            nextButton: '',
            paginationClickable: true,
            preventClicks: true,
            autoplayDisableOnInteraction: false,
            grabCursor: false,
            parallax: true

        });
    };
    //--------newslist end--------
});


