////////////////////////////////////////////////////////////////
//                                                            //
//                SPOT SYSTEMS   WINDOW V1.1                  //
//             FOR MICROSOFT IEXPLORER 6.0 SP1                //
//                                                            //
//             VERSIONE SPOT DIVERSI GIORNI/ORA               //
//          CON COOKIE PER NON RIPETIZIONE IMMEDIATA          //
//                                                            //
//   (c) Copyright 2003. Spotsystems || www.spotsystems.it    //
//                                                            //
//////////////////////////////////////////////////////////////// 

var s=10; // Minuti durata cookie
var ran=random(2)
var exp=new Date();
var giorno=exp.getDate();
var mese=(exp.getMonth()+1);
var anno=exp.getYear();
exp.setTime(exp.getTime() + (s*1000*60));
var ora=new Date;
var adesso=ora.getHours();
var xw=random(200);
var yw=random(50);


function random(max) {
	today=new Date();
	jran=today.getTime();
	ia=9301;
	ic=49297;
	im=233280;
	jran = (jran*ia+ic) % im;
	r1=Math.ceil( (jran/(im*1.0)) *max);
	return r1;}

//funzione spotCookie
function spotCookie(mode)
 {
	                    
	var VisitorName=GetCookie(Cname);
	if (VisitorName==null)
	{
	 	if (mode=='2') 
		{
	 	mySpot.openSpot();
		};
		VisitorName=Cname;
		SetCookie(Cname, VisitorName, exp, "/", null, false); 
	};
 return "";
};

//Cookie
function getCookieVal (offset) {
	var endstr=document.cookie.indexOf(";",offset);  
	if (endstr==-1) endstr=document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));}

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) 
   {
   var argv = SetCookie.arguments;
   var argc = SetCookie.arguments.length;
   var expires = (2 < argc) ? argv[2] : null;
   var path = (3 < argc) ? argv[3] : null;
   var domain = (4 < argc) ? argv[4] : null;
   var secure = (5 < argc) ? argv[5] : false;
   document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
     ((secure == true) ? "; secure" : "");
}

function DisplayInfo()
 	{
	var expdate = new Date();
	var visit;
	expdate.setTime(expdate.getTime()+(24*60*60*1000*365));
	if(!(visit = GetCookie("visit")))
	visit = 0;
	visit++;
	SetCookie("visit", visit, expdate, "/", null, false);
	}
	
function ResetCounts()
	{
	var expdate = new Date();
	expdate.setTime(expdate.getTime() + (24*60*60*1000*365));
	visit  = 0;
	SetCookie("visit", visit, expdate, "/", null, false);
	leapto()
	}
	
DisplayInfo()
	
	
//Inizio SpotWindow
SpotWindow = function ()
{

	this.titleSize = 0;
	this.titlebarHeight = 0;
	this.w = 0;
	this.h = 0;
	this.xPos = 0;
	this.yPos = 0;
	this.borderSize = 0;
	
	this.spotCompatible = navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion)>=4 ? true:false;
	
}

SpotWindow.prototype.openSpot = function()
{
	this.startSpot();
	
}

SpotWindow.prototype.closeSpot = function()
{
	this.spotMovie.close();
}

