
/*  Classe Cookies Manager per la memorizzazione e
	il caricamento di cookies javascript */
function CookiesManager() {

  this.readCookie = function(name) {
     var nameEQ = name + "=";
	 var ca = document.cookie.split(';');
	 for(var i=0;i < ca.length;i++) {
	    var c = ca[i];
	    while (c.charAt(0)==' ') c = c.substring(1,c.length);
	    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
   }

  this.createCookie = function(name,value,days) {
     if (days) {
	        var date = new Date();
	        date.setTime(date.getTime()+(days*24*60*60*1000));
	        var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; path=/";
   }


	this.eraseCookie = function(name) {
	    this.createCookie(name,"",-1);
	}
	
	this.hasCookie = function(name) {
		return this.readCookie(name) != null;
	}
}

     

function BodyInfoIE6() {
  	this.height = document.documentElement.clientHeight;
	this.width = document.documentElement.clientWidth;
  	this.Width = function() { return this.width-1; }
  	this.Height = function() { return this.height;}
}

function BodyInfoW3c() {
	this.height = document.body.clientHeight;
	this.width = document.body.clientWidth;
  	this.Width = function() { return this.width; }
  	this.Height = function() { return this.height;}// document.body.clientHeight-17; }
}

function BodyInfoOpera() {
	this.height = document.body.clientHeight;
	this.width = document.body.clientWidth;
  	this.Width = function() { return this.width-2; }
  	this.Height = function() { return this.height-1;}// document.body.clientHeight-17; }
}



function BodyInfoFactory() {
	this.getBodyInfo = function()
	{
		if(IE6) return new BodyInfoIE6();
		else if(OP) return new BodyInfoOpera();
		else return new BodyInfoW3c();
	}
}



function ElementInfoOP(_id) {
	this.element = document.getElementById(_id);
  	this.Width = function() { return this.element.style.pixelWidth ; }
  	this.Height = function() { return this.element.style.pixelHeight; }
  	this.Top = function(){
  		yPos = this.element.offsetTop;
		tempEl = this.element.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
  	}

}

function ElementInfoW3c(_id) {
	this.element = document.getElementById(_id);
  	this.Width = function() { return this.element.offsetWidth ; }
  	this.Height = function() { return this.element.offsetHeight; }
  	this.Top = function(){
  		yPos = this.element.offsetTop;
		tempEl = this.element.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		
  		}
		return yPos;
  	}
}

function ElementInfoNS(_id) {
	this.element = document.getElementById(_id);
  	this.Width = function() { return this.element.offsetWidth ; }
  	this.Height = function() { return this.element.offsetHeight; }
  	//this.Top = function(){
  	//	yPos = this.element.pageY;
	//	return yPos;
  	//}
  	this.Top = function(){
  		yPos = this.element.offsetTop;
		tempEl = this.element.offsetParent;
		while (tempEl != null) {
  			yPos += tempEl.offsetTop;
	  		tempEl = tempEl.offsetParent;
  		}
		return yPos;
  	}

}


function ElementInfoFactory() {
	this.getElementInfo = function(_id)
	{
		if(OP || IE6) return new ElementInfoOP(_id);
		else if(ns6) return new ElementInfoNS(_id);
		else return new ElementInfoW3c(_id);
	}
}













