function Render() {
	var self = this;
	var vdopath = "http://inventory.truelife.com/upload_video/";
	this.parser = new Parser();
	var folder_list = 'dv_listfolder';
	var friend_list = 'friend_list';
	// variables message list
	var msg_list = 'msg_list';
	var dvfoldername = 'dvfoldername';
	var index_tags = new Array();
	var dvpage = 'dvpage';
	var singleQuote = new RegExp("\'", "g");
	var doubleQuote = new RegExp("\"","g");

	var singleQuote1 = new RegExp("%27", "g");
	var doubleQuote1 = new RegExp("%22","g");
	var truelifethumb ='http://www.truelife.com/images/mini/truelife_thumb.gif';

	var __XML = '';
	var owner = false;
	var __user = '';
	
	/*--------------------------------------------------------
	 RENDER				Replace single and double quote
	 PARAMETER			txt
	---------------------------------------------------------*/
	this.fix = function(txt) {
		txt = txt.replace(singleQuote, "\\'");
		txt = txt.replace(doubleQuote, '&quot;');
		return txt;
	}

	this.convertdate = function(txtdate,styleyear,showtime,showmonthname) {
		txtmonth = new Array('','ม.ค','ก.พ','มี.ค','เม.ย','พ.ค','มิ.ย','ก.ค','ส.ค','ก.ย','ต.ค','พ.ย','ธ.ค');
		
		if (isNaN(Date.parse(txtdate)) ){
		
			dt = txtdate.split('T');
			
			_date = dt[0].split('-');
			_time = dt[1].split(':');
	
			yy = parseInt(_date[0])+543;
			if(!styleyear){
				dis_y = String(yy).substring(2);
			}else{
				dis_y = yy;
			}
			
			if(!showmonthname)
				txt_d = parseFloat(_date[2]) +' '+ txtmonth[parseFloat(_date[1])] +' '+ dis_y;
			else
				txt_d = parseFloat(_date[2]) +'/'+ parseFloat(_date[1])+'/'+ dis_y;
					
			txt_t = _time[0] +':' + _time[1];
			
				return txt_d +'&nbsp;&nbsp;'+ txt_t;
		}else{
			return '-';
		}
		//return txtdate;
		//2006-08-21T10:06:20
	}
	

	/*--------------------------------------------------------
	 GET HTML
	 PARAMETER		URL
	---------------------------------------------------------*/
	this.getHTML = function (get_url,disp,get_pars)
	{
			var url =get_url;
			var pars = get_pars;
			
			var myAjax = new Ajax.Updater(
				{success: disp}, 
				url, 
				{
					method: 'get', 
					parameters: pars
					//onLoading: function(){$(disp).innerText = 'loading ...';}
				});
	}
		
/*--------------------------------------------------------
	 RENDER				show VDO Type by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOType = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);

		// service success	
		var objlist = self.parser.getVDOType(xml);
		
		var spacer = '<div class="dvspacer">&nbsp;</div>';
		var select =		$("vdocat");
		var str_html = '';
		if(objlist!=null){
			categoryList = new Array();
			for(j=0;j<objlist.length;j++){
				categoryList[objlist[j].id] = objlist[j].name;
				opt = document.createElement('option');
				opt.value = objlist[j].id;
				opt.text = objlist[j].name;
				select.options.add(opt, j+1);
			}
		}
	}

/*--------------------------------------------------------
	 RENDER				show VDO folder by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOFolder = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);

		// service success	
		var objlist = self.parser.getVDOFolder(xml);
		
		var spacer = '<div class="dvspacer">&nbsp;</div>';
		var select =		$("select_folder");
		select.innerHTML = ''; 
		var str_html = '';
		if(objlist!=null){
			for(j=0;j<objlist.length;j++){
				opt = document.createElement('option');
				opt.value = objlist[j].id;
				opt.text = objlist[j].name;
				if(objlist[j].fdefault=='true'){
					opt.selected = true;
				}
				select.options.add(opt, j+1);
			}
		}
		
		opt = document.createElement('option');
		opt.value = '';
		opt.text = 'เลือกโฟลเดอร์ >';
		select.options.add(opt, 0);
	}


/*--------------------------------------------------------
	 RENDER				show VDO List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOList = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOList(xml);
		
			var spacer = '<div class="dvspacer">&nbsp;</div>';

			var win = '<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19" border=0>';
			var str_html = '';
			n= 0;

			if(objlist!=null){
				for(j=0;j<objlist.vdos.length;j++){
					n++;
					obj = objlist.vdos[j];
						if (n==1){
							text =  "<table cellpadding='1' cellspacing='1'><tr><td><div align='center' class='vdo_box'>";
						}else if(n%5!=1){ 
							text = text +"</div></td><td><div align='center' class='vdo_box'>";
						}else{
							text = text +"</div></td></tr><tr><td><div align='center' class='vdo_box'>";
						}
						image_online="";//(obj.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
						image_ec=(obj.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
						
						text = text +'<table width="98" border="0" align="center" cellpadding="0" cellspacing="0">';
						text = text +'	<tr>';
						text = text +'		<td valign="bottom">';
						text = text +'			<div align="center" id="vdo_{vdo_id}">';
						text = text +'				<img src="' + obj.vdothumbnail_url+ '" width="98" height="67" id="picture{vdo_id}" onError="this.src='+"'"+truelifethumb+"'"+'">';
						text = text +'			</div>';
						text = text +'		</td>';
						text = text +'	</tr>';
						text = text +'	<tr> ';
						text = text +'	  <td height="10" class="grlink"><span class="btxt"><font color="#333333"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"></font></span> ';
						text = text +'		{vdo_name}</strong></td>';
						text = text +'	</tr>';
						text = text +'	<tr> ';
						text = text +'	  <td height="20" class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo({vdo_userid},\'vdo\')">By:{vdo_userdisplay}</a>' + image_ec + '</td>';
						text = text +'	</tr>';
						text = text +'	<tr> ';
						text = text +'	  <td height="20" class="grlink"> ';
						text = text +'		<table width="100" border="0" cellspacing="0" cellpadding="0">';
						text = text +'		  <tr> ';
											for(i=1;i<=5;i++){
													if(i<=obj.vdoratingcount){
						text = text +'<td><div align="center"><img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14"></div></td>';
													}else if(obj.vdoratingcount-i>-1 && obj.vdoratingcount-i<0){
						text = text +'<td><div align="center"><img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14"></div></td>';
													}else{
						text = text +'<td><div align="center"><img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14"></div></td>';
													}
												}
						text = text +'		  </tr>';
						text = text +'		</table></td>';
						text = text +'	</tr>';
						text = text +'</table>';
						text = text.replace('{vdo_id}',obj.vdoid);
						text = text.replace('{vdoid}',obj.vdoid);
						text = text.replace('{user_id}',obj.vdouser.id);
						text = text.replace('{vdo_userid}',obj.vdouser.id);
						if(obj.vdoname.length>8){
							obj.vdoname = obj.vdoname.substring(0,8)+"...";
						}
						text = text.replace('{vdo_name}',obj.vdoname);
						if(obj.vdouser.displayname.length>6){
							obj.vdouser.displayname = obj.vdouser.displayname.substring(0,6)+"...";
						}
						obj.vdouser.displayname = obj.vdouser.displayname.replace("<"," ");
						obj.vdouser.displayname = obj.vdouser.displayname.replace(">"," ");

						text = text.replace('{vdo_userdisplay}',obj.vdouser.displayname);
						text = text.replace('{vdo_username}',obj.vdouser.username);
				}
				if(n%5!=1){
					n--;
					for( z =0 ;z<5-n%5;z++){
						text = text +'</div></td><td><div >';
					}
				}
				text = text +'</div></td></tr></table>';
				str_html += text;
				$('dvcontainer').innerHTML = str_html ;
				
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3"><a href="javascript:changePage(pageBox.value)"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

				//tag
				text="";

				for(i=0;i<objlist.index_tags.length;i++){
					text =  text + '<a href="javascript:changeTag(\'' + objlist.index_tags[i] + '\')">' + objlist.index_tags[i] + '</a>';
					if(i<objlist.index_tags.length-1){
						text = text + ",";
					}
				}
				$('relate_tag').innerHTML = text ;


			// no vdo data
			}else{
				if(chkowner){
					str = "คุณยังไม่มี VDO เลยค่ะ";
				}else{
					str = "เจ้าของบ้านยังไม่ได้ Upload VDO เลยค่ะ";
				}
				$("dvcontainer").innerHTML = str;
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}
			
		}else{
			
			$('dvcontainer').innerHTML = "No data";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}

	/*------------------------------------------------------------------------------  
	   Get Editor choice VDO
	  -------------------------------------------------------------------------------*/
	this.getEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			vdo = self.parser.getEditorChoice(xml);
			//$('hidden_tag').innerHTML= $('hidden_tag').innerHTML+" " +vdo.vdoid+ " ";
			var stage = document.getElementById('dvcontainer');
			var div = document.getElementById('vdo_box');
			var template_str = div.innerHTML;
				//Display photo info
				template_str = template_str.replace("{vdo_id}",vdo.vdoid);
				if(vdo.vdoname.length>8){
					vdo.vdoname = vdo.vdoname.substring(0,8)+"...";
				}
				var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"> \
							<span style="font-family: Tahoma; font-size: 11px; color: #666666;">'+vdo.vdoname+'</span>';
				template_str = template_str.replace("{vdo_name}", temptext);

				var image_online="";//(vdo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
				var image_ec=(vdo.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
				
				if(vdo.vdouser.displayname.length>5){
					vdo.vdouser.displayname = vdo.vdouser.displayname.substring(0,5)+"...";
				}
				vdo.vdouser.displayname = vdo.vdouser.displayname.replace("<"," ");
				vdo.vdouser.displayname = vdo.vdouser.displayname.replace(">"," ");

				temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+vdo.vdouser.id+',\'vdo\')">By:'+vdo.vdouser.displayname+'</a>' + image_ec + '</span>';

				template_str = template_str.replace("{vdo_userdisplay}",temptext);		
				template_str = template_str.replace("{rating_id}",'rating_'+vdo.vdoid);		
				var thumbnail = document.createElement("span");
				thumbnail.className = 'vdo_box';
				thumbnail.innerHTML = template_str;
				stage.appendChild(thumbnail);
				//รูป
				var frame = document.getElementById("vdo_"+vdo.vdoid);
				var pic = document.getElementById("picture"+vdo.vdoid);
				if(frame!=null && pic == null) {
					image = document.createElement("img");
					image.className = "picture_set";
					image.src = vdopath+vdo.vdothumbnail_url;
					image.setAttribute("onError","this.src='"+truelifethumb+"'");
					image.id = "picture"+vdo.vdoid;
					image.style.cursor='hand';
					image.onerror = function(){
							this.src=truelifethumb;
						}

					frame.appendChild(image);
					self.createContextMenu(vdo.folderid+"-"+vdo.vdoid,vdo.vdoid,vdo.vdouser.username,'vdo');
				}
					
				//เรตติ้ง
				var frame = document.getElementById("rating_"+vdo.vdoid);
				if(frame!=null) {
					var text = "";
					var a = self.countRating(vdo.vdorating,vdo.vdoratingcount);
					for(var j=1;j<=5;j++){
						if(j<=a){
							text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
						}else if(a-j>-1 && a-j<0){
							text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
						}else{
							text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
						}
					}
					frame.innerHTML = text;
				}
				var tag = "";
				var index_tag = $('relate_tag').innerHTML.split(",");
				var i = index_tag.length;
				for (var k=0;k<vdo.vdotaggings.length;k++) {
					tag =  '<a href="javascript:changeTag(\'' + vdo.vdotaggings[k]+ '\')">' + vdo.vdotaggings[k] + '</a>';
					check = true;
					for (var l=0;l<index_tag.length;l++){
						temptag = index_tag[l];
						if(temptag==tag){
							check = false;
						}
					}
					if(check== true && i<21){
						i++;
						$('relate_tag').innerHTML = $('relate_tag').innerHTML + tag+",";
					}
				}
		}
	}	
	
