function nTabs(tabObj, obj) {
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for (i = 0; i < tabList.length; i++) {
        if (tabList[i].id == obj.id) {
            document.getElementById(tabObj + "_Title" + i).className = "active";
            document.getElementById(tabObj + "_Content" + i).style.display = "block";
        } else {
            document.getElementById(tabObj + "_Title" + i).className = "normal";
            document.getElementById(tabObj + "_Content" + i).style.display = "none";
        }
    }
}

function nTabssub(tabObj, obj) {
    var tabList = document.getElementById(tabObj).getElementsByTagName("li");
    for (i = 0; i < tabList.length; i++) {
        if (tabList[i].id == obj.id) {
            document.getElementById(tabObj + "_Title" + i).className = "active";

        } else {
            document.getElementById(tabObj + "_Title" + i).className = "normal";
        }
        document.getElementById(tabObj + "_Content" + i).style.display = "block";
    }
}

function getsize(sizeid) {
    if (document.getElementById("sizevalue").value != "") {
        document.getElementById(document.getElementById("sizevalue").value).className = "size_none";
    }
    for (var i = 0; i < document.getElementById("size").getElementsByTagName("a").length; i++) {
        document.getElementById("size").getElementsByTagName("a")[i].className = "";
    }
    document.getElementById("sizevalue").value = sizeid;
    document.getElementById(sizeid).className = "size_bg";

}

$.fn.studyplay_star = function(options, callback) {
    var settings = {
        MaxStar: 5,
        StarWidth: 23,
        CurrentStar: 5,
        Enabled: true
    };
    if (options) { jQuery.extend(settings, options); };
    var container = jQuery(this);
    container.css({ "position": "relative" })
	.html('<ul class="studyplay_starBg"></ul>')
	.find('.studyplay_starBg').width(settings.MaxStar * settings.StarWidth)
	.html('<li class="studyplay_starovering" style="width:' + settings.CurrentStar * settings.StarWidth + 'px; z-index:0;" id="studyplay_current"></li>');
    if (settings.Enabled) {
        var ListArray = "";
        for (k = 1; k < settings.MaxStar + 1; k++) {
            ListArray += '<li class="studyplay_starON" style="width:' + settings.StarWidth * k + 'px;z-index:' + (settings.MaxStar - k + 1) + ';"></li>';
        }
        container.find('.studyplay_starBg').append(ListArray)
	.find('.studyplay_starON').hover(function() {
	    $("#studyplay_current").hide();
	    $(this).removeClass('studyplay_starON').addClass("studyplay_starovering");
	},
									  function() {
									      $(this).removeClass('studyplay_starovering').addClass("studyplay_starON");
									      $("#studyplay_current").show();
									  })
	.click(function() {
	    var studyplay_count = settings.MaxStar - $(this).css("z-index") + 1;
	    $("#studyplay_current").width(studyplay_count * settings.StarWidth)
	    if (typeof callback == 'function') {
	        callback(studyplay_count);
	        return;
	    }
	})
    }
}

var _url = encodeURI(window.location);
var _t = encodeURI(document.title);
function shareToSinaWb() {

    window.open('http://v.t.sina.com.cn/share/share.php?url=' + _url + '&appkey=400813291&title=' + _t + '&pic=', '', 'width=700, height=580,  toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}


function shareToRenrenWb() {
    window.open('http://share.renren.com/share/buttonshare.do?link=' + _url + '&title=' + _t, '', 'width=700, height=580,  toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}

function shareToTxWb() {
    var _appkey = encodeURI('65e3731f449e42a484c25c668160b355'); //你从腾讯获得的appkey
    var _pic = encodeURI(''); //（例如：var _pic='图片url1|图片url2|图片url3....）
    var _site = encodeURI('http://www.suning.cn'); //你的网站地址
    var _u = 'http://v.t.qq.com/share/share.php?title=' + _t + '&url=' + _url + '&appkey=' + _appkey + '&site=' + _site + '&pic=' + _pic;
    window.open(_u, '转播到腾讯微博', 'width=700,height=580,toolbar=no,menubar=no,scrollbars=no,location=yes,resizable=no,status=no');
}


function copyUrl() {
    if ($.browser.msie) {
        window.clipboardData.setData('Text', _url);
        alert("商品链接地址已经复制，您可以粘贴到QQ、MSN或邮件中发送给好友了!");
    } else {
        alert("您的浏览器不支持自动复制功能!");
    }
}

function shareToDoubanWb() {
    var comment = "推荐卡乐T恤定制网 " + document.title + "价格便宜，评价也不错，快去看看详细介绍吧\n" + window.location;

    window.open('http://www.douban.com/recommend/?url=' + _url + '&title=' + _t + '&comment=' + encodeURI(comment), '', 'width=700, height=580,  toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}

function shareToKaixinWb() {
    var url = 'http://www.kaixin001.com/repaste/bshare.php?rtitle='
					+ _t + '&rurl=' + _url
					+ '&from=maxthon';
    window.open(url, '', 'width=700, height=580,  toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}

function showHideNext(obj) {
    var _this = $(obj);
    var next = $(obj).parent().parent().next();
    var isNextHide = next.css('display') == 'none';
    if (isNextHide) {
        next.show();
        _this.text("隐藏");
    } else {
        next.hide();
        _this.text("查看");
    }
}
