//function doInterstitial(newURL,parBanner1,parBanner2,identifiers) 
function doInterstitial(newURL,parBanner1,parBanner2,identifiers,labeledOnly) 
{    
    if(!labeledOnly)
        labeledOnly = 0;    
    arrayIdentifiers = identifiers.split(" ");
	identifier = "";
    statusCookie = navigator.cookieEnabled;
    if(!statusCookie)
	   return;
	
    for(i=0;i<arrayIdentifiers.length;i++)
    {
    	returnValue = getCookieData('interstitial-'+arrayIdentifiers[i]);
    	if(returnValue)	
    	{
    		continue;
    	}
    	identifier = arrayIdentifiers[i];
    	break;
    }
    if(!identifier)
        return;
    //alert(identifier);
	//alert("in");
  	var links = document.getElementsByTagName('a');
  	for( var i=0; i<links.length; i++) 
	{
		var oldURL = links[i].href;
		if(checkUrl(oldURL) && (!labeledOnly||links[i].className=='interstitial'))
		{
		  oldURL = oldURL.replace(/'/g,"---APOS---");
		  oldURL = oldURL.replace(/&/g,"---AND---"); 
		  oldURL = oldURL.replace(/#/g,"---CANC---"); 	
		  //alert(oldUrl); 
		  //links[i].onclick = goIpFrom;
		  //links[i].href = newURL + '?parBanner1='+parBanner1+'&parBanner2='+parBanner2+'&destination=' + oldURL+'&identifier='+identifier;
		  links[i].href = newURL + '?destination=' + oldURL+'&identifier='+identifier;
		}
	}
}

function goIpFrom(e)
{
	if(!e)
	{
		var e = window.event;
	}
	targetElement = e.target || e.srcElement;
	oldUrl = targetElement.href;
       oldURL = oldURL.replace(/'/g,"---APOS---");
	oldUrl = oldUrl.replace(/&/g,"---AND---");
	oldUrl = oldUrl.replace(/#/g,"---CANC---");
	//alert(oldUrl);
	targetElement.href = 'script/ipfrommr.php?destination='+oldUrl;
}

function getCookieData(labelName) 
{
	//alert(labelName);
    var labelLen = labelName.length;
    var cookieData = document.cookie;
    var cLen = cookieData.length;
    var i = 0;
    var cEnd;
    while (i < cLen) 
    {
        var j = i + labelLen;
        if (cookieData.substring(i,j) == labelName) 
        {
            cEnd = cookieData.indexOf(";",j);
            if (cEnd == -1) {
                    cEnd = cookieData.length;
            }
            return unescape(cookieData.substring(j+1, cEnd));
        }
        i++;
    }
    return "";
}

function checkUrl(url)
{
	if(url.search("javascript") != -1)
	{
		return false; 
	}
	if(url.search("mailto") != -1)
	{
		return false;
	}
	if(url=="#")
	{
		return false;
	}
	if(url.search("media") != -1)
	{
		return false; 
	}

	if(url.search("overture") != -1)
	{
		return false; 
	}
	
	if(url.search("suedtirol") != -1)
	{
		return false; 
	}
		return true;
}

function printFlash(urlFlash,destination)
{
	destination=destination.replace('---APOS---','%27');
	destination=destination.replace('---AND---','%26');
	destination=destination.replace('---CANC---','%23');
	var larghezza = screen.width;
	var altezza = screen.height;
	if(larghezza==800||altezza==600) 
	{
		larghezzaFlash = 730;
		altezzaFlash = 430;
		nomeFlash = "800dsl";
	} 
	else if(screen.width==1024||screen.height==768) 
	{ 
		larghezzaFlash = 995;
		altezzaFlash = 570;
		nomeFlash = "1024dsl";
	} 
	else if(screen.width==1280||screen.height==800) 
	{ 
		larghezzaFlash = 1260;
		altezzaFlash = 595;
		nomeFlash = "1280dsl";
	} 
	else 
	{ 
		larghezzaFlash = 995;
		altezzaFlash = 580;
		nomeFlash = "1024dsl";
	}
	nomeFlash += ".swf";
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+larghezzaFlash+'" height="'+altezzaFlash+'">');
	document.write('<param name="movie" value="'+urlFlash+'/'+nomeFlash+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="menu" value="false">');
	document.write('<param name="FlashVars" value="destination='+destination+'">');
	document.write('<embed src="'+urlFlash+'/'+nomeFlash+'" width="'+larghezzaFlash+'" height="'+altezzaFlash+'" quality="high" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" menu="false" flashvars="destination='+destination+'"></embed>');
	document.write('</object>');
}