this.getBGEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			blog = self.parser.getBGEditorChoice(xml);
			var stage = document.getElementById('dvcontainer');
			var div = document.getElementById('blog_box');
			var template_str = div.innerHTML;
				//Display blog info
				template_str = template_str.replace("{blog_id}",blog.vdoid);
					blog.vdoname = blog.vdoname.replace(/\</g,'&lt;');
					blog.vdoname = blog.vdoname.replace(/\>/g,'&gt;');
					if(blog.vdoname.length>35){
							blog.vdoname = blog.vdoname.substring(0,35)+"...";
						}
					
					var image_ec=(blog.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif">':'';					
					var temptext= '<p class="grlink" align="left" style="float:left;margin:0px;"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">\
											<a href="http://minihome.truelife.com/'+blog.vdouser.username+'/blog/'+blog.vdoid+'" target="_blank">'+blog.vdoname+'</a></p><p align="right" style="text-align:right;margin:0px;">'+image_ec+'</p>';
					template_str = template_str.replace("{blog_name}", temptext);
					var image_online= "";(blog.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					
					if(blog.vdouser.displayname.length>35){
							blog.vdouser.displayname = blog.vdouser.displayname.substring(0,35)+"...";
						}
					blog.vdouser.displayname = blog.vdouser.displayname.replace("<"," ");
					blog.vdouser.displayname = blog.vdouser.displayname.replace(">"," ");

					temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+blog.vdouser.id+',\'blog\')">By:'+blog.vdouser.displayname+'</a></span>';
					template_str = template_str.replace("{blog_online}",image_online);		
					blog.vdodescription = blog.vdodescription.stripTags();
					blog.vdodescription = blog.vdodescription.replace(/\</g,'&lt;');
					blog.vdodescription = blog.vdodescription.replace(/\>/g,'&gt;');
					if(blog.vdodescription.length>120){
							blog.vdodescription = blog.vdodescription.substring(0,120)+"...";
						}				
					template_str = template_str.replace("{blog_userdisplay}",temptext);		
					var datetime = sinceForBlog(blog.vdocreation_date);
					template_str = template_str.replace("{blog_time}",datetime);
					temptext = blog.vdodescription;
					var re = /<\S[^><]*>/g;
					temptext = temptext.replace(re,"");
					template_str = template_str.replace("{blog_sample}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+blog.vdoid);		
					var thumbnail = document.createElement("span");
					thumbnail.className = 'blog_box';
					thumbnail.id= blog.vdoid;

					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+blog.vdoid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(blog.vdorating,blog.vdoratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}
				var tag = "";
				var index_tag = $('relate_tag').innerHTML.split(",");
				var i = index_tag.length;
				for (var k=0;k<blog.vdotaggings.length;k++) {
					tag =  '<a href="javascript:changeTag(\'' + blog.vdotaggings[k]+ '\')">' + blog.vdotaggings[k] + '</a>';
					check = true;
					for (var l=0;l<index_tag.length;l++){
						temptag = index_tag[l];
						if(temptag==tag){
							check = false;
						}
					}
					if(check== true && i<21){
						i++;
						$('relate_tag').innerHTML = $('relate_tag').innerHTML + tag+",";
					}
				}
		}
	}	
this.getPTEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			photo = self.parser.getPTEditorChoice(xml);
			var stage = document.getElementById('dvcontainer');
			var div = document.getElementById('photo_box');
			var template_str = div.innerHTML;
				//Display photo info

				template_str = template_str.replace("{photo_id}",photo.vdoid);
				if(photo.vdoname.length>8){
					photo.vdoname = photo.vdoname.substring(0,8)+"...";
				}
				var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"> \
							<span style="font-family: Tahoma; font-size: 11px; color: #666666;">'+photo.vdoname+'</span>';
				template_str = template_str.replace("{photo_name}", temptext);

				var image_online= "";//(photo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
				var image_ec=(photo.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
				
				if(photo.vdouser.displayname.length>5){
					photo.vdouser.displayname = photo.vdouser.displayname.substring(0,5)+"...";
				}
				photo.vdouser.displayname = photo.vdouser.displayname.replace("<"," ");
				photo.vdouser.displayname = photo.vdouser.displayname.replace(">"," ");

				temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+photo.vdouser.id+',\'photo\')">By:'+photo.vdouser.displayname+'</a>' + image_ec + '</span>';

				template_str = template_str.replace("{photo_userdisplay}",temptext);		
				template_str = template_str.replace("{rating_id}",'rating_'+photo.vdoid);		
				var thumbnail = document.createElement("span");
				thumbnail.className = 'photo_box';
				thumbnail.innerHTML = template_str;
				stage.appendChild(thumbnail);
				//รูป
				var frame = document.getElementById("photo_"+photo.vdoid);
				var pic = document.getElementById("picture"+photo.vdoid);
				if(frame!=null && pic == null) {
					image = document.createElement("img");
					image.className = "picture_set";
					image.src = photo.vdothumbnail_url;
					image.setAttribute("onError","this.src='"+truelifethumb+"'");
					image.id = "picture"+photo.vdoid;
					image.style.cursor='hand';
					image.border = 0 ;
					image.onerror = function(){
							this.src=truelifethumb;
						}
						var a = document.createElement("a");
						a.href="http://minihome.truelife.com/"+photo.vdouser.username+"/photo/"+photo.folderid+"-"+photo.vdoid;
						a.target="_blank";
						a.appendChild(image);
						frame.appendChild(a);

		//			self.createContextMenu(photo.folderid+"-"+photo.photoid,photo.photoid,photo.photouser.username,'photo');
				}
					
				//เรตติ้ง
				var frame = document.getElementById("rating_"+photo.vdoid);
				if(frame!=null) {
					var text = "";
					var a = self.countRating(photo.vdorating,photo.vdoratingcount);
					for(var j=1;j<=5;j++){
						if(j<=a){
							text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
						}else if(a-j>-1 && a-j<0){
							text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
						}else{
							text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
						}
					}
					frame.innerHTML = text;
				}
				var tag = "";
				var index_tag = $('relate_tag').innerHTML.split(",");
				var i = index_tag.length;
				for (var k=0;k<photo.vdotaggings.length;k++) {
					tag =  '<a href="javascript:changeTag(\'' + photo.vdotaggings[k]+ '\')">' + photo.vdotaggings[k] + '</a>';
					check = true;
					for (var l=0;l<index_tag.length;l++){
						temptag = index_tag[l];
						if(temptag==tag){
							check = false;
						}
					}
					if(check== true && i<21){
						i++;
						$('relate_tag').innerHTML = $('relate_tag').innerHTML + tag+",";
					}
				}
		}
	}	
	this.getMainEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			vdo = self.parser.getEditorChoice(xml);
			//$('hidden_tag').innerHTML= $('hidden_tag').innerHTML+" " +vdo.vdoid+ " ";
			var stage = document.getElementById('dvcontainerec');
			var div = document.getElementById('vdo_box_ec');
			var template_str = div.innerHTML;
				//Display photo info
				if(vdo.vdoname.length>8){
					vdo.vdoname = vdo.vdoname.substring(0,8)+"...";
				}
				var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">\
							'+vdo.vdoname;
				template_str = template_str.replace("{vdo_name}", temptext);

				var image_online= "";//(vdo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
				
				if(vdo.vdouser.displayname.length>6){
					vdo.vdouser.displayname = vdo.vdouser.displayname.substring(0,6)+"...";
				}
				vdo.vdouser.displayname = vdo.vdouser.displayname.replace("<"," ");
				vdo.vdouser.displayname = vdo.vdouser.displayname.replace(">"," ");

				temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+vdo.vdouser.id+',\'vdo\')">By:'+vdo.vdouser.displayname+'</a></span>';

				template_str = template_str.replace("{vdo_userdisplay}",temptext);		
				div.innerHTML = template_str;
				div.style.display= "block";
				//รูป
				var frame = document.getElementById("vdo_ec");
				if(frame!=null) {
					frame.innerHTML ="";
					image = document.createElement("img");
					image.className = "picture_set";
					image.src = vdopath+vdo.vdothumbnail_url;
					image.id = "picturevdoec";
					image.style.cursor='hand';
					image.onerror = function(){
							this.src=truelifethumb;
						}
					frame.appendChild(image);
					self.createContextMenu(vdo.folderid+"-"+vdo.vdoid,"vdoec",vdo.vdouser.username,'vdo');
				}
					
				//เรตติ้ง
				var frame = document.getElementById("rating_vdo_ec");
				if(frame!=null) {
					var text = "";
					var a = self.countRating(vdo.vdorating,vdo.vdoratingcount);
					for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
							}
					}
					frame.innerHTML = text;
				}
		}
	}
