﻿
var aspxURL = "http://www.pomoho.com/do/special/specialsingle.aspx";

function $C(className, parent){
	var elems = (document.getElementById(parent)||document.body).getElementsByTagName("*");
	var result = [];
	for(i=0; i<elems.length; i++){
		if((" "+elems[i].className+" ").indexOf(" "+className+" ") != -1){
			result.push(elems[i]);
		}
	}
	return result;
}

String.prototype.trim = function(){return this.replace(/(^[\s]*)|([\s]*$)/g,"")}

function f_alert(name)
{
	alert(name);
}
function DoMovieAction( subjectID, emitStatus )
{
	Pui.loadScript(aspxURL + "?subjectid="+ subjectID +"&emitstatus="+ emitStatus +"&alerttype=1");
	
}
function CopyText(s)
{
	window.clipboardData.setData("Text",s);
	alert("专题链接地址已复制，可以发给你MSN或QQ上的好友！");
}

function Trim(s)
{
	return s.replace(/(^\s*)|(\s*$)/g,"");   
}

function GetCookie(sName)
{
	//document.domain = "pomoho.com";
	var aCookie = document.cookie.split("; ");
	for (var i=0; i < aCookie.length; i++)
	{
	var aCrumb = aCookie[i].split("=");
	if (sName == aCrumb[0]) 
		return unescape(aCookie[i].replace(sName + "=", ""));
	}
	return null;
}

//发表评论
function SendBlog(subjectID)
{	
	var sNickName = '游客';
    var sSpaceName = '';
	var u_name = sNickName;

	var sNoticeCookie = GetCookie("PomohoNewNotice");	
	if (sNoticeCookie != null)
	{
		var arrNotice = sNoticeCookie.split("$***$");	
		sNickName = arrNotice[6];
		//sSpaceName = 'href="http://home.pomoho.com/' + arrNotice[7] + '.shtml"';
		sSpaceName = 'href="http://www.pomoho.com/ui/blogadmin.aspx?_type=preview"';
		u_name = '<a ' + sSpaceName + ' target="_blank" title="' + sNickName + '" >' + sNickName + '</a>';
	}


	scontent = Trim(document.getElementById("article").value);
	
	if (scontent.length < 5 || scontent.length > 200)
	{
		alert('您发的评论字数必须大于5个字，小于200个字');
		document.getElementById("article").focus();
		return;
	}
	
	scontent = scontent.replace("<", "&lt;").replace(">", "&gt;").replace(/&/g, "<--@@-@@-->");
	
	Pui.loadScript(aspxURL + "?subjectid="+subjectID + "&alerttype=1" + "&objtype=1" +"&content="+ escape(scontent));
	
	var time = new Date();
	var t_year = time.getFullYear();
	var f_time = t_year + "-" + parseInt(time.getMonth()+1) + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
	var div = null;	
	var div  = document.createElement("DIV");
	div.innerHTML = '<div class="mDocument">'
				 + '	   <div class="photo"><a ' + sSpaceName + ' target="_blank"><img src="http://static.pomoho.com/pics/user_default.gif" alt="' + sNickName + '" /></a></div>'
				 + '			<div class="detail">'
				 + '				<span class="n_user">'+u_name+'</span>'
				 + '				<p class="text">' + repEm(scontent) + '</p>'
				 + '			</div>'
				 + '			<div class="handle">'
				 + '				<span class="t_release">' + f_time + '</span>'
				 + '			</div>'
				 + '		</div>'
				 + '	</div>';
	
	var divCommentList = $C("cl")[0];
	
	divCommentList.insertBefore( div, divCommentList.firstChild );
	var spanList = $C("commentcount");
	var sCommentCount = 0;
	if( spanList!=null ){
		for( var i=0; i<spanList.length; i++ ) {
			var iCount = parseInt(spanList[i].innerHTML);			
			sCommentCount = iCount+1;
			spanList[i].innerHTML = sCommentCount.toString();
		}
	}
	document.getElementById("article").value = "";
}

//选择评论图标
function post_em(sEm)
{
	document.getElementById("article").value += "[em" + sEm + "]";
}

function repEm(s)
{
	return s.replace(/\[em(\d{1,})\]/g, "<img src='http://static.pomoho.com/images/em/em$1.gif' />");
}

//收藏页面
function bookmark()
{
	var title=document.title
	var url=document.location.href
	if (window.sidebar) window.sidebar.addPanel(title, url,"");
	else if( window.opera && window.print ){
	var mbm = document.createElement('a');
	mbm.setAttribute('rel','sidebar');
	mbm.setAttribute('href',url);
	mbm.setAttribute('title',title);
	mbm.click();}
	else if( document.all ) window.external.AddFavorite( url, title);
}

function getNextPlayURL() {
	var obj = $('#VideoList .ac').next().find('.title a');
	if(obj.attr('href') != undefined) {
		$('#Layout_1 .vp h2').html(obj.attr('title'));
		$('#VideoList .ac').removeClass('ac').next().addClass('ac');
		var ss = obj.attr('href').split('/');
		thiszhuanMovie("player").getvideonum(ss[ss.length - 1]);

		Pui.loadScript("http://video.pomoho.com/getvideoinfo.aspx?fivid=" + ss[ss.length - 1]);
		
		return "1";
	} else {
		thiszhuanMovie("player").getvideonum(0);
		return "1";
	}
}
function thiszhuanMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function ReadVideoInfo(sT_Release,sV_intro,sHonor,sC_view,sC_review,sC_bookmark,sV_type,sV_tag)
{
	$('#Layout_1 .vp .detail .t_release').html(sT_Release);
	$('#Layout_1 .vp .detail .v_intro').html(sV_intro);

	$('#Layout_1 .vp .detail .de .s .l_strong').html(sHonor);
	$('#Layout_1 .vp .detail .de .s .c_view').html(sC_view);
	$('#Layout_1 .vp .detail .de .s .c_review').html(sC_review);
	$('#Layout_1 .vp .detail .de .s .c_bookmark').html(sC_bookmark);

	$('#Layout_1 .vp .detail .de .v_type').html(sV_type);
	$('#Layout_1 .vp .detail .de .v_tag').html(sV_tag);
}




