function validate(theform)
{
	if (theform.comment.value == "")
	{
		alert("請填寫評論");
		return false;
	}

	if (theform.comment.value.length > 255)
	{
		alert("評論不能超過255個字節，請縮短");
		return false;
	}
}

function confrimAction(link){
	if (confirm("你講真架？真係delete? "))
    {
		document.location=link;
      return true;
    }
	
    return false;
}
function inlinePlayback(orgImage, paintid, pSize, component){
	
	var xPos = pSize.indexOf('x');
	var pWidth ="300";
	var pHeight="300";
	
	if(xPos>=0){
		pWidth = pSize.substring(0,xPos);
		pHeight = pSize.substring(xPos+1,pSize.length);
	}
	
	document.getElementById(component).innerHTML =
		"<table border='0' cellspacing='0' cellpadding='0' width='"+ (parseInt(pWidth)*2)+"'><tr valign='top'><td><img src=\"painter/file/"+orgImage+".jpg\"></td><td>"+
		"<applet " +
		"name=\"pch\" " +
		"code=\"pch2.PCHViewer.class\" " +
		"codebase=\"./\"; " +
		"archive=\"painter/PCHViewer.jar\" " +
		"width=\""+pWidth+"\" " + 
		"height=\""+(parseInt(pHeight)+26)+"\" " +
		"> " +
		"<param name=\"speed\" value=\"1\"> "+
		"<param name=\"pch_file\" value=\"painter/file/"+orgImage+".spch\"> " +
		"<param name=\"buffer_progress\" value=\"false\"> " +
		"<param name=\"buffer_canvas\" value=\"false\"> " +
		"<param name=\"res.zip\" value=\"painter/res/res.zip\"> " +
		"<param name=\"tt.zip\" value=\"painter/res/tt.zip\" " +
		"<param name=\"layer_count\" value=\"3\"> " +
		"<param name=\"layer_max\" value=\"8\"> " +
		"<param name=\"layer_last\" value=\"2\"> " +
		"<param name=\"image_width\" value=\""+pWidth+"\"> "+
		"<param name=\"image_height\" value=\""+pHeight+"\"> "+
		"<param name=\"quality\" value=\"1\"> " +
		"<param name=\"tt_size\" value=\"31\"> "+
		"</applet></td></table> ";
	
	return true;
}
function inlineHistory(orgImage, paintid, pSize, component){
	
	var genPage="<img src=\"painter/file/"+orgImage+".jpg\">";
	var checkResume = orgImage.indexOf("a");
	
	
	if(checkResume>=0 ){
		var historyCount = parseInt(orgImage.substring(checkResume+1,orgImage.length));
		var header=orgImage.substring(0,checkResume+1);
		
		for( var i=historyCount;--i>=0;){
			
			genPage += "<br/>歷史"+(i+1)+"<br/><img src=\"painter/file/"+(i==0?header.substring(0,header.length-1):header+i)+".jpg\">"
		}
		//confirm("extract point " + orgImage.substring(checkResume+1,orgImage.length));
	}else{
		
		return false;
	}
	
	document.getElementById(component).innerHTML =genPage;
	return true;
}