/*--------------------------------------------------------
	 RENDER				show VDO List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOListMainEditor = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainerec');
		var div = document.getElementById('vdo_box');
		div.style.display="none";
		var vdoids = new Array();
		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOListbyEditor(xml,vdoids);
			var	control = new Control();
			//$('hidden_tag').innerHTML= vdoids.length;

			for (var j=0;j<vdoids.length; j++) {
				self.vdoEC = new VDO();
				control.getVDOMainEC(vdoids[j] );
			}
		}else{
			$('dvcontainerec').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
		}


	}

/*--------------------------------------------------------
	 RENDER				show VDO List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOListEditor = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		var div = document.getElementById('vdo_box');
		div.style.display="none";
		var vdoids = new Array();
		$('loading').style.display="none";
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOListbyEditor(xml,vdoids);
			var str_html = '';
			n= 0;
			if(objlist!=null){
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

			}else{
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}			
			var	control = new Control();
			//$('hidden_tag').innerHTML= vdoids.length;

			for (var j=0;j<vdoids.length; j++) {
				self.vdoEC = new VDO();
				control.getVDOEC(vdoids[j] );
				//Create breaker on 5 vdos
				if(j % 5==4){
					var breaker = document.createElement("div");
					breaker.className = "breaker";
					stage.appendChild(breaker);
				}
			}
		}else{
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}

/*--------------------------------------------------------
	 RENDER				show VDO List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOListOO = function(request) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		stage.innerHTML = "";
		var div = document.getElementById('vdo_box');
		div.style.display="none";

		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOList(xml);
			var str_html = '';
			n= 0;
			if(objlist!=null &&objlist.vdos.length>0){
				var stage = document.getElementById('dvcontainer');
				var div = document.getElementById('vdo_box');
				$('loading').innerHTML = "";
				$('loading').style.display="none";
	
				for(var i=0;i< objlist.vdos.length;i++){
					var vdo = objlist.vdos[i];
					var template_str = div.innerHTML;
						//Display photo info
					template_str = template_str.replace("{vdo_id}",vdo.vdoid);
					if(vdo.vdoname.length>8){
							vdo.vdoname = vdo.vdoname.substring(0,8)+"...";
						}
					
					
					var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"> \
											<span style="font-family: Tahoma; font-size:11px; color: #666666;">'+vdo.vdoname+'<span>';
					template_str = template_str.replace("{vdo_name}", temptext);

					var image_online="";//(vdo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					var image_ec=(vdo.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
					
					if(vdo.vdouser.displayname.length>5){
							vdo.vdouser.displayname = vdo.vdouser.displayname.substring(0,5)+"...";
						}
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace("<"," ");
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace(">"," ");

					temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+vdo.vdouser.id+',\'vdo\')">By:'+vdo.vdouser.displayname+'</a>' + image_ec + '</span>';
					template_str = template_str.replace("{vdo_userdisplay}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+vdo.vdoid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'vdo_box';
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);
					//รูป
					var frame = document.getElementById("vdo_"+vdo.vdoid);
					var pic = document.getElementById("picture"+vdo.vdoid);
					if(frame!=null && pic == null) {
						image = document.createElement("img");
						image.className = "picture_set";
						image.src = vdopath+vdo.vdothumbnail_url;
						image.id = "picture"+vdo.vdoid;
						image.style.cursor='hand';
						image.onerror = function(){
							this.src=truelifethumb;
						}
						frame.appendChild(image);
						self.createContextMenu(vdo.folderid+"-"+vdo.vdoid,vdo.vdoid,vdo.vdouser.username,'vdo');
					}
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+vdo.vdoid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(vdo.vdorating,vdo.vdoratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}

					//menu
					
					
					//Create breaker on 5 vdos
					if(i % 5==4){
						var breaker = document.createElement("div");
						breaker.className = "breaker";
						stage.appendChild(breaker);
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

				//tag
				text="";

				for(i=0;i<objlist.index_tags.length;i++){
					text =  text + '<a href="javascript:changeTag(\'' + objlist.index_tags[i] + '\')">' + objlist.index_tags[i] + '</a>';
					if(i<objlist.index_tags.length-1){
						text = text + ", ";
					}
				}
				$('relate_tag').innerHTML = text ;

			}else{
				$('loading').innerHTML = "";				
				$('loading').style.display="none";
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}
			
		}else if(result!=null && result.code != '200') {  
			$('loading').innerHTML = "";
			$('loading').style.display="none";
			$('dvcontainer').innerHTML = "No data";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}else{
			$('loading').innerHTML = "";
			$('loading').style.display="none";
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}
	
/*--------------------------------------------------------
	 RENDER				show Blog List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showBlogListEditor = function(request) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		var div = document.getElementById('blog_box');
		div.style.display="none";
		var blogids = new Array();
		$('loading').style.display="none";

		// service success	
		if(result!=null && result.code == '200') {  
			var objlist = self.parser.getVDOListbyEditor(xml,blogids);
			var str_html = '';
			n= 0;
			if(objlist!=null){
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

			}else{
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}			
			var	control = new Control();
			//$('hidden_tag').innerHTML= blogids.length;

			for (var j=0;j<blogids.length; j++) {
				self.blogEC = new PHOTO();
				control.getBlogEC(blogids[j] );
				//Create breaker on 5 blogs
				if(j % 2==1){
					var breaker = document.createElement("div");
					breaker.className = "breaker";
					stage.appendChild(breaker);
				}
			}
		}else{
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}

/*--------------------------------------------------------
	 RENDER				show Photo List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showPhotoListEditor = function(request) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		var div = document.getElementById('photo_box');
		div.style.display="none";
		var photoids = new Array();
		$('loading').style.display="none";

		// service success	
		if(result!=null && result.code == '200') {  
			var objlist = self.parser.getVDOListbyEditor(xml,photoids);
			var str_html = '';
			n= 0;
			if(objlist!=null){
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

			}else{
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}			
			var	control = new Control();
			//$('hidden_tag').innerHTML= photoids.length;

			for (var j=0;j<photoids.length; j++) {
				self.photoEC = new PHOTO();
				control.getPhotoEC(photoids[j] );
				//Create breaker on 5 photos
				if(j % 5==4){
					var breaker = document.createElement("div");
					breaker.className = "breaker";
					stage.appendChild(breaker);
				}
			}
		}else{
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}


/*--------------------------------------------------------
	 RENDER				show Blog List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showBlogListOO = function(request) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		stage.innerHTML = "";
		var div = document.getElementById('Blog_box');
		div.style.display="none";
		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getBlogList(xml);
			if(objlist==null ||objlist.blogs.length<=0){
				objlist =self.parser.getBlogListByTag(xml);
			}
			
			var str_html = '';
			n= 0;
			$('loading').style.display="none";
			if(objlist!=null &&objlist.blogs.length>0){
				var stage = document.getElementById('dvcontainer');
				var div = document.getElementById('blog_box');
		
				for(var i=0;i< objlist.blogs.length;i++){
					var blog = objlist.blogs[i];
					var template_str = div.innerHTML;
						//Display blog info
					template_str = template_str.replace("{blog_id}",blog.blogid);
					blog.blogname = blog.blogname.replace(/\</g,'&lt;');
					blog.blogname = blog.blogname.replace(/\>/g,'&gt;');

					if(blog.blogname.length>35){
							blog.blogname = blog.blogname.substring(0,35)+"...";
						}
					
					var image_ec=(blog.blogisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif">':'';					
					var temptext= '<p class="grlink" align="left" style="float:left;margin:0px;"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">\
											<a href="http://minihome.truelife.com/'+blog.bloguser.username+'/blog/'+blog.blogid+'" target="_blank">'+blog.blogname+'</a></p><p align="right" style="text-align:right;margin:0px;">'+image_ec+'</p>';
					template_str = template_str.replace("{blog_name}", temptext);
					var image_online="";//(blog.bloguser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					
					if(blog.bloguser.displayname.length>35){
							blog.bloguser.displayname = blog.bloguser.displayname.substring(0,35)+"...";
						}
					blog.bloguser.displayname = blog.bloguser.displayname.replace("<"," ");
					blog.bloguser.displayname = blog.bloguser.displayname.replace(">"," ");

					//temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+blog.bloguser.id+',\'blog\')">By:'+blog.bloguser.displayname+'</a></span>';
					temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+blog.bloguser.id+',\'blog\')">By:'+blog.bloguser.username+'</a></span>';
					template_str = template_str.replace("{blog_online}",image_online);		
					blog.blogdescription = blog.blogdescription.stripTags();

					//blog.blogdescription = blog.blogdescription.replace(/\</g,'&lt;');
					//blog.blogdescription = blog.blogdescription.replace(/\>/g,'&gt;');
					if(blog.blogdescription.length>120){
							blog.blogdescription = blog.blogdescription.substring(0,120)+"...";
						}				
					template_str = template_str.replace("{blog_userdisplay}",temptext);		
					var datetime = sinceForBlog(blog.blogpost_datetime);
					template_str = template_str.replace("{blog_time}",datetime);
					temptext = blog.blogdescription;
					var re = /<\S[^><]*>/g;
					temptext = temptext.replace(re,"");
					template_str = template_str.replace("{blog_sample}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+blog.blogid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'blog_box';
					thumbnail.id= blog.blogid;
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);					
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+blog.blogid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(blog.blograting,blog.blogratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}
					
					//Create breaker on 2 blog2
					if(i % 2==1){
						var breaker = document.createElement("div");
						breaker.className = "breaker";
						stage.appendChild(breaker);
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

				//tag
				text="";

				for(i=0;i<objlist.index_tags.length;i++){
					text =  text + '<a href="javascript:changeTag(\'' + objlist.index_tags[i] + '\')">' + objlist.index_tags[i] + '</a>';
					if(i<objlist.index_tags.length-1){
						text = text + ", ";
					}
				}
				$('relate_tag').innerHTML = text ;

			}else{
				$('loading').style.display="none";
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}
		}else if(result!=null && result.code != '200') {  	
			$('loading').style.display="none";
			$('dvcontainer').innerHTML = "No data";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}else{
			$('loading').style.display="none";
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดเรื่องราวได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}
/*--------------------------------------------------------
	 RENDER				show Photo List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showPhotoListOO = function(request) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		stage.innerHTML = "";
		var div = document.getElementById('photo_box');
		div.style.display="none";
		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getPhotoList(xml);
			if(objlist==null ||objlist.photos.length<=0){
				objlist =self.parser.getPhotoListByTag(xml);
			}
			
			var str_html = '';
			n= 0;
			$('loading').style.display="none";
			if(objlist!=null &&objlist.photos.length>0){	
				for(var i=0;i< objlist.photos.length;i++){
					var photo = objlist.photos[i];
					var template_str = div.innerHTML;
						//Display photo info
					template_str = template_str.replace("{photo_id}",photo.photoid);
					if(photo.photoname.length>8){
							photo.photoname = photo.photoname.substring(0,8)+"...";
						}
					
					
					var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"> \
											<span style="font-family: Tahoma; font-size:11px; color: #666666;">'+photo.photoname+'<span>';
					template_str = template_str.replace("{photo_name}", temptext);

					var image_online="";//(photo.photouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					var image_ec=(photo.photoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
					
					if(photo.photouser.displayname.length>5){
							photo.photouser.displayname = photo.photouser.displayname.substring(0,5)+"...";
						}
					photo.photouser.displayname = photo.photouser.displayname.replace("<"," ");
					photo.photouser.displayname = photo.photouser.displayname.replace(">"," ");
					if(photo.photouser.username=="unknown"){photo.photouser.username=photo.photouser.old_username;};
					temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+photo.photouser.id+',\'photo\')">By:'+photo.photouser.displayname+'</a>' + image_ec + '</span>';
					template_str = template_str.replace("{photo_userdisplay}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+photo.photoid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'photo_box';
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);
					//รูป
					var frame = document.getElementById("photo_"+photo.photoid);
					var pic = document.getElementById("picture"+photo.photoid);
					if(frame!=null && pic == null) {
						image = document.createElement("img");
						image.className = "picture_set";
						image.src = photo.photothumbnail_url;
						image.id = "picture"+photo.photoid;
						image.style.cursor='hand';
						image.border = 0 ;
						image.onerror = function(){
							this.src=truelifethumb;
						}
						var a = document.createElement("a");
						a.href="http://minihome.truelife.com/"+photo.photouser.username+"/photo/"+photo.folderid+"-"+photo.photoid;
						a.target="_blank";
						a.appendChild(image);
						frame.appendChild(a);
			//			self.createContextMenu(photo.folderid+"-"+photo.photoid,photo.photoid,photo.photouser.username,'photo');
					}
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+photo.photoid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(photo.photorating,photo.photoratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st1.gif" width="14" height="14" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/st3.gif" width="14" height="14" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/st2.gif" width="14" height="14" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}

					//menu
					
					
					//Create breaker on 5 photos
					if(i % 5==4){
						var breaker = document.createElement("div");
						breaker.className = "breaker";
						stage.appendChild(breaker);
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'{prev_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/mini/1_5/action_back.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				if (objlist.current_page<objlist.page_count){
					nextText = '<a href="javascript:changePage(\'{next_page}\')"><img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/mini/1_5/action_forward.gif" align="absmiddle" width="16" height="16" border="0">';
				}
				text = '<span class="btxt">';
				text = text + prevText + 'หน้า {current_page} / {page_count}';
				text = text + nextText + '&nbsp;&nbsp;&nbsp;';
				text = text +'ไปที่หน้า <img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">';
				text = text +'<input name="pageBox" id="pageBox" type="text" class="nortxt" size="3" onkeypress="goSubmit(pageBox.value,'+objlist.page_count+');"><a href="javascript:changePage(pageBox.value,'+objlist.page_count+')"><img src="http://www.truelife.com/images/go.gif" align="absmiddle" width="21" height="13" border="0"></a>';
				text = text +'</span> ';
				text = text.replace('{current_page}',objlist.current_page);
				text = text.replace('{page_count}',objlist.page_count);
				$('page_detail').innerHTML = text ;

				//tag
				text="";

				for(i=0;i<objlist.index_tags.length;i++){
					text =  text + '<a href="javascript:changeTag(\'' + objlist.index_tags[i] + '\')">' + objlist.index_tags[i] + '</a>';
					if(i<objlist.index_tags.length-1){
						text = text + ", ";
					}
				}
				$('relate_tag').innerHTML = text ;

			}else{
				$('loading').style.display="none";
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;

			}
		}else if(result!=null && result.code != '200') {  
			$('loading').style.display="none";
				$('dvcontainer').innerHTML = "No data";
				$('relate_tag').innerHTML = '' ;
				$('page_detail').innerHTML = '' ;
		}else{
			$('loading').style.display="none";
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดรูปภาพได้ในขณะนี้";
			$('relate_tag').innerHTML = '' ;
			$('page_detail').innerHTML = '' ;
		}


	}
	

/*--------------------------------------------------------
	 RENDER				show VDO List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOListTheme = function(request,id,max,arrow) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
			
		var stage = document.getElementById('dvcontainer_theme'+id);
		stage.innerHTML="";
		var div = document.getElementById('vdo_box_theme');
		div.style.display="none";

		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOList(xml);
			var str_html = '';
			n= 0;
			if(objlist!=null &&objlist.vdos.length>0){
				for(var i=0;i< objlist.vdos.length;i++){
					var vdo = objlist.vdos[i];
					var template_str = div.innerHTML;
						//Display photo info
					template_str = template_str.replace("{vdo_id}",vdo.vdoid);
					if(vdo.vdoname.length>8){
							vdo.vdoname = vdo.vdoname.substring(0,8)+"...";
						}
					
					//var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">'+((id=="")?("<span style=\"font-family: Tahoma; font-size: 11px; color: #33cc00\">"+vdo.vdoname+"</span>"):("<span style=\"font-family: Tahoma; font-size: 11px; color: #ffffff\">"+vdo.vdoname+"</span>"));
					var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"><span style=\"font-family: Tahoma; font-size: 11px; color: #ffffff\">'+vdo.vdoname+'</span>';
					template_str = template_str.replace("{vdo_name}", temptext);

					var image_online="";//(vdo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					var image_ec=(vdo.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif">':'';
					
					if(vdo.vdouser.displayname.length>6){
							vdo.vdouser.displayname = vdo.vdouser.displayname.substring(0,6)+"...";
						}
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace("<"," ");
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace(">"," ");

					temptext = '<span class="'+((id=="")?"ypalink":"chlink")+'" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+vdo.vdouser.id+',\'vdo\')">By:'+vdo.vdouser.displayname+'</a>' + image_ec + '</span>';
					template_str = template_str.replace("{vdo_userdisplay}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+vdo.vdoid+"_theme");		
					var thumbnail = document.createElement("span");
					if(id=="1"){thumbnail.className = 'vdo_box';}else{thumbnail.className = 'vdo_box_theme';}
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);
					//รูป
					var frame = document.getElementById("vdo_"+vdo.vdoid+"_theme");
					var pic = document.getElementById("picture"+vdo.vdoid+"_theme");
					if(frame!=null && pic == null) {
						image = document.createElement("img");
						image.className = "picture_set";
						image.src = vdopath+vdo.vdothumbnail_url;
						image.setAttribute("onError","this.src='"+truelifethumb+"'");
						image.id = "picture"+vdo.vdoid+"_theme";
						image.style.cursor='hand';
						image.onerror = function(){
							this.src=truelifethumb;
						}
						frame.appendChild(image);
						self.createContextMenu(vdo.folderid+"-"+vdo.vdoid,vdo.vdoid+"_theme",vdo.vdouser.username,'vdo');
					}
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+vdo.vdoid+"_theme");
					if(frame!=null) {
						var text = "";
						var a = self.countRating(vdo.vdorating,vdo.vdoratingcount);
						for(var j=1;j<=5;j++){
							/*if(id==""){
								if(j<=a){
									text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
								}else if(a-j>-1 && a-j<0){
									text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
								}else{
									text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
								}
							}else{*/
								if(j<=a){
									text = text +'<img src="images/ico_rate_star.gif" width="11" height="11">';
								}else if(a-j>-1 && a-j<0){
									text = text +'<img src="images/ico_rate_star3.gif" width="11" height="11">';
								}else{
									text = text +'<img src="images/ico_rate_star2.gif" width="11" height="11">';
								}
							//}
						}
						frame.innerHTML = text;
					}
				}
				if(arrow!=""){
					if (objlist.current_page>1){
						prevText = '<a href="javascript:changePage(\'VDO_THEME\',\'{prev_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_l.gif" border="0"></a>';
						prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
					}else {
						prevText =  '<img src="http://www.truelife.com/images/index/mm/arr_l.gif"  border="0">';
					}
					if (parseInt(objlist.current_page)<parseInt(objlist.page_count)){
						nextText = '<a href="javascript:changePage(\'VDO_THEME\',\'{next_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0"></a>';
						nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
					}else {
						nextText =  '<img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0">';
					}

					$('vdo_arr_r_theme').innerHTML=nextText;
					$('vdo_arr_l_theme').innerHTML=prevText;
				}
			}else{
				$('dvcontainer_theme'+id).innerHTML = "No data";
			}
			
		}else{
			
			$('dvcontainer_theme'+id).innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
		}


	}

