function SetCookie(strName, oValue)
{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	
	var oDate = new Date(); 
	oDate.setFullYear(oDate.getFullYear() + 100);   

	document.cookie =   strName + "=" + escape(oValue.toString())       +
	                    (oDate ? "; expires=" + oDate.toGMTString() : "")          +
	                    (((argc > 3) && (argv[3])) ? "; domain=" + argv[3] : "")  +
	                    (((argc > 4) && (argv[4])) ? "; path=" + argv[4] : "")      +
	                    ((argc > 5) ? (argv[5] ? "; secure" : "") : "");
}

function GetCookie(strName)
{
    if((typeof(strName) == "string") && strName.length)
    {
        var i = 0, j;

        var strFind    = strName + "=";
        var strCookie  = document.cookie;

        do
        {
            j = i + strFind.length;

            if(strCookie.substring(i, j) == strFind)
            {
                var nEnd = strCookie.indexOf(";", j);

                if(nEnd < 0)
                    nEnd = strCookie.length;

                return unescape(strCookie.substring(j, nEnd));
            }
        }
        while(i = strCookie.indexOf(" ", j) + 1);
    }
	
    return null;
}

function DeleteCookie(strName)
{
    document.cookie = strName + "=0; expires=" + (new Date(0)).toGMTString();
}

function vote(voting, answer)
{
	var _2bv = GetCookie('2b_voting_'+voting);
	if (_2bv == null)
	{
		SetCookie('2b_voting_'+voting, answer);
		$("#vt_"+voting).load("adm/modules/mod.voting/ajax.php", {voting:voting, answer:answer, act:'vote'});
	}
}

function revote(voting)
{
	var _2bv = GetCookie('2b_voting_'+voting);
	if (_2bv != null)
	{
		DeleteCookie('2b_voting_'+voting);
		$("#vt_"+voting).load("adm/modules/mod.voting/ajax.php", {voting:voting, answer:_2bv, act:'revote'});
	}
}

function viewResults(id)
{
	$("#vt_"+id).load("adm/modules/mod.voting/ajax.php", {id:id, act:'viewResults'});
}

function viewVoting(id)
{
	$("#vt_"+id).load("adm/modules/mod.voting/ajax.php", {id:id, act:'viewVoting'});
}

function postComment(id, vote)
{
	$("#vt_"+vote).load("adm/modules/mod.voting/ajax.php", {id:id, vote:vote, comment:$("#comment").attr("value"), act:'postComment'});
	$("#comm_div").hide();
}