if (!$) var $=function(_id) { return document.getElementById(_id); }

var _userName=null;
function getCookie (name){ //获取Cookie
     var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));  
     if(arr !=null) 
     	return decodeURIComponent(arr[2]); 
     return null;     
}



String.prototype.trim = function() { 
	return this.replace(/(\s*$)/g, ""); 
} 

function clearRevInfo(){
	$("comment_txt_1").value = "";
	$("vCode_1").value = "";
	
}

if (!jse) var jse={};

jse.popwin={
	_win:null,
	_bodyWidth:0,
	_disabledZone:null,
	bodyHeight:function () {
		var cobj = document.body;
		while(cobj.scrollTop == 0 && cobj.parentNode)
		{
			if(cobj.tagName.toLowerCase() == 'html') break;
			cobj = cobj.parentNode;
		}
		return cobj.clientHeight;
	},
	_checkDisabledZone:function() {
		jse.popwin._disabledZone=$("disabledZone");
        if (!jse.popwin._disabledZone) {
        
            jse.popwin._disabledZone=parent.document.createElement('div');
            jse.popwin._disabledZone.id="disabledZone";
            jse.popwin._disabledZone.style.cssText="background-color:#eee;-moz-opacity:0.8;filter:alpha(opacity=80);position:absolute;z-Index:9998;left:0px;top:0px;display:none";
            parent.document.body.appendChild(jse.popwin._disabledZone);            
            if (window.attachEvent)  { //IE
                jse.popwin._disabledZone.style.width=parent.document.body.clientWidth+"px";
                jse.popwin._disabledZone.style.height=Math.max(parent.document.body.scrollHeight,parent.document.body.clientHeight,jse.popwin.bodyHeight())+"px";
            }
            else  {  //firefox
                jse.popwin._disabledZone.style.width="100%";
                jse.popwin._disabledZone.style.height=Math.max(parent.document.body.offsetHeight+16,parent.document.body.clientHeight,jse.popwin.bodyHeight())+"px";
            }
           
        }
	},
	init:function(_winId) {
		jse.popwin._checkDisabledZone();
		jse.popwin._win=$(_winId);
		jse.popwin._bodyWidth=parent.document.body.clientWidth;
		jse.popwin._win.style.cssText="display:none;position:absolute;z-Index:9999;top:150px;left:"+(jse.popwin._bodyWidth-500)/2+"px;width:500px";
		
	},
	show:function() {		
		jse.popwin._disabledZone.style.display="block";
		jse.popwin._win.style.display="block";		
	},
	hide:function() {
		jse.popwin._win.style.display="none";
		jse.popwin._disabledZone.style.display="none";
	}
};

function reviewCommit(_button) {
	var _userName=$("userName_1");
	if (_userName.value.trim()=="") {
		alert("用户名不能为空！");
		return;
	}
	
	if ($("comment_txt_1").value.trim()=="") {
		alert("不能发布空内容！");
		return;
	}
	if ($("comment_txt_1").value.trim().length > 70) {
		alert("简评不能超过70个字！");
		return;
	}
	if ($("vCode_1").value.length!=4) {
		alert("验证码位数有误！");
		return;
	}
	//_button.onclick=function(){};
	document.getElementById("frmReview").action="http://user.pipi.cn/action/revCommit.jsp?flag=8";
	document.getElementById("frmReview").target="hid";
	$("frmReview").submit();
}

function showVImg() {
	var _html='<img src="http://user.pipi.cn/action/verify.jsp" id="vi_1" style="display:inline;margin:0 0 -4px 5px" align="bottom"/>';
	_html+='&nbsp;&nbsp;<a style="cursor:pointer" onclick="refreshVImg()">看不清，换一个</a>';
	$("vimg_1").innerHTML=_html;
	$("vCode_1").onfocus=function(){};
}

function refreshVImg() {
	var _img=$("vi_1");
	_img.src="http://user.pipi.cn/action/verify.jsp?t="+new Date().getTime();
}

Date.prototype.format = function(format)
{
	var o = {
	"M+" : this.getMonth()+1, //month
	"d+" : this.getDate(),    //day
	"h+" : this.getHours(),   //hour
	"m+" : this.getMinutes(), //minute
	"s+" : this.getSeconds(), //second
	"q+" : Math.floor((this.getMonth()+3)/3),  //quarter
	"S" : this.getMilliseconds() //millisecond
	}
	if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
	(this.getFullYear()+"").substr(4 - RegExp.$1.length));
	for(var k in o)if(new RegExp("("+ k +")").test(format))
	format = format.replace(RegExp.$1,
	RegExp.$1.length==1 ? o[k] :
	("00"+ o[k]).substr((""+ o[k]).length));
	return format;
}

function showDate(_date) {
	document.write(new Date(_date).format("yyyy年MM月dd日 hh:mm:ss"));
}

document.write("<iframe name='hid' id='hid' width='1' height='1'></iframe>");



