﻿$(function(){
	$(".banner_940:eq(0)").find("a").bind("click",function(){
		div_onclick(this,"潮流频道首页头部通栏","YohoTrendIndexTopBanner20110115");
	});
	$(".trend_r").find(".banner_210160").find("a").bind("click",function(){
		div_onclick(this,"潮流内容页右侧Banner","YohoTrendConRightBanner20110115");
	});
	$(".banner_t").find("a").bind("click",function(){
		div_onclick(this,"首页中部通栏","YohoIndexCenterBanner20110115");
	});
});
function div_onclick(obj,Position,FlushID) {
        var recordType = "UserClick"
        var ua = "No";
        var Links = encodeURIComponent($(obj).attr("href"));
        var ImgPaths = encodeURIComponent($(obj).find("img").attr("src"));
        if (ImgPaths == 'null') {
            ImgPaths = "";
        }
        var Titles = "";
        var Position = encodeURIComponent(Position+"刷广告");
		var url="http://www.yoho.cn/index/ajax/YohoAdvertisementTraceManage.ashx?action=GetCityTraceQ&Position="+Position+"&Link="+Links+"&ImgPath="+ImgPaths+"&Title="+Titles+"&FlushID="+FlushID;
		$.getJSON(url+"&jsoncallback=?",function(data){});
        //jQuery.ajax({
        //    url: "http://www.yoho.cn/index/ajax/YohoAdvertisementTraceManage.ashx",
        //    type: "get",
        //    data: { "action": "GetCityTraceQ", "PageMainPos": PageMainPos, "PageChildPos": PageChildPos, "UserAgent": ua, "Link": Links, "ImgPath": ImgPaths, "Title": Titles, "Cookie":"No", "recordType": recordType },
        //    success: function(data) {
        //    }
        //});
}

function flash_onclick(Links,ImgPaths)
{
        var recordType = "UserClick"
        var ua = "No";
        var Links = encodeURIComponent(Links);
        var ImgPaths = encodeURIComponent(ImgPaths);
        if (ImgPaths == 'null') {
            ImgPaths = "";
        }
        var Titles = "";
		var FlushID="20110321"

        var Position = encodeURIComponent("首页大幅广告");
		var url="http://www.yoho.cn/index/ajax/YohoAdvertisementTraceManage.ashx?action=GetCityTraceQ&Position="+Position+"&Link="+Links+"&ImgPath="+ImgPaths+"&Title="+Titles+"&FlushID="+FlushID;
		$.getJSON(url+"&jsoncallback=?",function(data){});	
}
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;
} 
