if (!javascriptcn){var javascriptcn = {};}
(function(){
javascriptcn.ready = function(){
    var load_events = [],
        load_timer,
        script,
        done,
        exec,
        old_onload,
        init = function () {
            done = true;
            clearInterval(load_timer);
            while (exec = load_events.shift())
                exec();
            if (script) script.onreadystatechange = '';
        };
    return function (func) {
        if (done) return func();
        if (!load_events[0]) {
            // for Mozilla/Opera9
            if (document.addEventListener)
                document.addEventListener("DOMContentLoaded", init, false);
            // for Internet Explorer
                /**//*@if (@_win32)
                document.write("<\/scr"+"ipt>");
                script = document.getElementById("__ie_onload");
                script.onreadystatechange = function() {
                    if (this.readyState == "complete")
                        init(); // call the onload handler
                };
            /*@end @*/
            // for Safari
            if (/WebKit/i.test(navigator.userAgent)) { // sniff
                load_timer = setInterval(function() {
                    if (/loaded|complete/.test(document.readyState))
                        init(); // call the onload handler
                }, 10);
            }
            // for other browsers set the window.onload, but also execute the old window.onload
            old_onload = window.onload;
            window.onload = function() {
                init();
                if (old_onload) old_onload();
            };
        }
        load_events.push(func);
    }
}();
})();
var comment_xml_config={
	replaceid:'c_list',
	save_button:'c_save',
	u_d:'last',
	l_type:'',
	p_id:0, 
	txt_content:'c_content',
	nocommentmsg:'暂无评论',
	inithtml:'',
	nowpageno:1,
	pagecounts:0,
	lthtml:'<div class="commentBox">$C_LT$<div class="commentInfo"> <span class="author">$C_UserName$ 的原贴：</span> <span class="floorCount">$C_NowLouShu$</span> </div><p class="content">$C_Content$</p></div>',
	init:function(){
	    comment_xml_config.inithtml=document.getElementById(comment_xml_config.replaceid).innerHTML;
	    document.getElementById(comment_xml_config.replaceid).innerHTML='评论加载中。。。';
	    document.getElementById(comment_xml_config.replaceid).style.display='block';		    
		javascriptcn.ready(function(){_c_css();_c_set();});
	}
}
function _c_set()
{
	var  _c_tDragIframe   =   document.createElement("iframe");  
	_c_tDragIframe.id   =   "_xmlframe";  
	_c_tDragIframe.style.display   ='none';
	_c_tDragIframe.src='http://comments.zsjdc.com/save.html'
	document.body.appendChild(_c_tDragIframe);  
	if(comment_xml_config.save_button != "")
	{
		document.getElementById(comment_xml_config.save_button).onclick=function(){
			document.getElementById('_xmlframe').contentWindow.save_comment();
			
		}
        document.getElementById(comment_xml_config.txt_content).onkeyup=content_length;
        document.getElementById(comment_xml_config.txt_content).onpropertychange=content_length;
	}
	
	var  _c_tDragIframe_1   =   document.createElement("iframe");  
	_c_tDragIframe_1.id   =   "_xmlframe_1";  
	_c_tDragIframe_1.style.display   ='none';
	_c_tDragIframe_1.src='http://comments.zsjdc.com/loadxml.html'
	document.body.appendChild(_c_tDragIframe_1);
	
}
function _c_print(_c_id,_c_userid,_c_ip)
{
	_xmlhtml=comment_xml_config.inithtml;

	_xmlhtml=_xmlhtml.replace(/\$C_Id\$/g,(_c_id));
	_xmlhtml=_xmlhtml.replace(/\$C_UserId\$/g,(_c_userid))
	_xmlhtml=_xmlhtml.replace(/\$C_UserName\$/g,(document.getElementById('p_l_username').innerHTML.replace(/ /g,'')))
	_xmlhtml=_xmlhtml.replace(/\$C_Ip\$/g,(_c_ip))
	_xmlhtml=_xmlhtml.replace(/\$C_Addtime\$/g,('刚刚'))
	_xmlhtml=_xmlhtml.replace(/\$C_Content\$/g,(document.getElementById(comment_xml_config.txt_content).value.replace(/ /g,'')))
	_xmlhtml=_xmlhtml.replace(/\$C_Up\$/g,('0'));
 
 	if(document.getElementById(comment_xml_config.replaceid).innerHTML==comment_xml_config.nocommentmsg)document.getElementById(comment_xml_config.replaceid).innerHTML='';
	if(comment_xml_config.u_d=='top')
		document.getElementById(comment_xml_config.replaceid).innerHTML=_xmlhtml+document.getElementById(_xmlreplacid).innerHTML;
	else
		document.getElementById(comment_xml_config.replaceid).innerHTML+=_xmlhtml;
  
	document.getElementById(comment_xml_config.txt_content).value='';
}
function _c_up(c_id){}
function _c_hf(c_id){document.getElementById('hfid').value=c_id;}
function _c_css(){
    if(!document.styleSheets.length)
    document.getElementsByTagName("head")[0].appendChild(document.createElement("style"));
    var CssSheet=document.styleSheets["0"];
    var addRule = (function(a,b){CssSheet.addRule ? CssSheet.addRule(a,b) : CssSheet.insertRule(a+"{"+b+"}",null)});
    addRule(".commentBox ","background:none repeat scroll 0 0 #FFFFEE;border:1px solid #999999;margin-bottom:12px;overflow:hidden;padding:3px;word-wrap:break-word;");
    addRule(".commentBox .commentInfo","font-size:12px;height:20px;line-height:18px;margin:0 3px;overflow:hidden;position:relative;");
    addRule(".commentBox .author","color:#1E50A2;padding-top:2px;");
    addRule(".commentBox .floorCount","color:#666666;position:absolute;right:3px;top:0;");
    addRule(".commentBox .content","clear:both;color:#2B2B2B;font-size:14px;line-height:20px;margin:9px 3px;");
}


function CheckLength(strTemp){    
	var i,sum;    
	sum=0;    
	for(i=0;i<strTemp.length;i++)    
	{    
	  if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))    
	    sum=sum+1;    
	  else   
	    sum=sum+2;    
	}    
	return sum/2;    
}   
function content_length()
{
    if(1000>CheckLength(document.getElementById(comment_xml_config.txt_content).value)){;}else{document.getElementById(comment_xml_config.txt_content).value=cutstr(document.getElementById(comment_xml_config.txt_content).value,1000)}
}
function cutstr(str,len)
{
   var str_length = 0;
   var str_len = 0;
      str_cut = new String();
      str_len = str.length;
      for(var i = 0;i<str_len;i++)
     {
        a = str.charAt(i);
        str_length++;
        if(escape(a).length > 4)
        {
         //中文字符的长度经编码之后大于4
         str_length++;
         }
         str_cut = str_cut.concat(a);
         if(str_length>=len)
         {
         alert('您提交的内容不能超出1000个字符，一个汉字占用两个字符');
         return str_cut;
         }
    }
    //如果给定字符串小于指定长度，则返回源字符串；
    if(str_length<len){
     return  str;
    }
}