var review={};
review.login={	
	_revUrl:"",
	showmsg:function(){
		/*var _msghtml="";
		_msghtml +='<li class="close"><a href="#" onclick="review.login.msgclose(1)"><strong>×</strong></a></li>';
		_msghtml +='<li class="frm-content">评论成功！您的评论将在审核通过后显示。</li>';
		_msghtml +='<li class="btn-ok"><input type="button" value=" 确定 " class="btn" onclick="comment.login.msgclose()"/></li>';
				
		if (document.getElementById("_msgid")==null){
			var _ul=document.createElement("ul");
			document.body.appendChild(_ul);		
			_ul.style.cssText="display:none";
			_ul.className="cmtok frm-box";
			_ul.id="_msgid";
			_ul.innerHTML= _msghtml;
		    var _bodyWidth=document.body.clientWidth;
			_ul.style.cssText="display:none;position:absolute;z-Index:9999;top:150px;left:"+(_bodyWidth-300)/2+"px;width:300px;border:1px solid #CCC;";
			
		}
		document.getElementById("_msgid").style.display="block";	
		*/
		alert("评论成功！您的评论将在审核通过后显示。");
		review.login.msgclose();
	},
	msgclose:function(f){
		var _msgid = document.getElementById("_msgid");
		if (_msgid != null){
			_msgid.style.display="none";
		}
		if (f !=null) return;
		if (review.login._revUrl){
			parent.closeWin();
			//top.window.location.href=review.login._revUrl;
			//window.location.reload();
		}
		/*if (getCookie("usernickname") == null){
			var _uname=document.getElementsByName("userName")[0];
			try{
				//review.reg.revRegShow(_uname.value);
			}catch(e){
			}	
		}*/
	}
};

function openWin(){
	parent.openWin();	
}

review.send={	
	_movId:"",
	_movName:"",
	init:function(){
		var _userName=$("userName_1");
		if (_userName){
			if (getCookie("username") == null)
				_userName.value="";
			else{
				_userName.value=getCookie("username");alert(getCookie("username"));alert(getCookie("usernickname"));
				_userName.readOnly=true;
			}	
		}
	},
	showmsg:function(mid){
		review.send._movId = mid;
		var _msghtml="";		
			_msghtml +=
			" <div class='innerbox' id='_innerbox'>"+
			"<form id='frmReview' action='' method='post'>"+
			"<input type='hidden' name='movId' value="+review.send._movId+"/>"+
			"        <h2 class='title'>写简评 <a href='javascript:void(0)' onclick='review.send.msgclose()' class='rbox'>×</a></h2>"+
			"        <ul>"+
			"          <li>"+
			"            <label for='nickname'>昵称:</label>"+
			"            <input type='text' id='userName_1' name='userName' value='匿名游客' class='ipt_text' />"+
			"          &nbsp;&nbsp; <span id='span_username_1'></span> </li>"+
			"      <li>"+
			"      	简短评论:<br />"+
			"        <textarea name='comment_txt' id='comment_txt_1' rows='5' class='ipt_text msgcontent'></textarea>"+
			"        <span style='color:#666; margin-left:5px;'>140</span>"+
			"      </li>"+
			"      <li>"+
			"        <label for='vcode'>验证码<input type='text' id='vCode_1' name='vCode' onfocus='review.send.showVImg()' size=6 style='height:18px;font-size:12px'/><span id='vimg_1'></span></label>"+
			"        &nbsp;"+
			"      <li>"+
			"      	<label>"+
			"          <input type='button' name='button' id='button' value='发表简评' onclick='review.send.commit()' />&nbsp;&nbsp;"+
			"          <input type='button' name='button3' id='button3' value='取消' onclick='review.send.msgclose()'/>"+
			"      	</label>"+
			"      </li>"+
			"    </ul>"+
			"</form></div>";
 		jse.popwin._checkDisabledZone();
		if (parent.document.getElementById("_msgid")==null){
			var _div=parent.document.createElement("div");
			parent.document.body.appendChild(_div);	
			_div.className="reviewbox";
			_div.id="_msgid";
			_div.innerHTML= _msghtml;
		    //var _bodyWidth=parent.document.body.clientWidth;
			
		}
		parent.document.getElementById("_msgid").style.display="block";	
		jse.popwin._disabledZone.style.display="block";	
		review.send.init();
	},
	msgclose:function(f){
		var _msgid = parent.document.getElementById("_msgid");
		if (_msgid != null){
			_msgid.style.display="none";
			jse.popwin._disabledZone.style.display="none";
		}
		return;
		
	},
	showVImg:function() {
		var _html='<img src="http://user.pipi.cn/action/verify.jsp" id="vi_1" style="display:inline;margin:0 0 -4px 5px" align="bottom"/>';
		_html+='&nbsp;&nbsp;<a style="cursor:pointer" onclick="review.send.refreshVImg()">看不清，换一个</a>';
		parent.document.getElementById("vimg_1").innerHTML=_html;
		parent.document.getElementById("vCode_1").onfocus=function(){};
		
	},
	refreshVImg:function() {
		var _img=parent.document.getElementById("vi_1");
		_img.src="http://user.pipi.cn/action/verify.jsp?t="+new Date().getTime();
		
	},
	commit:function(){
	
		var _userName=$("userName_1");
		if (_userName.value.trim()=="") {
			alert("用户名不能为空！");
			return false;
		}
		
		if ($("comment_txt_1").value.trim()=="") {
			alert("不能发布空内容！");
			return;
		}
		if ($("comment_txt_1").value.trim().length > 70) {
			alert("简评不能超过70个字！");
			return;
		}
		if ($("vCode_1").value.length!=4) {
			alert("验证码位数有误！");
			return;
		}
		document.getElementById("frmReview").action="http://user.pipi.cn/action/revCommit.jsp?flag=8";
		document.getElementById("frmReview").target="hid";
		$("frmReview").submit();
				
	}
};


function doothers(){
}



