﻿// JavaScript Document

var textDiv = "";
$(function() {

    $('.mid_con').jScrollPane({ showArrows: true, scrollbarWidth: 5, scrollbarMargin: 10, dragMaxHeight: 28 });

    $(".sub_li").hover(function() {
        $(this).siblings().find(".sub_ul_in").hide();
        $(this).find(".sub_ul_in").show();
        //$(this).find("a").first().addClass("cnt");
    }, function() {
        $(this).find(".sub_ul_in").hide();
        //$(this).find("a").first().removeClass("cnt");
    })

    var pageurl = parent.location.href;
    var enurl = "/en"
    var senu = pageurl.indexOf(enurl);    //is englsih?
    var isen = 0;
    if (senu != -1) {
        isen = 1;
    }

    //tanchu 
    var pic_w = $(".tanc_li").find("img").attr("w_p");
    var pic_h = $(".tanc_li").find("img").attr("h_p");
    //alert(pic_w2);
    //var pic_w = 455;
    //var pic_h = 284;

    $(".tanc_pc").css({ "width": pic_w });
    $(".tanc_li").css({ "width": pic_w, "height": pic_h });
    var h = $("body").height();
    var w = $("body").width();
    $(".tanc").css({ "width": w, "height": h });
    $(".tanc2").css({ "width": w, "height": h });
    var n = $(".tanc_li").length;
    $(".tanc_ul").css({ "width": n * pic_w });
    var n1 = 0;
    var n2 = 1;
    ct = function() {
        $(".pic_li").removeClass("cn2");
        $nin = $(".pic_li").eq(n2).addClass("cn2");
        var tc = $nin.find(".pic_t").text();
        $(".c_tittle").text(tc)
    }
    $(".l_btn").click(function() {
        if (n1 == 0) {
            if (isen == 1) {
                alert("this is the first one")
            } else {
                alert("已经是第一张")
            }

        } else {
            $(".tanc_li").find("img").removeClass("cnt");
            n2 = n1 - 1;
            $(".tanc_li").eq(n2).find("img").addClass("cnt");

            $(".tanc_ul").stop().animate({ "left": "+=" + pic_w + "" });
            ct();
            n1--;
        }
    });

    $(".r_btn").click(function() {
        if (n1 + 1 == n) {
            if (isen == 1) {
                alert("this is the last one")
            } else {
                alert("已经是最后一张")
            }
        } else {
            n2 = n1 + 1;
            $(".tanc_li").find("img").removeClass("cnt");
            $(".tanc_li").eq(n2).find("img").addClass("cnt");
            $(".tanc_ul").stop().animate({ "left": "-=" + pic_w + "" });
            ct();
            n1++;
        }
    });
    $(".pic_li").each(function(i) {
        $(this).click(function() {
            $(".tanc").show();
            $(this).siblings().removeClass("cn2");
            $(this).addClass("cn2");
            var tc = $(this).find(".pic_t").text();
            $(".c_tittle").text(tc)
            $(".tanc_li").find("img").removeClass("cnt");
            $(".tanc_li").eq(i).find("img").addClass("cnt");
            n1 = i;
            $(".tanc_ul").css({ "left": -i * pic_w });
        });
    });
    $(".c_btn").click(function() {
        $(".tanc").hide();
    });

    //***联系我们*//
    $(".c_btn2").click(function() {
        $(".tanc2").hide();
    });
    $(".contect_pic").click(function() {
        $(".tanc2").show();
    });
    $(".tanc_li2").first().find("img").addClass("nn");

    var n3 = $(".tanc_li2").length;
    var n4 = 0;
    var tc2
    $(".tanc_ul2").css({ "width": n3 * 511 });
    $(".l_btn2").click(function() {
        if (n4 == 0) {
            if (isen == 1) {
                alert("this is the first one")
            } else {
                alert("已经是第一张")
            }
        } else {

            $(".tanc_ul2").stop().animate({ "left": "+=511" });
            $(".tanc_li2").find("img").removeClass("nn");
            $(".tanc_li2").eq(n4 - 1).find("img").addClass("nn");
            tc2 = $(".tanc_li2").find(".nn").attr("nam");
            $(".c_tittle2").text(tc2);
            n4--;
        }
    });
    $(".r_btn2").click(function() {
        if (n4 + 1 == n3) {
            if (isen == 1) {
                alert("this is the last one")
            } else {
                alert("已经是最后一张")
            }
        } else {

            $(".tanc_ul2").stop().animate({ "left": "-=511" });
            $(".tanc_li2").find("img").removeClass("nn");
            $(".tanc_li2").eq(n4 + 1).find("img").addClass("nn");
            tc2 = $(".tanc_li2").find(".nn").attr("nam");
            $(".c_tittle2").text(tc2);
            n4++;
        }
    });
    tc2 = $(".tanc_li2").find(".nn").attr("nam");
    $(".c_tittle2").text(tc2);




    ////////////
    $(".pou_btn").each(function(i) {
        $(this).click(function() {
            $(this).siblings().find("a").removeClass("cnt");
            $(this).find("a").addClass("cnt");
            $(".p_lm").hide();
            $(".p_lm").eq(i).show();
            return false;
        });


    });

    //////////////导航
    $(".m_l").hover(function() {
        var n = $(this).find(".main_li_bg2").length;
        var url1 = parent.location.href;
        var url2 = "/en"
        var s = url1.indexOf(url2);
        var wnav = 112;
        if (s != -1) {
            wnav = 155
        }
        var w = (n + 1) * wnav;
        $(this).find(".mnav2").css({ "width": w });
        $(this).find(".mnav2").show();
        $(this).siblings().find(".mnav2").hide();
    }, function() {
        $(this).find(".mnav2").hide();
    });


    //首页cp图片切换
    $(".i_num_a").eq(0).addClass("cnt");
    $(".ip_boc").css({ "width": 205 * 3 });
    rotate = function() {
        var triggerID = $active.attr("rel") - 1; //Get number of times to slide
        var image_reelPosition = triggerID * 205; //Determines the distance the image reel needs to slide

        $(".i_num_a").removeClass('cnt'); //Remove all active class
        $active.addClass('cnt'); //Add active class (the $active is declared in the rotateSwitch function)

        //Slider Animation
        $(".ip_boc").animate({
            left: -image_reelPosition
        }, 500);

    };
    rotateSwitch = function() {
        play = setInterval(function() { //Set timer - this will repeat itself every 3 seconds
            $active = $('.i_num a.cnt').next();
            if ($active.length == 0) { //If paging reaches the end...
                $active = $(".i_num_a").eq(0); //go back to first
            }
            rotate(); //Trigger the paging and slider function
        }, 5000); //Timer speed in milliseconds (3 seconds)
    };
    rotateSwitch();

    $(".ip_boc a").hover(function() {
        clearInterval(play); //Stop the rotation
    }, function() {
        rotateSwitch(); //Resume rotation
    });

    $(".i_num a").click(function() {
        $active = $(this); //Activate the clicked paging
        //Reset Timer
        clearInterval(play); //Stop the rotation
        rotate(); //Trigger rotation immediately
        rotateSwitch(); // Resume rotation
        return false; //Prevent browser jump to link anchor
    });


    ////搜索事件
    $(".serach_btn").click(function() {
        var key = $(".sear_t").val();
        var n = $(".sear_t").val().length;
        if (isen == 1) {
            if (n == 0) {
                alert("keyword is null");
            } else {
                window.location.href = "/en/cp_search.aspx?catid=57&keyword=" + key + "";
            }


        } else {
            if (n == 0) {
                alert("请输入有效信息");
            } else {
                window.location.href = "/pages/cp_search.aspx?catid=6&keyword=" + key + "";
            }
        }


    });


    //    logck = function(LoginInfo) {
    //        if (document.cookie.length > 0) {
    //            //c_start = document.cookie.indexOf(LoginInfo + "=")
    //            $(".toppl1").show();
    //            $(".toppl2").hide();

    //        } else {
    //            $(".toppl2").show();
    //            $(".toppl1").hide();
    //        }

    //    }
    //    logck();

    //    function getCookie(LoginInfo)//取cookies函数        
    //    {
    //        var arr = document.cookie.match(new RegExp("(^| )" + LoginInfo + "=([^;]*)(;|$)"));
    //        if (arr != null) return unescape(arr[2]); return null;

    //    } 
    //    
    //    delCookie = function(LoginInfo)//删除cookie 
    //    {
    //        var exp = new Date();
    //        exp.setTime(exp.getTime() - 1);
    //        var cval = getCookie(LoginInfo);
    //        if (cval != null) document.cookie = LoginInfo + "=" + cval + ";expires=" + exp.toGMTString();
    //        alert("删除cookie")
    //    }


    //    $(".tc_btn").click(function() {
    //        document.cookie = "";
    //        delCookie();
    //        alert("成功退出")
    //        window.location.href = "/index.html";
    //    });

    $(".jiathis_txt").hide();
    $(".logo").click(function() {

        top.location.href = '/index.html'
    });

    textDiv = $(".jt_ti").html();

    var enurl1 = parent.location.href;
    var enurl2 = "/en"
    var ebs = enurl1.indexOf(enurl2);
    if (ebs != -1) {
        $(".en_home").html("Home");
        $(".en_home").attr("href", "/enH/index.html");

        $(".encont").html("Contact Us");
        $(".encont").attr("href", "/enH/lianxi_c61_97.html");

        $(".enmap").html("Site Map");
        $(".enmap").attr("href", "/enH/map_c51.html");

        $(".cn_lm").hide();
        $(".en_lm").show();
        document.title = "Doppler Electronic Technologies Co., Ltd";
        //$("title").html("Doppler Electronic Technologies Co., Ltd");
    }


    //////////////
    //var news_con = $("#news_conn").html();
    //var ss = news_con.substr(0, 60);
    //var ss2 = ss + "...";
   // $("#news_conn").html(ss2);
});


var url1 = parent.location.href;
var url2 = "nwes_con"
var t1 = "";
var s = url1.indexOf(url2);
var url3 = "";
if (s == -1) {
    url3 = "http://doppler.ce4.cn/index.aspx";
    t1 = "广州多浦乐电子科技有限公司";
} else {
    url3 = url1;
   
    t1 = "广州多浦乐电子科技有限公司  " + textDiv;
    
}




var jiathis_config = {
    url: "" + url3 + "",
    title: "" + t1 + "",
    hideMore: true
} 
