﻿/// <reference path="http://www.yoho.cn/js/jquery-1.4.min.js" />
jQuery(function() {
    var ua = navigator.userAgent;
    if (getStatisticsCookie("PersonBannerShow") != "" && getStatisticsCookie("PersonBannerShow") != undefined) {
        jQuery("#yohobanners").hide();
    }
    else {
        jQuery("#yohobanners").show();
    }

    //居民中心通栏
    jQuery("#BannerCenter").find("a").bind("mouseover", function() {
        alert(111);
    });
    //大广告
    jQuery(".y_hotpic").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameHotPic" + i);
            var ADClickCookie = getStatisticsCookie("AdvertiseHomeHotPicClick" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameHotPic" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PagePos = encodeURIComponent("首页大幅广告");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
            //前台投放广告监测PV,UV
            if (ADClickCookie == undefined) {
                var cookieVal = setStatisticsCookie("AdvertiseHomeHotPicClick" + i + jQuery(this).attr("href"), 60 * 24);
                if (cookieVal != "") {
                    var recordType = "UserClick";
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PageMainPos = encodeURIComponent("首页");
                    var PageChildPos = encodeURIComponent("滚动广告");
                    jQuery.ajax({
                        url: "index/ajax/YohoAdvertisementTraceManage.ashx",
                        type: "post",
                        data: { "action": "HomeUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal, "recordType": recordType },
                        success: function(data) {

                        }
                    });
                }
            }
            else {
                var recordType = "PersonClick";
                var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                var Link = encodeURIComponent(jQuery(this).attr("href"));
                var Title = "";
                var PageMainPos = encodeURIComponent("首页");
                var PageChildPos = encodeURIComponent("滚动广告");
                jQuery.ajax({
                    url: "index/ajax/YohoAdvertisementTraceManage.ashx",
                    type: "post",
                    data: { "action": "HomeUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": "No", "recordType": recordType },
                    success: function(data) {

                    }
                });
            }




        });
    });

    //首页左侧广告
    jQuery(".y_ad1").bind("click", function() {
        var recordType = "PersonClick";
        var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
        var Link = encodeURIComponent(jQuery(this).find("a").attr("href"));
        var Title = "";
        var PageMainPos = encodeURIComponent("首页");
        var PageChildPos = encodeURIComponent("左侧Banner");
        jQuery.ajax({
            url: "index/ajax/YohoAdvertisementTraceManage.ashx",
            type: "post",
            data: { "action": "HomeUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": "No", "recordType": recordType },
            success: function(data) {

            }
        });
    });
    //首页左侧广告
    jQuery(".y_ad2").bind("click", function() {
        var recordType = "PersonClick";
        var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
        var Link = encodeURIComponent(jQuery(this).find("a").attr("href"));
        var Title = "";
        var PageMainPos = encodeURIComponent("首页");
        var PageChildPos = encodeURIComponent("左侧Banner");
        jQuery.ajax({
            url: "index/ajax/YohoAdvertisementTraceManage.ashx",
            type: "post",
            data: { "action": "HomeUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": "No", "recordType": recordType },
            success: function(data) {

            }
        });
    });
    //人物
    jQuery("#CBPeople").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameCBPeople" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameCBPeople" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PagePos = encodeURIComponent("首页人物");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });

    //热门话题
    jQuery(".y_news > .content > .pic").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameNewsPic" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameNewsPic" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PagePos = encodeURIComponent("首页热门话题");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });
    jQuery(".y_news > .content > .pic_c").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameNewsTopic" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameNewsTopic" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = "";
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = encodeURIComponent(jQuery(this).text());
                    var PagePos = encodeURIComponent("首页热门话题");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });

    //推荐圈子
    jQuery(".y_x2 > .y_group > .picbox").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameHotGroupPic" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameHotGroupPic" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PagePos = encodeURIComponent("首页推荐圈子");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });
    jQuery(".y_x2 > .y_hgroup > .picbox").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameHotGroupPicR" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameHotGroupPicR" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PagePos = encodeURIComponent("首页推荐圈子");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });
    jQuery(".y_x2 > .y_group > .f_orange").find("a").each(function(i) {
        jQuery(this).bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameHotGroupTopic" + i);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameHotGroupTopic" + i, 60);
                if (cookieVal != "") {
                    var ImgPath = "";
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = encodeURIComponent(jQuery(this).text());
                    var PagePos = encodeURIComponent("首页推荐圈子");
                    jQuery.ajax({
                        url: "index/ajax/StatisticsManager.ashx",
                        type: "post",
                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
                        success: function(data) {

                        }
                    });
                }
            }
        });
    });
    //个人中心
    //    jQuery("#yohoinfos").find("ul").each(function(j) {
    //        jQuery(this).find("li").not(".yohoinfop").each(function(i) {
    //            jQuery(this).find("a").bind("click", function() {
    //                var sCookie = getStatisticsCookie("StatisticNameInfoT" + j + i);
    //                if (sCookie != "" && sCookie == undefined) {
    //                    var cookieVal = setStatisticsCookie("StatisticNameInfoT" + j + i, 60);
    //                    if (cookieVal != "") {
    //                        var ImgPath = "";
    //                        var Link = encodeURIComponent(jQuery(this).attr("href"));
    //                        var Title = encodeURIComponent(jQuery(this).text());
    //                        var PagePos = encodeURIComponent("个人中心公告");
    //                        jQuery.ajax({
    //                            url: "../index/ajax/StatisticsManager.ashx",
    //                            type: "post",
    //                            data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
    //                            success: function(data) {

    //                            }
    //                        });
    //                    }
    //                }
    //            });
    //        });
    //        jQuery(this).find(".yohoinfop").find("a").bind("click", function() {
    //            var sCookie = getStatisticsCookie("StatisticNameInfoP" + j);
    //            if (sCookie != "" && sCookie == undefined) {
    //                var cookieVal = setStatisticsCookie("StatisticNameInfoP" + j, 60);
    //                if (cookieVal != "") {
    //                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
    //                    var Link = encodeURIComponent(jQuery(this).attr("href"));
    //                    var Title = "";
    //                    var PagePos = encodeURIComponent("个人中心公告");
    //                    jQuery.ajax({
    //                        url: "../index/ajax/StatisticsManager.ashx",
    //                        type: "post",
    //                        data: { "action": "HomeStatistics", "PagePos": PagePos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal },
    //                        success: function(data) {

    //                        }
    //                    });
    //                }
    //            }
    //        });

    //    });
    //个人中心公告点击UV,PV
    jQuery("#yohoinfos").find("ul").each(function(j) {
        jQuery(this).find(".yohoinfop").find("a").bind("click", function() {
            var sCookie = getStatisticsCookie("StatisticNameInfoP" + j);
            if (sCookie != "" && sCookie == undefined) {
                var cookieVal = setStatisticsCookie("StatisticNameInfoP" + j, 60);
                if (cookieVal != "") {
                    var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                    var recordType = "UserClick"
                    var Link = encodeURIComponent(jQuery(this).attr("href"));
                    var Title = "";
                    var PageMainPos = encodeURIComponent("个人中心");
                    var PageChildPos = encodeURIComponent("右侧公告");
                    jQuery.ajax({
                        url: "../index/ajax/YohoAdvertisementTraceManage.ashx",
                        type: "post",
                        data: { "action": "SpaceIndexUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": cookieVal, "recordType": recordType },
                        success: function(data) {

                        }
                    });
                }
            }
            else {
                var ImgPath = encodeURIComponent(jQuery(this).find("img").attr("src"));
                var recordType = "PersonClick"
                var Link = encodeURIComponent(jQuery(this).attr("href"));
                var Title = "";
                var PageMainPos = encodeURIComponent("个人中心");
                var PageChildPos = encodeURIComponent("右侧公告");
                jQuery.ajax({
                    url: "../index/ajax/YohoAdvertisementTraceManage.ashx",
                    type: "post",
                    data: { "action": "SpaceIndexUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": "No", "recordType": recordType },
                    success: function(data) {

                    }
                });
            }
        });

    });

});

