﻿// Utility per il cambio degli sfondi del sito.
// Ultima modifica: 3 luglio 2008.
// Autore: Vincenzo Pizio.

var mm_sfondo;

function manager_sfondo()
{
    mm_sfondo = this;
    this.texture = 1;
    this.color = 1
   
    manager_sfondo.prototype.change_color = function(c){
        this.color = c;
        document.cookie = "color=" + c;
        document.body.style.backgroundImage = "url('grafica/texture/texture" + this.texture + "_colore" + this.color + ".jpg')";
    }
    
    manager_sfondo.prototype.change_texture = function(t){
        this.texture = t;
        document.cookie = "texture=" + t;
        document.body.style.backgroundImage = "url('grafica/texture/texture" + this.texture + "_colore" + this.color + ".jpg')";
    }
    
    manager_sfondo.prototype.charge_color_settings = function(){
       start = document.cookie.indexOf("color="); 
       if(start!=-1)
       {
		    end = start + 7;
		    stringa = document.cookie.substring(start + 6, end);
		    this.color = stringa;
		    this.change_color(stringa);
	   }
    }
    
    manager_sfondo.prototype.charge_texture_settings = function(){
       start = document.cookie.indexOf("texture="); 
       if(start!=-1)
       {
		    end = start + 9
		    stringa = document.cookie.substring(start + 8, end);
		    this.texture = stringa;
		    this.change_texture(stringa);
	   }
    }
}