// JavaScript Document
var clubembeded_addto = function(no,clubid) {
	// find the source element
	if(typeof clubembeded == "undefined") clubembeded = document.getElementById("clubembeded");
	var lis = clubembeded.getElementsByTagName("li");
	for(var i=0;i<no && i<lis.length ; i++) var a = lis[i].getElementsByTagName("a")[0];
	var contentType = clubembeded.getElementsByTagName("input")[0].value;
	var contentId = clubembeded.getElementsByTagName("input")[1].value;
	var ctype = clubembeded.getElementsByTagName("input")[2].value;
	var agent;
	var path = "http://www.vcharkarn.com/vclub/";
	switch(contentType.toLowerCase()){
		case "article": case "articles":
			agent = new postman(path+"listarticles.php");
			agent.addParam("cmd","add");
			agent.addParam("clubid",clubid);
			agent.addParam("aid",contentId);
			agent.addParam("ctype",ctype);
			break;
		case "kratoo": case "kratoos":
			agent = new postman(path+"listkratoos.php");
			agent.addParam("cmd","add");
			agent.addParam("clubid",clubid);
			agent.addParam("pid",contentId);
			agent.addParam("ctype",ctype);
			break;
	case "news":
			agent = new postman(path+"listnews.php");
			agent.addParam("cmd","add");
			agent.addParam("clubid",clubid);
			agent.addParam("pid",contentId);
			agent.addParam("ctype",ctype);
			break;			
	case "service": case "services":
			agent = new postman(path+"listservices.php");
			agent.addParam("cmd","add");
			agent.addParam("clubid",clubid);
			agent.addParam("pid",contentId);
			agent.addParam("ctype",ctype);
			break;			
	}
	if(agent) { // agent is properly instantiated
		agent.setLoading(function(loading){
				if(loading) a.className = "loading";
				else 	a.className = "done";
		});
		agent.setResponse(function(text){ a.href = "#"; });
		agent.send();
	}
}