/*--------------------------------------------------------
	 RENDER				show VDO List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showVDOListMain = function(request,load) {
		xml = request.responseXML;
		//xml="http://www.truelife.com/xml/media_vdo_content.xml";
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer');
		stage.innerHTML="";
		var div = document.getElementById('vdo_box');
		div.style.display="none";

		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOList(xml);
			var str_html = '';
			n= 0;
			if(objlist!=null &&objlist.vdos.length>0){
				for(var i=0;i< objlist.vdos.length;i++){
					var vdo = objlist.vdos[i];
					var template_str = div.innerHTML;
						//Display photo info
					template_str = template_str.replace("{vdo_id}",vdo.vdoid);
					if(vdo.vdoname.length>8){
							vdo.vdoname = vdo.vdoname.substring(0,8)+"...";
						}
					
					
					var temptext= '<img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"></font>\
											'+vdo.vdoname;
					template_str = template_str.replace("{vdo_name}", temptext);

					var image_online="";//(vdo.vdouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					var image_ec=(vdo.vdoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif">':'';
					
					if(vdo.vdouser.displayname.length>6){
							vdo.vdouser.displayname = vdo.vdouser.displayname.substring(0,6)+"...";
						}
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace("<"," ");
					vdo.vdouser.displayname = vdo.vdouser.displayname.replace(">"," ");

					temptext = '<span class="grlink" align="left">' + image_online + '<a href="javascript:openHomeHomeGo('+vdo.vdouser.id+',\'vdo\')">By:'+vdo.vdouser.displayname+'</a>' + image_ec + '</span>';
					template_str = template_str.replace("{vdo_userdisplay}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+vdo.vdoid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'vdo_box';
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);
					//รูป
					var frame = document.getElementById("vdo_"+vdo.vdoid);
					var pic = document.getElementById("picture"+vdo.vdoid);
					if(frame!=null && pic == null) {
						image = document.createElement("img");
						image.className = "picture_set";
						image.src = vdopath+vdo.vdothumbnail_url;
						image.setAttribute("onError","this.src='"+truelifethumb+"'");
						image.id = "picture"+vdo.vdoid;
						image.style.cursor='hand';
						image.onerror = function(){
							this.src=truelifethumb;
						}
						frame.appendChild(image);
						self.createContextMenu(vdo.folderid+"-"+vdo.vdoid,vdo.vdoid,vdo.vdouser.username,'vdo');
					}
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+vdo.vdoid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(vdo.vdorating,vdo.vdoratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'video\',\'{prev_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_l.gif" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/index/mm/arr_l.gif"  border="0">';
				}
				if (parseInt(objlist.current_page)<parseInt(objlist.page_count)){
					nextText = '<a href="javascript:changePage(\'video\',\'{next_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0">';
				}

				$('vdo_arr_r').innerHTML=nextText;
				$('vdo_arr_l').innerHTML=prevText;
			}else{
				$('dvcontainer').innerHTML = "No data";
			}
			
		}else{
			$('dvcontainer').innerHTML = "ไม่สามารถเปิดวีดีโอได้ในขณะนี้";
		}


	}



	this.htmlReplace =function(str) {
		var ss = str.split("<");
		var n="";

		for (i = 0; i < ss.length; i++){
			var sa=ss[i].split(">");
			if(sa.length>1){
				n=n+sa[1];
			}else{
				n=n+sa[0];
			}

		}
		return n;
	}

	/**
	*/
	this.createContextMenu = function(link,id,user,type){
			var ccMenu = new CustomContextMenu();
				ccMenu.setStyle("context_popup");
				ccMenu.append(new MenuItem('<img src="http://www.truelife.com/images/mini/icon/photo_ret.gif" align="absmiddle" border="0"/> Play',"http://minihome.truelife.com/"+user+"/vdo/"+link+"-1","context_menu","VDO"));
				ccMenu.append(SEPARATOR);

				ccMenu.append(new MenuItem('<img src="http://www.truelife.com/images/mini/icon/photo_ret.gif" align="absmiddle" border="0"/> View',"http://minihome.truelife.com/"+user+"/vdo/"+link,"context_menu","VDO"));
				ccMenu.attachTo("picture"+id);
	}




	/*--------------------------------------------------------
	 RENDER				show PHOTO List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showPHOTOListMain = function(request,load) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainer_photo');
		var div = document.getElementById('photo_box');
		div.style.display="none";
		stage.innerHTML="";
		// service success	
		if(result!=null && result.code == '200') { 
			var objlist = self.parser.getPhotoList(xml);
			var str_html = '';
			n= 0;
			$('loading_photo').style.display="none";
			if(objlist!=null &&objlist.photos.length>0){
				for(var i=0;i< objlist.photos.length;i++){
					var photo = objlist.photos[i];
					var template_str = div.innerHTML;
						//Display photo info
					template_str = template_str.replace("{photo_id}",photo.photoid);
					if(photo.photoname.length>8){
							photo.photoname = photo.photoname.substring(0,8)+"...";
						}
					
					
					var temptext= '<span class="grlink" align="left"><span class="btxt"><font color="#333333"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"></font></span> \
											<a href="http://minihome.truelife.com/'+photo.photouser.username+'/photo/'+photo.photoid+'">'+photo.photoname+'</a></span></span>';
					template_str = template_str.replace("{photo_name}", temptext);

					var image_online="";//(photo.photouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					var image_ec=(photo.photoisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif" width="20" height="19">':'';
					
					if(photo.photouser.displayname.length>6){
							photo.photouser.displayname = photo.photouser.displayname.substring(0,6)+"...";
					}
					photo.photouser.displayname = photo.photouser.displayname.replace("<"," ");
					photo.photouser.displayname = photo.photouser.displayname.replace(">"," ");
					temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+photo.photouser.id+',\'photo\')">By:'+photo.photouser.displayname+'</a>' + image_ec + '</span>';
					template_str = template_str.replace("{photo_online}",image_online);		
					template_str = template_str.replace("{photo_userdisplay}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+photo.photoid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'vdo_box';
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);
					//รูป
					var frame = document.getElementById("photo_"+photo.photoid);
					var pic = document.getElementById("picture"+photo.photoid);
					if(frame!=null && pic == null) {
						image = document.createElement("img");
						image.className = "picture_set";
						if(photo.photooriginal_url.toLowerCase().indexOf(".gif")>-1){
							image.src = photo.photooriginal_url;
						}else{
							image.src = photo.photothumbnail_url;
						}
						image.id = "picture"+photo.photoid;
						image.border = 0 ;
						var a = document.createElement("a");
						a.href="http://minihome.truelife.com/"+photo.photouser.username+"/photo/"+photo.folderid+"-"+photo.photoid;
						a.target="_blank";
						a.appendChild(image);
						frame.appendChild(a);
						//self.createContextMenu(photo.photoid,photo.photouser.username,"photo");
					}
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+photo.photoid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(photo.photorating,photo.photoratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'photo\',\'{prev_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_l.gif" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/index/mm/arr_l.gif"  border="0">';
				}
				if (parseInt(objlist.current_page)<parseInt(objlist.page_count)){
					nextText = '<a href="javascript:changePage(\'photo\',\'{next_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0">';
				}

				$('photo_arr_r').innerHTML=nextText;
				$('photo_arr_l').innerHTML=prevText;
				if(load=="vdo"){
					loadVDO();
				}

			}else{
				$('dvcontainer_photo').innerHTML = "No data";
				if(load=="vdo"){
					loadVDO();
				}

			}
			
		}else{
			$('dvcontainer_photo').innerHTML = "ไม่สามารถเปิดรูปภาพได้ในขณะนี้";
				if(load=="vdo"){
					loadVDO();
				}
		}


	}

		this.getMainPhotoEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			photo = self.parser.getPhotoEditorChoice(xml);
			//$('hidden_tag').innerHTML= $('hidden_tag').innerHTML+" " +photo.photoid+ " ";
			var div = document.getElementById('photo_box_ec');
			var template_str = div.innerHTML;
			//Display photo info
			if(photo.photoname.length>8){
				photo.photoname = photo.photoname.substring(0,8)+"...";
			}
			var temptext= '<span class="grlink" align="left"><span class="btxt"><font color="#333333"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"></font></span> \
						<a href="http://minihome.truelife.com/'+photo.photouser.username+'/photo/'+photo.photoid+'">'+photo.photoname+'</a></span></span>';
			template_str = template_str.replace("{photo_name}", temptext);
			var image_online="";//(photo.photouser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
			
			if(photo.photouser.displayname.length>6){
				photo.photouser.displayname = photo.photouser.displayname.substring(0,6)+"...";
			}
			photo.photouser.displayname = photo.photouser.displayname.replace("<"," ");
			photo.photouser.displayname = photo.photouser.displayname.replace(">"," ");

			temptext = '<span class="grlink" align="left">'+image_online+'<a href="javascript:openHomeHomeGo('+photo.photouser.id+',\'photo\')">By:'+photo.photouser.displayname+'</a></span>';
			template_str = template_str.replace("{photo_userdisplay}",temptext);		
			div.innerHTML = template_str;
			
			//รูป
			var frame = document.getElementById("photo_ec");
			var pic = document.getElementById("picturephoto");
			if(frame!=null && pic == null) {
				image = document.createElement("img");
				image.className = "picture_set";
				//image.src = photo.photothumbnail_url;
				if(photo.photooriginal_url.toLowerCase().indexOf(".gif")>-1){
					image.src = photo.photooriginal_url;
				}else{
					image.src = photo.photothumbnail_url;
				}
				image.id = "picturephoto";
				image.border = 0 ;
				var a = document.createElement("a");
				a.href="http://minihome.truelife.com/"+photo.photouser.username+"/photo/"+photo.folderid+"-"+photo.photoid;
				a.target="_blank";
				a.appendChild(image);
				frame.appendChild(a);
						//self.createContextMenu('photo',photo.photouser.username,'photo');
				control = new Control();
//				control.getPhotoMainECOnline(photo.photouser.id);
				control.getPhotoMainECRate(photo.photoid );
			}
			div.style.display = 'block';
		}
	}
	this.getMainPhotoEditorChoiceRate = function(request) {
		var xml = request.responseXML;
		if(xml!=null) {  
			photo = self.parser.getPhotoEditorChoiceRate(xml);
			//เรตติ้ง
			var frame = document.getElementById("rating_ec");
			if(frame!=null) {
				var text = "";
				var a = self.countRating(photo.photorating,photo.photoratingcount);
				for(var j=1;j<=5;j++){
					if(j<=a){
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
					}else if(a-j>-1 && a-j<0){
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
					}else{
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
					}
				}
				frame.innerHTML = text;
			}
		}
	}
	this.getMainPhotoEditorChoiceOnline = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		if(xml!=null ) {  
			user = self.parser.getPhotoEditorChoiceOnline(xml);
			var div = document.getElementById('photo_box_ec');
			var template_str = div.innerHTML;
				//Display photo info
			var image_online=(user.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
			template_str = template_str.replace("{photo_online}",image_online);		
			div.innerHTML = template_str;
		}
	}
/*--------------------------------------------------------
	 RENDER				show Photo List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showPHOTOListMainEditor = function(request) {

		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainerec_photo');
		var div = document.getElementById('photo_box');
		div.style.display="none";
		var photoids = new Array();
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOListbyEditor(xml,photoids);
			$('loading_photo').style.display="none";
			var	control = new Control();
			//$('hidden_tag').innerHTML= photoids.length;

			for (var j=0;j<photoids.length; j++) {
				self.photoEC = new PHOTO();
				control.getPhotoMainEC(photoids[j] );			
			}
		}else{
			$('dvcontainerec_photo').innerHTML = "ไม่สามารถเปิดรูปภาพได้ในขณะนี้";
		}


	}
/*--------------------------------------------------------
	 RENDER				show Blog List  Editor by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showBLOGListMainEditor = function(request) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
			
		var stage = document.getElementById('dvcontainerec_blog');
		var div = document.getElementById('blog_box');
		div.style.display="none";
		var blogids = new Array();
		
		// service success	
		if(result!=null && result.code == '200') {  
			
			var objlist = self.parser.getVDOListbyEditor(xml,blogids);
			var	control = new Control();
			for (var j=0;j<blogids.length; j++) {
				control.getBlogMainEC(blogids[j] );			
			}
		}else{
			$('dvcontainer_blog').innerHTML = "ไม่สามารถเปิดเรื่องราวได้ในขณะนี้";
		}


	}
	/*--------------------------------------------------------
	 RENDER				show BLOG List by prang
	 PARAMETER		XML data
	---------------------------------------------------------*/
	this.showBLOGListMain = function(request,load) {
		xml = request.responseXML;
		var result = self.parser.getResult(xml);
		
		var stage = document.getElementById('dvcontainer_blog');
		var div = document.getElementById('blog_box');
		div.style.display="none";
		stage.innerHTML="";
		// service success	
		if(result!=null && result.code == '200') { 
			var objlist = self.parser.getBlogList(xml);
			var str_html = '';
			n= 0;
			if(objlist!=null &&objlist.blogs.length>0){
				for(var i=0;i< objlist.blogs.length;i++){
					var blog = objlist.blogs[i];
					var template_str = div.innerHTML;
						//Display blog info
					if(blog.blogname.length>15){
							blog.blogname = blog.blogname.substring(0,15)+"...";
						}
					
					var image_ec=(blog.blogisEC !="false")?'<img src="http://www.truelife.com/images/mini/p3/ico_ec.gif">':'';					
					var temptext= '<p class="grlink" align="left" style="float:left;margin:0px;"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5">\
											<a href="http://minihome.truelife.com/'+blog.bloguser.username+'/blog/'+blog.blogid+'" target="_blank">'+blog.blogname+'</a></p><p align="right" style="text-align:right;margin:0px;">'+image_ec+'</p>';
					template_str = template_str.replace("{blog_name}", temptext);
					var image_online=(blog.bloguser.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
					
					if(blog.bloguser.displayname.length>6){
							blog.bloguser.displayname = blog.bloguser.displayname.substring(0,6)+"...";
						}
					blog.bloguser.displayname = blog.bloguser.displayname.replace("<"," ");
					blog.bloguser.displayname = blog.bloguser.displayname.replace(">"," ");

					//temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+blog.bloguser.id+',\'blog\')">By:'+blog.bloguser.displayname+'</a></span>';
					temptext = '<span class="grlink" align="left"><a href="javascript:openHomeHomeGo('+blog.bloguser.id+',\'blog\')">By:'+blog.bloguser.username+'</a></span>';
					template_str = template_str.replace("{blog_online}",image_online);		
					blog.blogdescription = blog.blogdescription.stripTags();
					if(blog.blogdescription.length>45){
							blog.blogdescription = blog.blogdescription.substring(0,45)+"...";
						}				
					template_str = template_str.replace("{blog_userdisplay}",temptext);		
					var datetime = sinceForBlog(blog.blogpost_datetime);
					template_str = template_str.replace("{blog_time}",datetime);
					temptext = blog.blogdescription;
					
					temptext = temptext.stripTags();
						
					template_str = template_str.replace("{blog_sample}",temptext);		
					template_str = template_str.replace("{rating_id}",'rating_'+blog.blogid);		
					var thumbnail = document.createElement("span");

					thumbnail.className = 'blog_box';
					thumbnail.id= blog.blogid;
					thumbnail.innerHTML = template_str;
					stage.appendChild(thumbnail);					
					
					//เรตติ้ง
					var frame = document.getElementById("rating_"+blog.blogid);
					if(frame!=null) {
						var text = "";
						var a = self.countRating(blog.blograting,blog.blogratingcount);
						for(var j=1;j<=5;j++){
							if(j<=a){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
							}else if(a-j>-1 && a-j<0){
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
							}else{
								text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
							}
						}
						frame.innerHTML = text;
					}
				}
				if (objlist.current_page>1){
					prevText = '<a href="javascript:changePage(\'blog\',\'{prev_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_l.gif" border="0"></a>';
					prevText = prevText.replace('{prev_page}',parseInt(objlist.current_page)-1);
				}else {
					prevText =  '<img src="http://www.truelife.com/images/index/mm/arr_l.gif"  border="0">';
				}
				if (parseInt(objlist.current_page)<parseInt(objlist.page_count)){
					nextText = '<a href="javascript:changePage(\'blog\',\'{next_page}\')"><img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0"></a>';
					nextText = nextText.replace('{next_page}',parseInt(objlist.current_page)+1);
				}else {
					nextText =  '<img src="http://www.truelife.com/images/index/mm/arr_r.gif"  border="0">';
				}

				$('blog_arr_r').innerHTML=nextText;
				$('blog_arr_l').innerHTML=prevText;
				if(load=="photo"){
					loadPHOTO();
				}
			}else{
				$('dvcontainer_blog').innerHTML = "No data";
				if(load=="photo"){
					loadPHOTO();
				}

			}
			
		}else{
			$('dvcontainer_blog').innerHTML = "ไม่สามารถเปิดเรื่องราวได้ในขณะนี้";
				if(load=="photo"){
					loadPHOTO();
				}
		}


	}

		this.getMainBlogEditorChoice = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		var result = self.parser.getResult(xml);
		// service success	
		if(result!=null && result.code == '200') {  
			blog = self.parser.getBlogEditorChoice(xml);
			//$('hidden_tag').innerHTML= $('hidden_tag').innerHTML+" " +blog.blogid+ " ";
			var div = document.getElementById('blog_box_ec');
			var template_str = div.innerHTML;
			//Display blog info
			if(blog.blogname.length>15){
				blog.blogname = blog.blogname.substring(0,15)+"...";
			}
			var temptext= '<span class="grlink" align="left"><span class="btxt"><font color="#333333"><img src="http://www.truelife.com/images/mini/icon/ar_bl.gif" width="3" height="5"></font></span> \
						<a href="http://minihome.truelife.com/'+blog.bloguser.username+'/blog/'+blog.blogid+'" target="_blank">'+blog.blogname+'</a></span></span>';
			template_str = template_str.replace("{blog_name}", temptext);
			var image_online="";
			
			template_str = template_str.replace("{blog_time}",sinceForBlog(blog.blogpost_datetime));
			temptext =blog.blogdescription;
			var re= /<\S[^><]*>/g;
			temptext = temptext.replace(re,"");
			if(temptext.length>45){
				temptext = temptext.substring(0,45)+"...";
			}
			if(temptext.length>14){
				var texttemp = "";
				texttemp = temptext.substring(0,14)+"\n";
				if(temptext.length>28){
					texttemp = texttemp + temptext.substring(14,28)+"\n";
					texttemp = texttemp + temptext.substring(28,temptext.length);
				}
				temptext = texttemp;
			}
			template_str = template_str.replace("{blog_sample}",temptext);
			if(blog.bloguser.displayname.length>6){
				blog.bloguser.displayname = blog.bloguser.displayname.substring(0,6)+"...";
			}
			blog.bloguser.displayname = blog.bloguser.displayname.replace("<"," ");
			blog.bloguser.displayname = blog.bloguser.displayname.replace(">"," ");

			temptext = '<span class="grlink" align="left">'+image_online+'<a href="javascript:openHomeHomeGo('+blog.bloguser.id+',\'blog\')">By:'+blog.bloguser.displayname+'</a></span>';
			template_str = template_str.replace("{blog_userdisplay}",temptext);		
			div.innerHTML = template_str;
						//รูป
			if(div!=null) {
				control = new Control();
				control.getBlogMainECOnline(blog.bloguser.id);
				control.getBlogMainECRate(blog.blogid );
			}
			div.style.display = 'block';
		}
	}
	this.getMainBlogEditorChoiceRate = function(request) {
		var xml = request.responseXML;
		if(xml!=null) {  
			blog = self.parser.getPhotoEditorChoiceRate(xml);
			//เรตติ้ง
			var frame = document.getElementById("rating_blog_ec");
			if(frame!=null) {
				var text = "";
				var a =  self.countRating(blog.photorating,blog.photoratingcount);
				for(var j=1;j<=5;j++){
					if(j<=a){
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
					}else if(a-j>-1 && a-j<0){
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
					}else{
						text = text +'<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
					}
				}
				frame.innerHTML = text;
			}
		}
	}
	this.getMainBlogEditorChoiceOnline = function(request) {
		var xml = request.responseXML;
		//alert(xml);
		if(xml!=null ) {  
			user = self.parser.getPhotoEditorChoiceOnline(xml);
			var div = document.getElementById('blog_box_ec');
			var template_str = div.innerHTML;
				//Display photo info
			var image_online=(user.online !="false")?"<img src=\"http://www.truelife.com/images/mini/icon/ico_on_user.gif\">":"<img src=\"http://www.truelife.com/images/mini/icon/ico_off_user.gif\">";
			template_str = template_str.replace("{blog_online}",image_online);		
			div.innerHTML = template_str;
		}
	}
	this.countRating = function(rate,count){
		var star = 0;
		if(count!=0){
			//alert(rate+"/"+count+(rate/count));
			star = (rate/count);
		}
		return star;
	}
	
	this.getSnowPhoto = function(reqPhoto){		
		var xmlPhoto = reqPhoto.responseXML;
		var resultPhoto = self.parser.getResult(xmlPhoto);
		if (resultPhoto!=null && resultPhoto.code == '200') {
			var objHashPhoto = self.parser.getPhoto2(xmlPhoto);
			if (objHashPhoto.size()>0) {
			
				//{photo_rating}{miniHome}{username}/photo/{album_id}-{photo_id}
				var photo_html = new Array(6);
				photo_html[0] = snow_photo_table_t;
				photo_html[1] = snow_photo_table_t;
				photo_html[2] = snow_photo_table_t;
				photo_html[3] = snow_photo_table_t;
				photo_html[4] = snow_photo_table_t;
				photo_html[5] = snow_photo_table_t;				
				
				length_value = 10;			
				
				for(var i=0;i<snow_photo_id.length;i++){					
					obj = objHashPhoto.get(snow_photo_id[i]);
					dname = obj.displayname;
					dname_arr = dname.split(';');
					if(dname_arr.length > length_value){
						dname = '';
						for(var k=0;k<length_value;k++){
							dname += dname_arr[k]+';';
						}						
					}else if(dname.length > length_value){
						dname = dname.substring(0,length_value)+'..';
					}
					
					photo_name = obj.name;
					photo_name_arr = photo_name.split(';');
					if(photo_name_arr.length > length_value){
						photo_name = '';
						for(var x=0;x<length_value;x++){
							photo_name += photo_name_arr[x]+';';
						}
					}else if(photo_name.length > length_value){
						photo_name = photo_name.substring(0,length_value)+'..';
					}
					row_tem = snow_photo_cal;
					row_tem = row_tem.replace("{photo_name}",photo_name);					
					row_tem = row_tem.replace(/{username}/g, obj.username);	
					row_tem = row_tem.replace("{displayname}",dname);					
					row_tem = row_tem.replace(/{album_id}/g, obj.album_id);
					row_tem = row_tem.replace(/{photo_id}/g, obj.id);
					row_tem = row_tem.replace("{photo_src}", obj.thumbnail);				
					row_tem = row_tem.replace("{miniHome}", "javascript:openHomeHomeGo("+obj.user_id+",'photo');");					
					
					row_tem = row_tem.replace("{photo_rating}", '{photo_rating_'+snow_photo_id[i]+'}');	
					
					
					if(i < 4){
						photo_html[0] += row_tem
					}else if(i == 4){
						photo_html[0] += row_tem+snow_photo_table_f;						
					}else if(i < 9){
						photo_html[1] += row_tem;
					}else if(i == 9){
						photo_html[1] += row_tem+snow_photo_table_f;				
					}else if(i < 14){
						photo_html[2] += row_tem;
					}else if(i == 14){
						photo_html[2] += row_tem+snow_photo_table_f;						
					}else if(i < 19){						
						photo_html[3] += row_tem;
					}else if(i == 19){	
						photo_html[3] += row_tem+snow_photo_table_f;					
					}else if(i < 24){						
						photo_html[4] += row_tem;
					}else if(i == 24){
						photo_html[4] += row_tem+snow_photo_table_f;					
					}else if(i < 29){						
						photo_html[5] += row_tem;
					}else if(i == 29){						
						photo_html[5] += row_tem+snow_photo_table_f;
					}												
				}
				
				$("snow_photo1").innerHTML = photo_html[0];
				$("snow_photo2").innerHTML = photo_html[1];
				$("snow_photo3").innerHTML = photo_html[2];
				$("snow_photo4").innerHTML = photo_html[3];
				$("snow_photo5").innerHTML = photo_html[4];
				$("snow_photo6").innerHTML = photo_html[5];				
				
				//var control = new Control();
				//for(var i=0;i<=4;i++){			
				//	control.getSnowPhotoRating(snow_photo_id[i],snow_photo1);	
				//}	
			
				self.setSnowRating(5,'snow_photo1');
				self.setSnowRating(10,'snow_photo2');
				self.setSnowRating(15,'snow_photo3');
				self.setSnowRating(20,'snow_photo4');
				self.setSnowRating(25,'snow_photo5');
				self.setSnowRating(30,'snow_photo6');				
				setSnowPhotoShow();	
				
			}else{
				$("snow_photo1").innerHTML = 'ไม่สามารถแสดงรูปได้ในขณะนี้';
				$("snow_loading").style.display = "none";	
				$("snow_photo1").style.display = "";
				
			}
		
		}else{
			$("snow_photo1").innerHTML = 'ไม่สามารถแสดงรูปได้ในขณะนี้';
			$("snow_loading").style.display = "none";	
			$("snow_photo1").style.display = "";
		}
	}	
	
	this.setSnowRating = function(count,re_id_name){		
		var control = new Control();
		for(var i=count-5;i<count;i++){			
			control.getSnowPhotoRating(snow_photo_id[i],re_id_name);	
		}				
		//setSnowPhotoShow();					
	}
	

	this.snowPhotoRating = function(reqRat,re_id_name){	
		var xmlRat = reqRat.responseXML;	
		var resultRat = self.parser.getResultcode(xmlRat);		
				
		if (resultRat!=null && resultRat.code == '200') {			
			var rat_obj = self.parser.getRatingByItemID(xmlRat);
			photo_id = rat_obj.id;
			rating = rat_obj.ratingvalue;			
			rating_count = rat_obj.ratingcount;
			
			star = self.countRating(rating,rating_count);
				
			rating_html = "";	
			for (var j=1; j<=5; j++){
				if (j<=star){					
					rating_html += '<img src="http://www.truelife.com/images/index/mm/stg1.gif" width="10" height="9" class="rating_img">';
				}else if (star-j>-1 && star-j<0){
					rating_html += '<img src="http://www.truelife.com/images/index/mm/stg3.gif" width="10" height="9" class="rating_img">';
				}else{
					rating_html += '<img src="http://www.truelife.com/images/index/mm/stg2.gif" width="10" height="9" class="rating_img">';
				}
			}
			$(re_id_name).innerHTML = $(re_id_name).innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			/*
			$("snow_photo1").innerHTML = $("snow_photo1").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			$("snow_photo2").innerHTML = $("snow_photo2").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			$("snow_photo3").innerHTML = $("snow_photo3").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			$("snow_photo4").innerHTML = $("snow_photo4").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			$("snow_photo5").innerHTML = $("snow_photo5").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);
			$("snow_photo6").innerHTML = $("snow_photo6").innerHTML.replace('{photo_rating_'+photo_id+'}',rating_html);		
			*/
		}				
		
	};

