function getCookie(cn) {
  if(document.cookie) {
    var index = document.cookie.indexOf(cn);
    if (index != -1) {
      var countbegin = (document.cookie.indexOf("=", index)+1);
      var countend = document.cookie.indexOf(";", index);
      if (countend == -1) {
        countend = document.cookie.length;
      }
      return document.cookie.substring(countbegin, countend);
    }
  }
  return 0;
}
function openKeywordWindow(urlString, windowSize)
{
var pathnameTmp = (window.location.pathname);
var pathname = pathnameTmp.toLowerCase();
if (navigator.appVersion.indexOf('X11') != -1)  
	{
		window.open(pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+urlString,"",'status=no,resizable=yes,scrollbars=no,screenX=100,screenY=100,'+windowSize);
	} else 
	{
	if (navigator.appName =='Netscape') 
			{
			window.open(pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+urlString,"",'status=no,resizable=yes,scrollbars=no,screenX=120,screenY=100,'+windowSize);
			}
			 else
			 {
				window.open(pathname.substring(0,(pathname.lastIndexOf('.nsf')+5))+urlString,"",'status=no,resizable=yes,scrollbars=no,top=120,left=100,'+windowSize);
			}
	}
}
function openTO()
	{
	var h=document.forms[0].Inquiry.length;
	var hplus=h*104+50;
	var iID = document.forms[0].InquiryID.value;	
	var urlString = "InquiryResult?OpenForm&ID="+iID;
	var windowSize = "width=400,height="+ String(hplus) +'"';
	openKeywordWindow(urlString,  windowSize);
	}
function inq(id)
{
	var x="";
	var i=0;
	var k=document.forms[0].Inquiry.length;
	var existRK77ID=getCookie("RK77ID").toString();
	var idIndex=existRK77ID.indexOf(id);
//	alert("idIndex="+idIndex);
	for (i=0;i<k;i++)
		{
		if (document.forms[0].Inquiry[i].checked=="1")
			{
			x=document.forms[0].Inquiry[i].value;
			document.cookie=id+"="+String(x)+";";
			document.cookie="RK77Temp"+"="+id+";";
			if (idIndex == -1) {
				document.cookie="RK77ID"+"="+existRK77ID+"^"+id+";";
				}
			}
		}
}
function Callinq()
{
inq(document.forms[0].InquiryID.value);
// alert(getCookie("RK77ID"));
// alert(getCookie("RK77Temp"));
}
function makeInquiry()
{
var existRK77ID=getCookie("RK77ID").toString();
var iID = document.forms[0].InquiryID.value;	
var idIndex=existRK77ID.indexOf(iID);
var h=document.forms[0].Answers.value;
var hplus=(h*30)+50;
if (iID!="" && iID!="-no-" && iID!="Common"  )
	{
	if  (idIndex!=-1 )
		{
		document.write('<table class="InquiryTableEnd" width="203" border="0"><tr><td>');
		document.write("Dziękujemy za udział w głosowaniu.<br>");
//		document.write("<a href='javascript:void(0);' onClick='openTO();'><b>Wyniki</b></a>");
		var src='/home.nsf/InquiryResult?OpenForm&ID='+iID
		document.write('<iframe class="if" scrolling="no" src=' + src +' frameborder="0" width="195" height=' + hplus + '>.</iframe>');
		}else
			{
			document.write('<table class="InquiryTableStart" width="203" border="0"><tr><td>');
			document.write(ankieta);
		
			}
	}
}
function HideVote(){
var existRK77ID=getCookie("RK77ID").toString();
var iID = document.forms[0].InquiryID.value;
var idIndex=existRK77ID.indexOf(iID);
if (iID!="" && iID!="-no-" && iID!="Common") {
		document.write('</td></tr></table>');
	if  (idIndex!=-1)
		{
		
		document.forms[0].vote.className="voteFalse";
		}
	}else
		{
		document.forms[0].vote.className="voteFalse";
		document.write("");
		}
}
