// Costanti
lngVarName = "lng";
mmenuVarName = "mmenu";
tplVarName = "tpl";

// Cambia la lingua tramite cookie
function changeLanguage(lngID){
	common_writeCookie(lngVarName, lngID, 24*365);
	if (common_readCookie(lngVarName) == lngID){
		// Ricarica la pagina (elimina le ancore perch&egrave; potrebbero dare fastidio nel reloading)
		location=common_removeURLAnchor(location); 
	}else{
		// Se i cookie non funzionano tenta con una richiesta GET
		location = common_setURLVar(location, lngVarName, lngID);
	}
}

function changeLanguageIT(){changeLanguage('IT')};
function changeLanguageEN(){changeLanguage('EN')};

function changeTemplate(tplName){
	location = common_setURLVar(location, tplVarName, tplName);	
}

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function windowResize(){
	width = document.documentElement.clientWidth;
	if ((width < 1000) || twoColumnMode ){
		// Modalità a 2 colonne
		var x = new getObj('sidebarright');
		x.style.display = 'none';

		var x = new getObj('content');
		x.style.marginRight = '0px';
		
	}else{
		// Modalità a 3 colonne
		var x = new getObj('sidebarright');
		x.style.display = 'block';
		var x = new getObj('content');
		x.style.marginRight = '210px';
	}
}

var wipe = true;
var lastAct = '';

function wipeInN(elId) {
	if (!wipe)return;
	var x = new getObj(wiped);
	x.style.display = 'none';

	var x = new getObj(elId);
	x.style.display = 'block';					

	wiped = elId;

	if (lastAct == '') lastAct = new getObj('firstNav').obj;
	lastAct.className = '';
}			

function getObjectProperties(object) {
	var result = '';
	for (var property in object) {
		result += property + ': ' + object[property] + '\r\n';
	}
	return result;
}

function lockIn(elId, linkObj) {
	wipe = true;
	wipeInN(elId);
	if (lastAct == '') lastAct = new getObj('firstNav').obj;
	linkObj.className = 'active';
	lastAct.className = '';
	lastAct = linkObj;
	wipe = false;
}						
