function Specialty(){
	
}
Specialty.prototype.load = function(){
	var fncSuc = XHR.Delegate(this,this.loadSuc);
	var param = {act:"listProduct",page:1,n:50,order:0,showinhome:1};
	new XHR("post",fncSuc).send($PN+"/Proc",param);
}

Specialty.prototype.loadSuc = function(r){
	var xml = new XML(r);
	if (xml.value){
		var pro = xml.get("product");
		var html="";
		var htmlline = "";
		for(var i=0; i < pro.length; i=i+2){
			htmlline+="<td width='50%' valign='top' class='commonborder_product'>"+this.gen1Block(pro[i]);+"</td>";
			htmlline+="<td width='50%' valign='top' class='commonborder_product'>"+this.gen1Block(pro[i+1])+"</td>";
			htmlline="<tr>"+htmlline+"</tr>";
			html +=htmlline;
			htmlline = "";
		}
		if(html==""){
			html = "";
		}else{
			html = "<table width='100%' cellpadding='0' cellspacing='2'>"+html+"</table>";
			var text = "Xem tất cả";
			if($LANG=="en")
				text = "View all"
			html +="<div align='right' style='margin-top:5px'><a class='viewall' href='?act=productlist&lang="+$LANG+"&id=-1'>"+text+" &raquo;</a></div>";
			this.loadTitle();
		}	
		$("specialdiv").innerHTML  = html;
		
	} else {
		alert(xml.msg);
	}
}
Specialty.prototype.gen1Block=function(pro){
	try{
		var html="";
		var template = $("specialty_template").innerHTML;
		var title;
		id = pro.getAttribute("id");
		
		var file = (pro.getAttribute("filepic")=="") ? "../../images/noimg.gif" : $LIB_PATH+getThumbPath(pro.getAttribute("filepic"))
		
		var pic = 	"";
		var price = "";	
		var text = "Giá: ";
		if($LANG=="en")
			text = "Price: "
		if(pro.getAttribute("price")!="")
			price = "<div>"+text+"<span class=\"price\">"+pro.getAttribute("price")+"</span></div>";
		
		
		title = "<a class=\"titlepro\" href=\"?act=productdetail&id="+id+"&lang="+$LANG+"\">"+
					pro.getAttribute("title")+
				"</a>";
		pic = "<a href=\"?act=productdetail&id="+id+"&lang="+$LANG+"\"><img class=\"commonborder propichome\" align=\"left\" style=\"margin-right:7px\" src=\""+file+"\"/></a>";
		var detail = pro.getAttribute("description");

		html=template.replace("$SP_TITLE",title).replace("$SP_IMG",pic).replace("$SP_CONTENT",detail).replace("$SP_PRICE",price);
		return html;
	}catch(e){
		return "";
	}
}
Specialty.prototype.loadTitle = function(){
	var fncSuc = XHR.Delegate(this,this.loadTitleSuc);
	var param = {act:"getSpecialty"};
	new XHR("post",fncSuc).send($PN+"/Proc",param);
}

Specialty.prototype.loadTitleSuc = function(r){
	var xml = new XML(r);
	if (xml.value){
		var spec = xml.get("specialty")[0];
		var spec = xml.get("specialty")[0];
		$("title_specialty").innerHTML = "<span style='cursor:pointer' onclick='window.location=\"?act=productlist&id=-1\"'>"
					+spec.getAttribute("title")+"</span>";
	}
}

