function GetCookie(name){
	var arg=name+"=";var alen=arg.length;var clen=document.cookie.length;var i=0;
	while(i<clen){
		var j=i+alen;
		if(document.cookie.substring(i,j)==arg)
			return getCookieVal(j);
		i=document.cookie.indexOf(" ",i)+1;
		if(i==0)
			break;
		}
	return null;
}

function SetCookie(name,value,expires,path,domain,secure){
	var today = new Date();
	var expires_date = new Date();
	if (expires==null || expires==0) expires=1;
	expires_date.setTime(today.getTime() + 3600000*24*expires);
        document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires_date.toGMTString():"")+((path)?"; path="+path:"")+((domain)?";domain="+domain:"")+((secure)?"; secure":"");
}

function DeleteCookie(name,path,domain){
	if(GetCookie(name)){
document.cookie=name+"="+((path)?"; path="+path:"")+((domain)?"; domain="+domain:"")+"; expires=Tue, 01-Jan-2002 00:00:01 GMT";
	}
}
function getCookieVal(offset){
	var endstr=document.cookie.indexOf(";",offset);
	if(endstr==-1)endstr=document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
}

// *****************
//var TIP;
//document.write("<sc"+"ript src=\"http:/"+"/procedure.tiscali.it/main/\"></sc"+"ript>");
document.write("<sc"+"ript src=\"http:/"+"/www.tiscali.it/js/v1.1/lib.html\"></sc"+"ript>");

//******** CT *******
var CLASS = GetCookie("CLASS");
sz        = 2000; 
sImg      = new Image;

function spCK(){
if(CLASS == null){
    s1 = new Date();
    sImg.src="http://img.tiscali.it/etc/pxw2k.bmp?"+Math.random(); 
    if(navigator.userAgent.indexOf("Fire")==-1){
      setTimeout("getSp()",1);         
    }else{
      sImg.onload = getSp;
    }
 }
}

function getSp(){
   if(sImg.complete){
     s2 = new Date();
     CLASS = s2.getTime()-s1.getTime();    
     if (CLASS!=0){
       CLASS=Math.floor(8*sz/CLASS);
       CLASS=(CLASS<=36?1:2);
     }
WH:     while(1){
if(TIP.search("^(195.130|213.205|217.133|62.1|82.(82|84|85|222))")!=-1){TIP="1";break WH;}
if(TIP.search("^(151|193|212|213.140|217)")!=-1){TIP="A";break WH;}
if(TIP.search("^(80|81|82|83|84|85|213.45)")!=-1){TIP="B";break WH;}
TIP = "Z"; break WH;}
SetCookie("CLASS",TIP+CLASS,2,"/","tiscali.it","");
}else{
  setTimeout("getSp()",1);
  }
}

var oldonload = window.onload;
if (typeof window.onload != 'function') {
  window.onload = spCK;
}else {
  window.onload = function() {
   oldonload();
   spCK();
 }
}
// *****************

function gatway(col,typ)
{
document.forms[0].collection.value=col;
document.forms[0].tiscalitype.value=typ;
document.forms[0].maxCount.value=(typ=="image")?'4':'';
}
function ts_gourl(url){
	top.location.href=url;
}

