﻿function OpenVoteUrl(url, type, vid)
{
	if (type == 0)
	{
		
		if ((document.all.yourAnswer.value > 0) && (document.all.yourVote.value == vid))
		{
			url = url + "&yourAnswer=" + document.all.yourAnswer.value;
			var coll = document.getElementById("voteSelect" + vid);
			if (coll)
			{
				for (var i=0; i<coll.length; i++)
				{
					coll(i).checked = false;
					coll(i).disabled = true;
				}
			}
			var votePartLink = document.getElementById("votePart" + vid);
			if (votePartLink)
				votePartLink.removeAttribute("href");
			document.all.yourAnswer.value = 0;
			window.open(url,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");	
		}
	}
	else
		window.open(url,"","height=333,width=590,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes");	
}
function GetVoteCookieValue(sParent, sName, sValue)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
// a name/value pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (aCookie[i].lastIndexOf(sName)> -1) 
{
//var aCrumb1 = aCookie[i].split("&");
//for (var k=0; k < aCrumb1.length; k++)
//{
var aCrumb = aCookie[i].split("=");
if (sParent == aCrumb[0])
{ 
if (sName == aCrumb[1])
{
if (aCrumb[2].search(",") > -1)
{
var aCrumb2 = aCrumb[2].split(",");
for (var l=0; l < aCrumb2.length; l++)
{
if (aCrumb2[l] == sValue)
return aCrumb2[l];
}
}
else
{
if (aCrumb[2] == sValue)
return unescape(aCrumb[2]);
}
}

}
//}

}

}
// a cookie with the requested name does not exist
return null;
}
function CheckCookie(vid)
{
var voteId = GetVoteCookieValue("vote","vID",vid);
if (voteId)
{
var coll = document.getElementById("voteSelect" + vid);

if (coll)
{
for (var i=0; i<coll.length; i++)
{
coll(i).disabled = true;
}
}
var votePartLink = document.getElementById("votePart" + vid);
if (votePartLink)
votePartLink.removeAttribute("href");
}
}