//===========================================================================================================//
//                                                                                                           //
// (C) Hellonet 2002                                                                                         //
//                                                                                                           //
//===========================================================================================================//

//if( self == top )
//{
//	location = "easyportal.asp?" + self.location;
//}

//var IdSession

function init()
{


}

function DisplayNotizia(IdCanale,IdNotizia)
{
	
	var newLoc = "hpm01.asp?CgiAction=Display&IdCanale="+IdCanale+"&IdNotizia="+IdNotizia;	
	location.href=newLoc;
}

function GoToBookMark(IdCanale,bk)
{

	var ArrHref = new Array();

//	var newLoc = location.href + bk;
	var newLoc = location.href;
ArrHref = newLoc.split('#');
newLoc = ArrHref[0] + bk;
	location.href = newLoc;
}

function Poll_setCookie(name, value, expires, path, domain, secure) 
{
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
     document.cookie = curCookie;
}

function Poll_getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function Poll_Votazione(Chiave, Data, Univoco){
if (Univoco=='SI'){
			if (Chiave==Poll_getCookie('HnPoll')){

if (screen) {
	y = (screen.availHeight - 150)/2;
	x = (screen.availWidth - 260)/2;
	}
    var IdCanale=document.forms['Poll_FrmAdd'].elements['IdCanale'].value;
    var IdSondaggio=document.forms['Poll_FrmAdd'].elements['IdSondaggio'].value;
    window.open('hpmpoll00.asp?IdSondaggio='+IdSondaggio+'&IdCanale='+IdCanale+'&CgiAction=Avviso','Info','menubar=no, scrollbars=yes, width=260,height=150,screenX='+x+',screenY='+y+',top='+y+',left='+x);
				return false;
				}else{
	            return true;
                } 
			}
if (Univoco=='NO'){
			if ((Chiave==Poll_getCookie('HnPoll')) && (Data==Poll_getCookie('HnData'))){
		
if (screen) {
	y = (screen.availHeight - 150)/2;
	x = (screen.availWidth - 260)/2;
	}
    var IdCanale=document.forms['Poll_FrmAdd'].elements['IdCanale'].value;
    var IdSondaggio=document.forms['Poll_FrmAdd'].elements['IdSondaggio'].value;
    window.open('hpmpoll00.asp?IdSondaggio='+IdSondaggio+'&IdCanale='+IdCanale+'&CgiAction=Avviso','Info','menubar=no, scrollbars=yes, width=260,height=150,screenX='+x+',screenY='+y+',top='+y+',left='+x);
				return false;
				}else{
                return true; 
                }
		}
}

function Poll_Risultati(IdSondaggio)
{
if (screen) {
    y = (screen.availHeight - 230)/2;
    x = (screen.availWidth - 450)/2;
    }
    var IdCanale=document.forms['Poll_FrmAdd'].elements['IdCanale'].value;
    window.open('hpmpoll00.asp?IdSondaggio='+IdSondaggio+'&IdCanale='+IdCanale+'&CgiAction=Dsp','Risultati','menubar=no, scrollbars=auto, width=400,height=300,screenX='+x+',screenY='+y+',top='+y+',left='+x);
}

function Poll_CallVota(Chiave, Data, Univoco)
{

	var partCount = document.forms['Poll_FrmAdd'].elements.length;
	var oFrm =document.forms['Poll_FrmAdd'].elements
	for (nIndex = 0; nIndex < partCount; nIndex++)
	{
		if (oFrm[nIndex].name=="Voto")
			{
			if (oFrm[nIndex].type=="radio")
				{
				if (oFrm[nIndex].checked)
					{
					var Voto= escape(oFrm[nIndex].value);
					}
				}
			if (oFrm[nIndex].type=="select-one")
				{
					var Voto = oFrm[nIndex].options[oFrm[nIndex].selectedIndex].value;					
				}
			}
	}

	if(Voto!=undefined)
	{

		if (Poll_Votazione(Chiave, Data, Univoco)==true)
		{
		   	if (Univoco=="SI")
	  		{
		       	Poll_SetCookieU(Chiave);
	      	}
			else
			{
		       	Poll_SetCookieN(Chiave,Data);
	   		}
	
			var urlpoll = 'hpmpoll00.asp?CgiAction=Add';
			urlpoll += '&IdSondaggio=' + document.forms['Poll_FrmAdd'].elements['IdSondaggio'].value;
			urlpoll += '&IdCanale=' + document.forms['Poll_FrmAdd'].elements['IdCanale'].value;
			urlpoll += '&Voto=' + Voto;
		    var y = (screen.availHeight - 230)/2;
		    var x = (screen.availWidth - 450)/2;
			urlpoll += '&screenX=' + x;
			urlpoll += '&screenY=' + y;
			window.open(urlpoll,'Votazione','menubar=no, scrollbars=yes, width=400,height=300 ,screenX='+x+',screenY='+y+',top='+y+',left='+x);
		}
	}
}

function Poll_SetCookieU(Chiave){
	var expires = new Date('01/01/2010');
	Poll_setCookie('HnPoll',Chiave,expires)
}

function Poll_SetCookieN(Chiave,Data){
	var expires = new Date('01/01/2010');
	Poll_setCookie('HnPoll',Chiave,expires)
	Poll_setCookie('HnData',Data,expires)
}

//===========================================================================================================//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null)
{ v=args[i+2];
    if (obj.style) { obj=obj.style;
v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
