var methodPost = {methos:"post"};
var methodGet = {methos:"get"};

function voteNews() {
	var vcID = "";
	for(var i=0;i < document.voteFormNews.vcIDN.length;i++) {
		if (document.voteFormNews.vcIDN[i].checked) {
			vcID = document.voteFormNews.vcIDN[i].value;
			break;
		}
	}
	
	if (vcID == "") { alert("กรุณาเลือกตัวเลือกใดตัวเลือกหนึ่ง"); }
	else 
	{
		var pars = "vcID="+vcID;
		var myAjax = new Ajax.Request("XML/ajaxProxy_updateVote.jsp", {method: "post", parameters: pars, onComplete: showResponseNews});  
	}
}

function showResponseNews(originalRequest) {
	var items = null;
	items = originalRequest.responseXML.selectSingleNode("ajax-response/response");
	alert(items.childNodes[1].firstChild.nodeValue);
}

function openComment2(VoteID) 
{
	var windowprops = "directories=no,scrollbars=yes,width=799,height=510,left=200,top=50,resizable=1";
	window.open("http://webboard.truelife.com/comment/voteComment.jsp?voteID="+VoteID,"",windowprops)
}

function openView(guid) 
{
	var windowprops = "directories=no,scrollbars=yes,width=797,height=630,left=200,top=50,resizable=1";
	window.open("http://webboard.truelife.com/newsgroup/gallery.jsp?guid="+guid,"",windowprops)
}

function vote()
{
	var vcID = "";
	for(var i=0;i < document.voteForm.vcID.length;i++) 
	{
		if (document.voteForm.vcID[i].checked) { vcID = document.voteForm.vcID[i].value; break; }
	}
	var urlXML = "XML/ajaxProxy_updateVote.jsp";
	var param = {parameters: "vcID=" + escape(vcID) };
	Object.extend(param, methodPost);
	XSLT.ImportXML(urlXML, param);
	var items = XSLT._lastXML.selectSingleNode("ajax-response/response");
	alert(items.childNodes[1].firstChild.nodeValue);
	for(var i=0;i < items.childNodes[2].childNodes.length;i++)
	{
		if(i != items.childNodes[2].childNodes.length-1)
		{
			var temp = items.childNodes[2].childNodes[i].firstChild.nodeValue;
			var params1 = temp.split("_");
			$("point"+params1[0]).innerHTML =  params1[1];
			$("percent"+params1[0]).innerHTML =  params1[2];
			$("bar"+params1[0]).innerHTML = "<img src=\"http://webboard.truelife.com/images/Vote_bar.gif\" width = '"+(params1[2]*2)+"' height = \"14\">";
		}
		else
		{
			var total = items.childNodes[2].childNodes[i].firstChild.nodeValue;
			var params2 = total.split("_");
			$(""+params2[0]).innerHTML =  params2[1];
		}
	}
}

function sendToFriends()
{
	var path = window.location;
	var windowprops = "directories=no,scrollbars=no,width=480,height=350,left=200,top=50,resizable=1";
	window.open("http://trueworld.truelife.com/newsletter/send2fr/index.jsp?requestpath=" + escape(path),"",windowprops)
}

function fadeUpPix(which2)
{
	theobject = which2;
	highlighting = setInterval("highlightit(theobject)",50);
}
		
function fadeDownPix(which2)
{
	clearInterval(highlighting)
	if(which2.style.MozOpacity) { which2.style.MozOpacity = 0.6; }
	else if(which2.filters) { which2.filters.alpha.opacity=75; }
}

function highlightit(cur2)
{
	if(cur2.style.MozOpacity<1) { cur2.style.MozOpacity = parseFloat(cur2.style.MozOpacity) + 0.1; }
	else if(cur2.filters && cur2.filters.alpha.opacity < 100) { cur2.filters.alpha.opacity += 10; }
	else if(window.highlighting) { clearInterval(highlighting); }
}
