/******************************************
Auto-readmore link script, version 2.0 (for blogspot)

(C)2008 by Anhvo
visit http://en.vietwebguide.com to get more cool hacks 

Edited 25-11-2008 by DoTuan: increase loading speed.
demo: http://www.thugian360.com
********************************************/

function removeHtmlTag(strx,chop){ 
	if(strx.indexOf("<")!=-1)
	{
		var s = strx.split("<"); 
		for(var i=0;i<s.length;i++){ 
			if(s[i].indexOf(">")!=-1){ 
				s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); 
			} 
		} 
		strx =  s.join(""); 
	}
	chop = (chop < strx.length-1) ? chop : strx.length-2; 
	while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; 
	strx1 = strx.substring(0,1); 
	strx2 = strx.substring(1,chop-1);
	strx = '<span style="float:left;font-size:50px;line-height:30px;padding:7px 1px 0 0 ;">'+strx1+'</span>'+strx2;
	return strx;
}

function createSummaryAndThumb(pID){
	var div = document.getElementById(pID);
	pIDpre = pID  + "pre";
	var divpre = document.getElementById(pIDpre);

img = divpre.value;
//img = img.toLowerCase();
img = img.replace("<IMG","<img");img = img.replace("HTTP://","http://");
img = img.substr(img.indexOf("<img"),img.length);
img = img.substr(0,img.indexOf(">"));
img = img.substr(img.indexOf("http://"),img.length);
img = img.substr(0,img.indexOf(" "));
img = img.replace('"','');img = img.replace("'","");img = img.replace('&#65533;&#65533;','');img = img.replace('&#65533;&#65533;','');

	if(img.length>10) {	
		imgtag = '<span style="float:left; padding:0px 5px 5px 5px;"><img src="'+img+'" style="border:1px solid silver;width:'+img_thumb_width+'px; height:'+img_thumb_height+'px;"/></span>';
		summ = summary_img;
	}else
	{	// Ads here
		imgtag = '<span style="float:left; padding:0px 5px 5px 5px;"><img src="http://img.photo.zing.vn/file_uploads/gallery/sources/q42008/2009/02/05/09/26961233799851.jpg" style="border:1px solid silver;width:'+img_thumb_width+'px; height:'+img_thumb_height+'px;"/></span>';
		summ = summary_noimg;
	}
	
	var summary = imgtag + '<div>' + removeHtmlTag(divpre.value,summ) + '</div>';
	div.innerHTML = summary;
}
















