function video(vid){
this.api = 'http://v.bbboo.com/php/video/';
this.vid = vid;
this.downstate = 'none';
this.digover = false;
this.flush_count = function(){
url = bj_active+'php/video/ajax.php';
$.getScript(bj_active+'php/video/ajax.php?action=count_get_all&jsonp=v.flush_count_true&id='+this.vid);
}
this.flush_count_true = function(json){
$('#v_count_hit').html(json.count_hit);
$('#v_count_dig').html(json.count_dig);
$('#v_count_bury').html(json.count_bury);
$('#v_count_comment').html(json.count_comment);
$('#v_count_fav').html(json.count_fav);
$('#v_count_cite').html(json.count_cite);
}
this.dig = function(){
if(!this.digover){
this.digover = true;
$.getScript(bj_active+'php/video/ajax.php?action=dig&jsonp=v.dig_true&id='+this.vid);
v.flush_count();
}
else{
alert('您已经参与过评分了！');
}
}
this.bury = function(){
if(!this.digover){
this.digover = true;
$.getScript(bj_active+'php/video/ajax.php?action=bury&jsonp=v.bury_true&id='+this.vid);
v.flush_count();
}
else{
alert('您已经参与过评分了！');
}
}
this.count_add = function(){
$.getScript(bj_active+'php/video/ajax.php?action=count_add&jsonp=v.count_add_true&id='+this.vid);
v.flush_count();
}
this.copy_url = function(copy_type){
if (copy_type == 1)
copyToClipboard('#v_url_flash', '复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中了。');
else if (copy_type == 2)
copyToClipboard('#v_url_html', '复制成功。现在您可以粘贴（Ctrl+v）到Blog 或BBS中了。');
return false;
}
this.show_share = function(){
copyToClipboard('#v_i_share_input', '视频地址和标题已复制，你可以粘贴到MySpace、QQ、MSN或通过其它方式发给好友了。');
return false;
}
this.show_down = function(){
if(this.downstate != 'down'){
this.downstate = 'down';
document.getElementById('v_down').style.display = "block";
$.getScript(bj_active+'php/video/ajax.php?action=down&jsonp=v.show_down_true&id='+this.vid);
}else{
document.getElementById('v_down').style.display = "none";
this.downstate = 'none';
}
}
this.show_down_hd = function(){
if(this.downstate != 'down_hd'){
this.downstate = 'down_hd';
document.getElementById('v_down').style.display = "block";
$.getScript(bj_active+'php/video/ajax.php?action=down_hd&jsonp=v.show_down_true&id='+this.vid);
}else{
document.getElementById('v_down').style.display = "none";
this.downstate = 'none';
}
}
this.show_down_true = function(json){
var html = '<span>' + json.des + '</span>';
for (var i=0;i<json.downlinks.length;i++){
html += '<a href="'+json.downlinks[i].url+'" target="_blank">'+(json.downlinks[i].name)+'</a> ';
}
$('#v_down').html(html);
}
this.show_comment_list = function(page){
if (typeof page=='undefined'){
page = 1;
}
var url='/php/video/ajax.php?action=get_comment&sid='+this.vid+'&page='+page+'&t='+new Date().getTime();
$.getJSON(url, function(j){
var html = '';
if(j.c.length==0){
html += '<div class="content">||--还没有人发表评论哦，快抢沙发吧--||</div>';
}
else{
var htmlcount='<div class="page">';
if(page*20>=j.count){
var islast=true;
}
else{
var islast=false;
}
if(page==1){
var isfrist=true;
}
else{
var isfrist=false;
}
htmlcount+='第'+((page-1)*20+1)+'-'+(islast ? j.count : page*20)+'条 ';
htmlcount+='共'+j.count+'条<span>';
if (!isfrist){
htmlcount+='<a href="javascript:v.show_comment_list('+(page-1)+')">上页</a>';
}
if (!islast){
htmlcount+='<a href="javascript:v.show_comment_list('+(page+1)+')">下页</a>';
}
htmlcount+='</span></div>';
html+=htmlcount;
for (var i=0;i<j.c.length;i++){
html+='<div class="usertime"><span>'+j.c[i].user_name+'</span> 发表于'+j.c[i].timepast+'</div>';
html+='<div class="content">'+j.c[i].content+'</div>';
}
html+=htmlcount;
//if
}
$('#v_comment_list').html(html);
})
}
this.play = function(sid){
if (!sid){
sid = this.vid;
}
if(typeof video_sids != 'undefined'){
var htmlSer='<ul>';
for(var i=0;i<video_sids.length;i++){
if (video_sids[i][0] != sid){
htmlSer+='<li><a href="#" onclick="v.play(\''+video_sids[i][0]+'\');return false;">'+video_sids[i][1]+'</a></li>';
}
else{
htmlSer+='<li><span>↓'+video_sids[i][1]+' ↓</span></li>';
}
}
htmlSer+='</ul><div class="clear"></div>';
$$('v_series').innerHTML=htmlSer;
}
var htmlObj='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="480" height="400" id="flv_swfplayer" name="flv_swfplayer"><param name="movie" value="http://v.bbboo.com/cite/sid/'+sid+'/v.swf" /><param name="quality" value="high" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="allownetworking" value="all" /><param name="wmode" value="transparent"><embed src="http://v.bbboo.com/cite/sid/'+sid+'/v.swf" quality="high" allowfullscreen="true" allowscriptaccess="always" allownetworking="all" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="480" height="400" wmode="transparent" ></embed></object>';
$$('v_obj').innerHTML=htmlObj;
}
}
function video_relation(){
var margin = $$('v_relations_videos').style.marginLeft.slice(0,-2)||0;
$$('v_relations_videos').style.marginLeft=(margin==-960) ? '0px' : (margin-480)+'px';
}
function video_comment(){
var url='/php/video/ajax.php?action=comment';
if ($$('comment_content').value.length < 5){
alert('评论内容太短，是不是又灌水了……不能少于五个汉字。');
return false
}
if ($$('comment_content').value.length > 200){
alert('评论内容太长了，不能多于200个汉字…');
return false;
}
var user_name = $$('comment_user').value;
if (user_name.length == 0 || user_name == '请输入用户名'){
alert('请输入用户名');
$('#comment_user').focus();
return false
}
var hanzi;
if (hanzi=user_name.match(/[^x00-xff]/g)){
if ((user_name.length+hanzi.length) > 12){
alert('用户名太长，请输入6个以内的汉字或者12个以内的英文字母。');
return false;
}
}
else{
if (user_name.length > 12){
alert('用户名太长，请输入6个以内的汉字或者12个以内的英文字母。');
return false;
}
}
var content=$$('comment_content').value;
var commentdata={sid: $$('comment_video_sid').value, comment_content: content, comment_user: user_name};
$.post(url, commentdata, function(d){
if (d == '1'){
alert('恭喜您，发表评论成功。');
v.show_comment_list();
window.location='#v_comment_list';
}
else if(d == '-4'){
alert('您发帖太频繁啦，30秒限发一个评论：）');
}
});
}