function PopupBrandPollResult(myTongID, pollID)
{
	var url = "/poll/poll.do?action=poll_result&myTongID="+ myTongID + "&pollID=" + pollID;
	window.open(url,'','status=yes,width=460,height=472,left=' + (window.screen.availWidth/2 - 180) + ',top=' + (window.screen.availHeight/2 - 211));
	return false;
}
function BrandPollAction(object)
{
	var frm = object;
	if(!frm.examNo.value)
	{
		alert("°ø°¨ÇÏ½Ã´Â ´äº¯À» ¼±ÅÃÇÏ¿© ÁÖ½Ê½Ã¿ä.");
        return false;
    }
	if (_GetCookieValue('GUID'))
	{
		if (_GetCookieValue('SYS_USER_ID'))
		{
			var url = '/poll/poll.do?action=poll_dopoll&myTongID=' + frm.myTongID.value + '&pollID=' + frm.pollID.value + '&examNo=' + frm.examNo.value;
			window.open(url,'','status=yes,width=460,height=480,left=' + (window.screen.availWidth/2 - 180) + ',top=' + (window.screen.availHeight/2 - 211));
			return false;
		}
		else
		{
			PopupJoinTong('&need_mytong=true&need_toss=false&redirect_url=/poll/poll.do?action=poll_dopoll&myTongID=' + frm.myTongID.value + '&pollID=' + frm.pollID.value + '&examNo=' + frm.examNo.value);
			return false;
		}
	}
	else
	{
		PopupLogin('&need_mytong=true&need_toss=false&redirect_url=/poll/poll.do?action=poll_dopoll&myTongID=' + frm.myTongID.value + '&pollID=' + frm.pollID.value + '&examNo=' + frm.examNo.value);
		return false;	
	}	
}	
function viewPoll(httpRequest, args) {
	var xmlDoc = httpRequest.responseXML;
	try {
	var code = xmlDoc.getElementsByTagName('code').item(0).firstChild.nodeValue;
	} catch (e) {
		alert(e);
	}
	if (code == 'success') {
		var pollItem = eval( "(" + xmlDoc.getElementsByTagName('data').item(0).firstChild.nodeValue + ")" ); // JSON POWER
		var div = document.createElement("DIV");
		if(pollItem.length == 4 && pollItem[0].pollItemImage != 0) {
			div.innerHTML = '<form name=pollList'+ args + ' style="margin:0;padding:0;" method="post">'+
							'<dl class="pollTitle">' +
								'<dt style="margin:0;"><strong>Áú¹® . '+ pollItem[0].pollTitle.replace(/\\n/g, '</strong>\n<br/>', '</strong>') + '</dt>' +
							'</dl>'+
							'<ul>' +
								'<li class="imageLeft" style="clear:all;margin:0;width:195px;float:left;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="1" onclick="this.form.examNo.value = this.value;">' + pollItem[0].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[0].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
								'<li class="imageRight" style="margin:0;width:195px;float:right;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="2" onclick="this.form.examNo.value = this.value;">' + pollItem[1].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[1].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
								'<li class="imageLeft" style="clear:all;margin:0;width:195px;float:left;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="3" onclick="this.form.examNo.value = this.value;">' + pollItem[2].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[2].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
								'<li class="imageRight" style="margin:0;width:195px;float:right;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="4" onclick="this.form.examNo.value = this.value;">' + pollItem[3].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[3].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
							'</ul>'+
							'<input type=hidden name=examNo>'+
							'<input type=hidden name=pollID value="' + pollItem[0].pollID + '">'+
							'<input type=hidden name=myTongID value="' + pollItem[0].tongID + '">' +
							'</form>';
		} else if (pollItem.length == 4 && pollItem[0].pollItemImage == 0) {
			div.innerHTML = '<form name=pollList'+ args + ' style="margin:0;padding:0;" method="post" onsubmit="return BrandPollAction();">'+
							'<dl class="pollTitle">' +
								'<dt style="margin:0;"><strong>Áú¹® . '+ pollItem[0].pollTitle.replace(/\\n/g, '</strong>\n<br/>', '</strong>') + '</dt>' +
							'</dl>'+
							'<ul>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="1" onclick="this.form.examNo.value = this.value;">' + pollItem[0].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="2" onclick="this.form.examNo.value = this.value;">' + pollItem[1].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="3" onclick="this.form.examNo.value = this.value;">' + pollItem[2].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="4" onclick="this.form.examNo.value = this.value;">' + pollItem[3].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
							'</ul>'+
							'<input type=hidden name=examNo>'+
							'<input type=hidden name=pollID value="' + pollItem[0].pollID + '">'+
							'<input type=hidden name=myTongID value="' + pollItem[0].tongID + '">' +
							'</form>';
		} else if(pollItem.length == 2 && pollItem[0].pollItemImage != 0) {
			div.innerHTML = '<form name=pollList'+ args + ' style="margin:0;padding:0;" method="post" onsubmit="return BrandPollAction();">'+
							'<dl class="pollTitle">' +
								'<dt style="margin:0;"><strong>Áú¹® . '+ pollItem[0].pollTitle.replace(/\\n/g, '</strong>\n<br/>', '</strong>') + '</dt>' +
							'</dl>'+
							'<ul>' +
								'<li class="imageLeft" style="clear:all;margin:0;width:195px;float:left;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="1" onclick="this.form.examNo.value = this.value;">' + pollItem[0].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[0].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
								'<li class="imageRight" style="margin:0;width:195px;float:right;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="2" onclick="this.form.examNo.value = this.value;">' + pollItem[1].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"><img src='+ getFileServerURL() + pollItem[1].pollItemImage +' width="195" height="100"></dd>' +
									'</dl>' +
								'</li>' +
							'</ul>'+
							'<input type=hidden name=examNo>'+
							'<input type=hidden name=pollID value="' + pollItem[0].pollID + '">'+
							'<input type=hidden name=myTongID value="' + pollItem[0].tongID + '">' +
							'</form>';
		} else {
			div.innerHTML = '<form name=pollList'+ args + ' style="margin:0;padding:0;" method="post" onsubmit="return BrandPollAction();">'+
							'<dl class="pollTitle">' +
								'<dt style="margin:0;"><strong>Áú¹® . '+ pollItem[0].pollTitle.replace(/\\n/g, '</strong>\n<br/>', '</strong>') + '</dt>' +
							'</dl>'+
							'<ul>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="1" onclick="this.form.examNo.value = this.value;">' + pollItem[0].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
								'<li  style="margin:0;width:430px;">'+
									'<dl style="margin:0;">' +
										'<dt style="margin:0;padding:0;"><input type="radio" style="margin:0;padding:0;" name="answer" value="2" onclick="this.form.examNo.value = this.value;">' + pollItem[1].pollItemTitle + '</dt>' +
										'<dd style="margin:0;padding:5px 0;"></dd>' +
									'</dl>' +
								'</li>' +
							'</ul>'+
							'<input type=hidden name=examNo>'+
							'<input type=hidden name=pollID value="' + pollItem[0].pollID + '">'+
							'<input type=hidden name=myTongID value="' + pollItem[0].tongID + '">' +
							'</form>';
		}
		document.getElementById(args).appendChild(div);
		if(pollItem[0].usePoll == "y") {
			var div = document.createElement("div");
			div.className = "actionButtom";
			var vtoday = getToday();
			var vpollEnd = pollItem[0].pollEnd;
			if(vpollEnd >= vtoday ) {
				div.innerHTML = '<input type="image" src="/images/event/admin/btn_vote.gif" style="margin:20px 10px 0 0;" onclick="return BrandPollAction(this.form);"> <input type="image" src="/images/event/admin/btn_result.gif" style="margin:20px 10px 0 0;" onclick="return PopupBrandPollResult('+ pollItem[0].tongID + ','+ pollItem[0].pollID + ');">';
			} else {
				div.innerHTML = '<input type="image" src="/images/event/admin/btn_result.gif" style="margin:20px 10px 0 0;" onclick="return PopupBrandPollResult('+ pollItem[0].tongID + ','+ pollItem[0].pollID + ');">';
			}
			document.getElementById(args).firstChild.firstChild.appendChild(div);
		} else {
			var div = document.createElement("div");
			div.className = "actionButtom";
			div.innerHTML = '<input type="image" src="/images/event/admin/btn_result.gif" style="margin:10px;" onclick="return PopupBrandPollResult('+ pollItem[0].tongID + ','+ pollItem[0].pollID + ');">';
			document.getElementById(args).firstChild.firstChild.appendChild(div);
		}
		document.getElementById(args).style.display = "block";	
		
	} 
}
