String.prototype.lenB=function(){
	return this.replace(/[^\x00-\xff]/g,"**").length;
}
function CheckIfEnglish(String)
{
    var Letters = "(!@$%^&*;':";
     var i;
     var c;
      if(String.charAt(0)=='-')
 return false;
      if( String.charAt( String.length - 1 ) == '-' )
          return false;
 for(i = 0; i < String.length; i ++ )
     {
          c = String.charAt( i );
   if (Letters.indexOf( c ) > 0)
    return false;       
     }
     return true;
}
function checklen(info)
{
	return info.lenB();
}
function getContentLen()
{
	var con=$("#content").val();
	$("#loglength").html((365-con.length)+"字")
	if(con.length>365)
	{
		var subc=con.substring(0,365);
		$("#content").val(subc);
	}
}
function showreplay(k)
{
	$("#replay_box"+k).show();
}
function hiddenbox(k)
{
	$("#replay_box"+k).hide();
}
 
(function($){ 
$.fn.extend({ 
insertAtCaret: function(myValue){ 
var $t=$(this)[0]; 
if (document.selection) { 
this.focus(); 
sel = document.selection.createRange(); 
sel.text = myValue; 
this.focus(); 
} 
else 
if ($t.selectionStart || $t.selectionStart == '0') { 
var startPos = $t.selectionStart; 
var endPos = $t.selectionEnd; 
var scrollTop = $t.scrollTop; 
$t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length); 
this.focus(); 
$t.selectionStart = startPos + myValue.length; 
$t.selectionEnd = startPos + myValue.length; 
$t.scrollTop = scrollTop; 
} 
else { 
this.value += myValue; 
this.focus(); 
} 
} 
}) 
})(jQuery);

function CheckEmail(email){
 var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
 flag = pattern.test(email);
 if(!flag){
  	return false;
 }
 return true;
}
//
function closediv(div)
{
	$("#"+div).hide(200);
}
function choseicon(div,k)
{
	$("#"+div).insertAtCaret("("+k+".gif)");
}
function showtopic()
{
	$("#content").val("#请在这里输入自定义话题#");
    var l = $("#content").val().length;
	var c=$("#content").get(0);
    //创建选择区域	
    if(c.createTextRange){//IE浏览器
        var range = c.createTextRange();
        range.moveEnd("character",-l)         
        //range.moveStart("character",-l)              
        range.moveEnd("character",l-1);
        range.moveStart("character", l-12);
        range.select();
    }else{
        c.setSelectionRange(l-12,l-1);
        c.focus();
    }
}
function showshare()
{
	var html="<div class='share_title'><div class='close' onclick=\"closediv('moreContent');\"><span>分享视频，FLASH，音乐，图片等等媒体文件！</span><em>X</em></div>URL地址：<input type='text' name='s_title' id='s_title' style='width:350px;' value='http://'><Br/>说明内容：<input type='text' name='s_content' id='s_content' style='width:350px;'><input type='button' name='btn_s_send' id='btn_s_send' value='确认分享' onclick=\"btn_s_send_click();\"/></div>";
	$("#moreContent").show(300).html(html);
}
function btn_s_send_click()
{
	var s_title=$.trim($("#s_title").val());
	var s_content=$.trim($("#s_content").val());
	if((s_title=="")||(s_content==""))
	{
		alert('请输入您要分享的内容');
	}
	else
	{
		var share="@@"+s_title+"@@"+s_content;
		$("#content").val(share);
		closediv("moreContent");
	}
}
function isEmail(vEMail)
{
var regInvalid=/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
var regValid=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
return (!regInvalid.test(vEMail)&&regValid.test(vEMail));
}
//2010-07-31
function showGLdiv(tid)
{
	var html="<div id=\"superbox-overlay\" style=\"display: block; opacity: 0.8;filter:alpha(opacity=50);\"></div><div id=\"superbox-wrapper\" style=\"display: table;\"><div id=\"superbox-container\"><div id=\"superbox\" style=\"position: static; top: 0px; width: 450px; opacity: 1;border:1px #ccc solid\" class=\"content\"><p class=\"close\"><a><strong><span onclick='closedivJS()'>Close</span></strong></a></p><div id=\"superbox-innerbox\" style=\"height: 180px;\"><div id=\"box-content\"><div>请输入您要回复的内容 <dd onclick=\"showicon('gltext','glmsg')\">插入表情</dd></div><input type=\"text\" name=\"gltext\" id=\"gltext\" class=\"recontent\"><input type=\"button\" value=\"确认回复\" onclick=\"glsubmit();\" id=\"glsubmit\" name=\"glsubmit\"><input type='hidden' id='tid' name='tid' value='"+tid+"' /><div id=\"glmsg\"></div></div></div></div></div></div>";
	$(html).appendTo("body");
}
//2010-08-11
function showReplaydiv(pid)
{
	if($("#box_"+pid).length>0)
		return false;
	var html="<div id=\"box_"+pid+"\" class='replaybox'><div  class='close'>请输入您要回复的内容 <dd onclick=\"showicon('box_replay_"+pid+"','boxmsg"+pid+"')\">插入表情</dd><em onclick=\"removediv('box_"+pid+"');\">X</em></div><textarea style=\"width:380px;height:70px\" name=\"gltext\" id=\"box_replay_"+pid+"\"></textarea><input type=\"button\" value=\"确认回复\" onclick=\"submitbox("+pid+",0);\" id=\"glsubmit\" name=\"glsubmit\"><input type='hidden' id='pid' name='tid' value='"+pid+"' /><div id=\"boxmsg"+pid+"\" class='box_icon'></div></div>";
	$(html).appendTo("#replay_box"+pid);
}
function removediv(div)
{
	$("#"+div).remove();
}
//
function closedivJS(){
	$("#superbox-overlay").remove();
	$("#superbox-wrapper").remove();
	$("#superbox-container").remove();
	$("#superbox").remove();
}
function gourl(url)
{
	var html="<div id=\"superbox-overlay\" style=\"display: block; opacity: 0.8;filter:alpha(opacity=50);\"></div><div id=\"superbox-wrapper\" style=\"display: table;\"><div id=\"superbox-container\"><div id=\"superbox\" style=\"position: static; top: 0px; width: 350px; opacity: 1;\" class=\"content\"><p class=\"close\"><a><strong><span onclick='closedivJS()'>Close</span></strong></a></p><div id=\"superbox-innerbox\" style=\"height: 100px;\"><div id=\"box-content\">您点击的URL："+url+"并非本站连接<br/>放弃访问请点击 Close<br/>继续请点击 <a href='"+url+"' target='_blank'>"+url+"</a></div></div></div></div></div>";
	$(html).appendTo("body");
}
function showMapBlog(img,username,time,id,title,address)
{
	var html="<div style=\"width:350px;height:80px;\" class='map'><img src='"+img+"' alt='"+username+"' class='mapimg'/><div class='mapconent'><div class='time'>"+username+"  发布于："+time+"</div><div class='title'><a href='"+id+"' target='_blank'>"+title+"</a></div></div></div></div>";
	return html;
}