var snow_photo_id = new Array('1451626','1632636','1661549','1640161','1630715',
							  '1522398','1639325','1637824','1656184','1660760',
							  '1518825','1646798','1572106','1646631','1642455',
							  '1642646','1660902','1658989','1640466','1660843',
							  '1660842','1660845','1660846','1581472','1627430',
							  '1639182','1660827','1660828','1645731','1631419');

var snow_photo_table_t = '<table border="0" width="100%" cellspacing="0" cellpadding="0" ><tr>';
var snow_photo_table_f = '</tr></table>';
var snow_photo_cal = '<td width="20%"><div align="center">\
						<table width="98" border="0" align="center" cellpadding="0" cellspacing="0">\
							<tr><td height="36" valign="bottom">\
									<div align="center">\
										<a href="http://minihome.truelife.com/{username}/photo/{album_id}-{photo_id}" target="_blank">\
										<img src="{photo_src}" width="98" height="67"  border="0">\
									</a></div>\
							</td></tr>\
							<tr><td height="15" class="grlink">\
									<font color="#000000"><span class="btxt">\
										<img src="images_snow/ar_bl.gif" width="3" height="5">\
										</span> \
										<a href="http://minihome.truelife.com/{username}/photo/{album_id}-{photo_id}" target="_blank">{photo_name}</a>\
									</font>\
							</td></tr>\
							<tr><td height="15" class="grlink">\
								<font color="#000000"><a href="{miniHome}">By: {displayname}</a></font>\
							</td></tr>\
							<tr><td height="20" align="center" class="grlink">{photo_rating}</td>\
						</tr></table>\
					</div></td>';
					
	

}//end Rander()

var index_snow_show = 0;	
function setSnowPhotoShow(){	
		if(index_snow_show > 6 ){
			index_snow_show = 1;
		}		
		if(index_snow_show == 1){
			$("snow_loading").style.display = "none";
			$("snow_photo6").style.display = "none";
			$("snow_photo1").style.display = "";			
		}else if(index_snow_show == 2){
			$("snow_photo1").style.display = "none";
			$("snow_photo2").style.display = "";
		}else if(index_snow_show == 3){			
			$("snow_photo2").style.display = "none";
			$("snow_photo3").style.display = "";
		}else if(index_snow_show == 4){			
			$("snow_photo3").style.display = "none";
			$("snow_photo4").style.display = "";
		}else if(index_snow_show == 5){			
			$("snow_photo4").style.display = "none";
			$("snow_photo5").style.display = "";			
		}else if(index_snow_show == 6){		
			$("snow_photo5").style.display = "none";
			$("snow_photo6").style.display = "";
		}
		
		if(index_snow_show > 0){
			setTimeout("setSnowPhotoShow()",5000);
		}else{
			setTimeout("setSnowPhotoShow()",2000);
		}
		
			
		++index_snow_show;
}