//活动中心通栏Flash
function div_onclick(link, imgPath, Title) {
        var recordType = "PersonClick"
        var ua = navigator.userAgent;
        var Links = link;
        var ImgPaths = imgPath;
        if (ImgPaths == 'null') {
            ImgPaths = "";
        }
        var Titles = Title;
        var PageMainPos = encodeURIComponent("活动中心");
        var PageChildPos = encodeURIComponent("通栏FLASH");
        jQuery.ajax({
            url: "../index/ajax/YohoAdvertisementTraceManage.ashx",
            type: "post",
            data: { "action": "CityUserClick", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Links, "ImgPath": ImgPaths, "Title": Titles, "Cookie": "No", "recordType": recordType },
            success: function(data) {

            }
        });
}

function GetAdClickNum(action1, PageMainPos1, PageChildPos1, UserAgent1, Link1, ImgPath1, Title1, Cookie1, RecordType1) {
    var ImgPath = ImgPath1
    var recordType = RecordType1;
    var Link = Link1
    var Title = Title1;
    var PageMainPos = PageMainPos1;
    var PageChildPos = PageChildPos1;
    jQuery.ajax({
        url: "../index/ajax/YohoAdvertisementTraceManage.ashx",
        type: "post",
        data: { "action": action1, "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": UserAgent1, "Link": Link, "ImgPath": ImgPath, "Title": Title, "Cookie": "No", "recordType": recordType },
        success: function(data) {

        }
    });
}

function CloseBanner() {
    jQuery("#yohobanners").hide();
    setStatisticsCookie("PersonBannerShow", 60*24);
}
function getStatisticsCookie(cookie_name) {
    var allcookies = document.cookie;
    var cookie_pos = allcookies.indexOf(cookie_name);
    // 如果找到了索引，就代表cookie存在，   
    // 反之，就说明不存在。   
    if (cookie_pos != -1) {
        // 把cookie_pos放在值的开始，只要给值加1即可。   
        cookie_pos += cookie_name.length + 1;
        var cookie_end = allcookies.indexOf(";", cookie_pos);
        if (cookie_end == -1) {
            cookie_end = allcookies.length;
        }
        var value = unescape(allcookies.substring(cookie_pos, cookie_end));
    }
    return value;
}

function setStatisticsCookie(cookieName,time) {
    var date = new Date();
    var name = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ":" + date.getSeconds();
    if (!navigator.cookieEnabled) {
        name = "";
    } else {

        //date.setTime(date.getTime() + 60000 * time);
        date.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
        date.setHours(23, 59, 59);
        document.cookie = cookieName + '=' + escape(cookieName) + ';expires=' + date.toGMTString() + ';path=/' + ';domaim=yoho.cn' + ':secure';

    }
    return name;
} 
