document.write('<script type="text/javascript" src="http://www.yoho.cn/js/yohologin.js?randnum=' + Math.random() + '"><\/script>');

function buyMenu(n, c) {
    for (var i = 1; i <= 3; i++) {
        $("#dv_buy_" + i).hide();
    }
    $("#btn_buy_1").attr("class", "tab_new");
    $("#btn_buy_2").attr("class", "tab_sale");
    $("#btn_buy_3").attr("class", "tab_hot");
    $("#btn_buy_" + n).attr("class", c + "on");
    $("#dv_buy_" + n).show();
}

$(function() {
    //潮流论坛
    $("#ul_part li").bind("mouseover", function() {
        var str = "<span class='icon_on'></span>";
        $(this).find("span").remove();
        $(this).attr("class", "on").append(str).siblings().removeAttr("class").find("span").remove();
        $("#cpart_" + parseInt($(this).index() + 1)).css("display", "inline").siblings(".cpart_r").hide();
    });
    //潮流资讯上
    $("#ul_trend_top li").bind("mouseover", function() {
        $(this).find("span").attr("class", "trendon");
        $(this).siblings().find("span").removeClass("trendon");
        $("#dv_trend_top_" + parseInt($(this).index() + 1)).css("display", "block").siblings(".trend_text").hide();
    });
    //潮流资讯下
    $("#ul_trend_bottom li").bind("mouseover", function() {
        $(this).find("span").attr("class", "trendon");
        $(this).siblings().find("span").removeClass("trendon");
        $("#dv_trend_bottom_" + parseInt($(this).index() + 1)).css("display", "block").siblings(".trend_text").hide();
    });

    //全城聚焦单行滚动
    var _wrap = $('#dv_foucs'); //定义滚动区域
    var _interval = 5000; //定义滚动间隙时间
    var _moving; //需要清除的动画
    _wrap.hover(function() {
        clearInterval(_moving); //当鼠标在滚动区域中时,停止滚动
    }, function() {
        _moving = setInterval(function() {
            var _field = _wrap.find('li:first'); //此变量不可放置于函数起始处,li:first取值是变化的
            var _h = _field.height(); //取得每次滚动高度
            _field.animate({ marginTop: -_h + 'px' }, 600, function() {//通过取负margin值,隐藏第一行
                _field.css('marginTop', 0).appendTo(_wrap); //隐藏后,将该行的margin值置零,并插入到最后,实现无缝滚动
            })
        }, _interval)//滚动间隔时间取决于_interval
    }).trigger('mouseleave'); //函数载入时,模拟执行mouseleave,即自动滚动




    //cookie
    //if (getStatisticsCookie("dv_ad_2011") == null) {
    //    setStatisticsCookie("dv_ad_2011", 60 * 24);
    //    openad2011();
    //}

});


function openad2011() {
    //ad
    var pwidth = $(window).width();
    var pleft = pwidth - 940 < 0 ? 0 : pwidth - 940;
    if (!$.browser.msie) {
        $("#dv_2011_1")[0].style.left = (pleft / 2) + "px";
    }
    $("#dv_2011_1")[0].style.display = '';
}



function closead2011() {
    $('#dv_2011_1')[0].style.display = 'none';
}


//读取cookie
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));
    }
    else {
        value = null;
    }
    return value;
}

//设置cookie
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.setTime(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate()) + ' ' + "17:32:00");
        //alert(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate()) + ' ' + "17:32:00");
        //date.setTime(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + (date.getDate()) + ' ' + "17:32:00");
        //date.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
        //date.setHours(23, 59, 59);
        document.cookie = cookieName + '=' + escape(cookieName) + ';expires=' + date.toUTCString() + ';path=/' + ';domaim=yoho.cn' + ':secure';
    }
    return name;
} 
        