SpotWindow.prototype.startSpot = function()
{
	if(this.centered=="yes")
	{
		var tempX = this.w;
		var tempY = this.h;
		this.xPos = (screen.availWidth/2)-(tempX/2);
		this.yPos = (screen.availHeight/2)-(tempY/2);
	}
	if (this.spotCompatible)
	{
		this.spotMovie = window.open("about:blank","","top=8000,left=8000,width=10,height=10,scrollbars="+this.scrollbars);
	}
	else
	{
		this.spotMovie = window.open(this.URL, "SpotWindow", "top="+this.yPos+",left="+this.xPos+",width="+this.w+",height="+this.h+",toolbar=0,scrollbars="+this.scrollbars+",resizable=0");
	}
	this.cH = (this.h-this.titlebarHeight)-this.borderSize;
	this.cW = this.w -(this.borderSize*2);
	this.c = "<object type='text/html' border='0' style='position:absolute;z-index:2;top:"+this.titlebarHeight+"px;left:"+this.borderSize+"px;width:"+this.cW+"px;height:"+this.cH+"px;' data='"+this.URL+"' id='canvas'></object>";
	
	this.menu = "\
		<div id='Title' unselectable='on' style='font-family:Arial;font-size:11px;font-weight:bold;position:absolute;top:5px;left:"+this.borderSize+"px;width:70%;height:15px;cursor:default;font-family:"+this.titleFont+";font-size:"+this.titleSize+";color:"+this.titleColor+";z-index:3'>"+this.title+"</div>\
		<img id='closeBottom' unselectable='on' src='"+this.closeBottom+"' width='16' height='10' style='position:absolute; top:5px; right:"+(this.borderSize)+"px;z-index:3'>\
		"+this.titlebarContent+"\
		<img id='minimizeBottom' unselectable='on' src='"+this.minimizeBottom+"' width='16' height='10' style='position:absolute; top:5px; right:"+(this.borderSize+20)+"px;z-index:3'>\
		<div id='fondo' unselectable='on' style='position:absolute; top:0px; left:0px; width:100%; height:100%; background-color:"+this.borderColor+";z-index:1'></div>";

	if (this.spotCompatible)
	{
		this.spotMovie.moveTo(300,-5000);
		this.spotMovie.resizeTo(800,600);
		this.spotMovie.document.writeln('<html>');
		this.spotMovie.document.writeln('<head>');
		this.spotMovie.document.writeln('<META HTTP-EQUIV="imagetoolbar" CONTENT="no">');
		this.spotMovie.document.writeln('<style>');
		this.spotMovie.document.writeln('BODY{border:0px !important}');
		this.spotMovie.document.writeln('</style>');
		this.spotMovie.document.writeln('</head>');
		this.spotMovie.document.writeln('<body>');
		this.spotMovie.document.writeln('<script>');
		this.spotMovie.document.writeln('var c=window.createPopup();');
		this.spotMovie.document.writeln('var b=c.document.body;');
		this.spotMovie.document.writeln("var ox=oy=ix=iy=0;");
		this.spotMovie.document.writeln("var allContent =\""+this.menu+this.c+"\";");
		this.spotMovie.document.writeln('b.innerHTML=allContent;');
		this.spotMovie.document.writeln('var cx='+this.xPos+';');
		this.spotMovie.document.writeln('var cy='+this.yPos+';');
		this.spotMovie.document.writeln('var cw='+this.w+';');
		this.spotMovie.document.writeln('var ch='+this.h+';');
		this.spotMovie.document.writeln('function showSpot(){');
		this.spotMovie.document.writeln('c.show(cx,cy,cw,ch);focus()');
		this.spotMovie.document.writeln('}');
		this.spotMovie.document.writeln('var mm=false;');
		this.spotMovie.document.writeln('var cmove=b.all("fondo");');
		this.spotMovie.document.writeln('var allb=b.all("allborders");');
		this.spotMovie.document.writeln('var cmove2=(b.all("menu"))?b.all("menu"):"";');
		this.spotMovie.document.writeln('var ctitle=b.all("Title");');
		this.spotMovie.document.writeln('ctitle.style.visibility=('+this.tb+')?"hidden":"visible";');
		this.spotMovie.document.writeln('var cclose=b.all("closeBottom");');
		this.spotMovie.document.writeln('var cminimize=b.all("minimizeBottom");');
		this.spotMovie.document.writeln('cclose.onclick=function(){opener=self;self.close()};');
		this.spotMovie.document.writeln('cminimize.onclick=function(){if(top.opener&&!top.opener.closed){top.opener.window.focus()};top.window.blur()};');
		this.spotMovie.document.writeln('var ox=oy=ix=iy=0;');
		this.spotMovie.document.writeln('var m=0;');
		this.spotMovie.document.writeln('ctitle.onmousedown=function(){m=1};');
		this.spotMovie.document.writeln('ctitle.onmouseup=function(){m=0};');
		this.spotMovie.document.writeln('cmove.onmousedown=function(){m=1};');
		this.spotMovie.document.writeln('cmove.onmouseup=function(){m=0};');
		this.spotMovie.document.writeln('cmove2.onmousedown=function(){m=1};');
		this.spotMovie.document.writeln('cmove2.onmouseup=function(){m=0};');
		this.spotMovie.document.writeln('document.body.onclick=function(){ if (m) { focus();cx=ix+event.screenX-ox;cy=iy+event.screenY-oy;c.show(cx,cy,cw,ch) }else { ix=cx; iy=cy; ox=event.screenX; oy=event.screenY } };');
		this.spotMovie.document.writeln('setInterval("document.body.click()",20);');
		this.spotMovie.document.writeln('onfocus=function(){showSpot();}');
		this.spotMovie.document.writeln('</script>');
		this.spotMovie.document.writeln('</body>');
		this.spotMovie.document.writeln('</html>');
		this.spotMovie.document.location.reload();
		this.spotMovie.document.title = this.title;
		
	}
	else
	{
		this.spotMovie.document.title = this.title;
	}
	
}

var mySpot = new SpotWindow();
//Dati da non variare!!!
mySpot.titlebarHeight = -2;
mySpot.scrollbars = "no"; 
mySpot.borderSize = -2;
mySpot.titleFont = "Arial";
mySpot.titleSize = 14;
mySpot.titleColor = "#F0F0F0";
mySpot.borderColor = "#ffffff";
mySpot.title = "Spotsystems Window";



//////////////////////////////////////////
//Comando lancio Spot Popup Window     ///
//////////////////////////////////////////

if (giorno==22||giorno==23||giorno==24||giorno==25||giorno==26||giorno==27||giorno==28||giorno==29||giorno==30||giorno==31){
	if (mese == 5){
		if (anno == 2003){
			if (adesso != 25){
	//Inserire il nome del file1 da richiamare
	mySpot.URL = "http://www.clarence.com/common/spotsystem/nokia_tec_maggio/nokia_cla.html";
	//Dimensioni finestra1
	mySpot.w = 100; //larghezza
	mySpot.h = screen.height; //altezza
	//Per centrare la finestra1 inserire "yes" per altre posizioni "no"
	mySpot.centered = "no";
	//Posizione della finestra1 se non centrata
	mySpot.xPos = 0;
	mySpot.yPos = 0;
	//variabile Cname da assegnare a seconda dello spot
	var Cname="spotsystemsit-nokia_cla"; 
	spotCookie(2);
			};
		};
	};
};

