var blockUiImage = path;

   $(function() {
      var radiobuttons = $('input[name="radiobutton"]');
      goChange();
      $.each(radiobuttons,function(index,rbts){
          $(rbts).bind('click',function(){
	                  $('#textContext').empty();
	                  $('#textContext').val($(this).val());
	                  goChange();	                  
          });
      });
   });
 

$(document).ready(function(){
	       $("#textContext").keyup(function(){		    
			goChange();
		});
});
goChange();
function goChange(){
	var txtValue = $("#textContext").val();//获取文本域的值
	if (undefined == txtValue 
			|| 'undefined' == txtValue 
			|| null == txtValue 
			|| '' == txtValue){
		return;
	}
	
	var curLength = txtValue.length;	
	var sum=140;		    
	if(curLength>140){
		var content=$("#textContext").val();
	    $("#textContext").val(content.substring(0,140));
	}else{					 
	    $("#smallNum").empty();
	    var a = '<span class="colormain"><strong >'+(140-curLength)+'</strong></span>';
	    $("#smallNum").append(a);
	}
}


/**
 * 为字符串对象增加startWith方法
 */
String.prototype.startWith=function(str){
	if(str==null||str==""||this.length==0||str.length>this.length)
	  return false;
	if(this.substr(0,str.length)==str)
	  return true;
	else
	  return false;
	return true;
	}

	/**
	 * 为字符串对象增加endWith方法
	 */
	String.prototype.endWith=function(str){
		if(str==null||str==""||this.length==0||str.length>this.length) {
		  return false;
		}
		if(this.substring(this.length-str.length)==str) {
		  return true;
		} 
		return false;
	}
	var param_pic = "";
	window.shareTo = function(target_url, param_title, param_pic, contentId, picId){
		if ($('#' + contentId)) {
			if ((($("#" + contentId).val() || $("#" + contentId).text()) == null) || 
					(($("#" + contentId).val() || $("#" + contentId).text()) == '')) {
				alert('请选择您要分享的内容!');return;
			}
			param_title += encodeURIComponent($("#" + contentId).val() || $("#" + contentId).text()) + "&";
		}
		target_url += param_title;
		//param_title += encodeURIComponent($("#" + contentId).val() || $("#" + contentId).text()) + "&";
		var loc = "";
		var stuff = /(.com|.net|.org|.cn)/;
		if (param_pic && param_pic != null && !param_pic.startWith("http") || !param_pic.startWith("www") || !stuff.test(param_pic)) {
			loc = window.location.href;
			if (loc.startWith("http")) {
				loc = loc.substring(loc.indexOf('//') + 2);
			}
			loc = loc.substring(0, loc.indexOf("/") + 1);
		}
		if (picId != "" && picId != null) {
			if ($('#' + picId).attr("src") != "" && $('#' + picId).attr("src") != null) {
				param_pic += "http://" + loc + $("#" + picId).attr("src");
				target_url += param_pic;
			}
		}
		if (target_url.endWith('&')) {
			target_url = target_url.substring(0, target_url.length - 1);
		}
		window.open(target_url);
	}
	
	/**
	 * 分享工具构造函数
	 */
	$("input[name='btnShare']").live('click',function() {
		var target_url = /^(target|url|u|link|l)$/i;
		var title = /^(title|t)$/i;
		var pic_exp = /^(image|images|img|pic|pictures|pics|p)$/i;
		var target = $(this).attr("url") + "?";
		var d=$(this).attr("param").split(",");
		var param_title="";
		var param_pic="";
		for ( var s=0;s<d.length;s++) {
			if (target_url.test(d[s])) {
				target += d[s] + '=' + window.location.href + "&";
			} else if (title.test(d[s])) {
				param_title += d[s] + "=";
			} else if (pic_exp.test(d[s])) {
				param_pic += d[s] + "=";
			}
		}
		shareTo(target,param_title,param_pic,'textContext','htmlImage');
	});
