function hidediv(divid)
{
var theObject = document.getElementById(divid);
	theObject.style.display = "none";
		theObject.style.visibility = "hidden";
}
function showdiv(divid)
{
	var theObject = document.getElementById(divid);
	theObject.style.display = "block";
	theObject.style.visibility = "visible";
}

function changeclass(divid,cln)
{		
	var theObject = document.getElementById(divid);
	theObject.className = cln;
}
function showandhide(showid, sumdivid, prefix)
{
	var i=0;
	for (i=0;i<sumdivid;i++)
	{
		if (i == showid){
			showdiv(prefix + i + "");
			changeclass(prefix + i + "_li","on");
		}else{
			hidediv(prefix + i + "");
			changeclass(prefix + i + "_li","");
		}
	}
}


function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	 else if (obj.x)
	{
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
		curtop += obj.offsetTop
		obj = obj.offsetParent;
		}
	} 
	else if (obj.y)
	{
		curtop += obj.y;
	}
return curtop;
}
/**
*	Ham lay danh sach thuoc tinh cua 1 category
* @param url action duoc goi
*	@param catid category_id
*	@param rid ID doi tuong nhan noi dung tra ve
*/

function getrss(baseurl, catid, rid)
{
	$(rid).innerHTML = 'Đang tải';
	var myAjax = new Ajax.Request(baseurl,
	{method: 'post', parameters: {catid: catid}, 
	onComplete: function(transport)
	{
		$(rid).innerHTML = transport.responseText;	
	}	
	});
}

function getintro(baseurl, rid)
{
	$(rid).innerHTML = 'Đang tải';
	var myAjax = new Ajax.Request(baseurl,
	{method: 'get', 
	onComplete: function(transport)
	{
		$(rid).innerHTML = transport.responseText;	
	}	
	});
}

function xemnhieunhat(baseurl, rid)
{
	$(rid).innerHTML = 'Đang tải';
	var myAjax = new Ajax.Request(baseurl,
	{method: 'get', //parameters: {catid: catid}, 
	onComplete: function(transport)
	{
		$(rid).innerHTML = transport.responseText;	
	}	
	});
}

function newAttributeValue(e, baseurl, attrid, rid)
{
		
		if($(rid).getStyle('visibility')!= 'visible')
		{
			
			var theObject = document.getElementById(rid);
			theObject.style.display = "block";
			theObject.style.visibility = "visible";
			theObject.style.height = '100px';
			theObject.style.width = '300px';
			var posx = 0;
			var posy = 0;
			posx =  e.clientX + 10;// - findPosX($('catattributelist')) ;
			posy =  e.clientY + 10;// - findPosY($('catattributelist')) ;
			if(posx + 280 > window.innerWidth) posx -=310;
			if(posy + 100 > window.innerHeight) posy -=110;
			theObject.style.left = posx + "px";
			theObject.style.top = posy + "px";
			theObject.innerHTML = 'Đang tải';
			
			var myAjax = new Ajax.Request(baseurl+'/ajax/newattributevalue',
				{
				method: 'get', parameters: {attrid: attrid},
				onComplete: function(transport)
				{
					theObject.innerHTML = transport.responseText;	
				}	
				});
				
			}
			else
			{
				
				hidediv(rid);
			}
}
