// assic.js

// Funzione che permette il cambiamento dell'immagine dello schermo
function ChangeWallpaper(modulo){
	//Ricerca dell'elemento di sfondo
	var schermo = document.getElementById('menu');
	//Var estrazione querystring
	var query = document.location.search;
//	alert(query);
//	alert(modulo);
	//Composizione del path dell'immagine
//	var host = "/docebo_demo";
	var host = "";
	var template_dir = "/doceboLms/templates/assic/images/bande/";
	var imagefile = "nuvole.jpg";
	//Selezione dell'immagine in base all'url
	switch(modulo){
		case 'storage'	:
			imagefile = 'mulino.jpg';
		break;
		case 'coursereport'	:
			imagefile = "cannocchiale.jpg";
		break;
		case 'stats'	:
			opzione = query.slice(18,26);
			if(opzione=="statuser")
				imagefile = "colleghi.jpg";
			else
				imagefile = "farfalla.jpg";
		break;
		case 'statistic'	:
			imagefile = "divano.jpg";
		break;
		case 'groups'	:
//			imagefile = "mucchio.jpg";
			imagefile = "fiori_rossi.jpg";
		break;
		case 'manmenu'	:
			imagefile = "foglia.jpg";
		break;
		case 'course'	:
			opzione = query.slice(19,29);
			if(opzione=="infocourse")
				imagefile = "ingranaggio.jpg";
			else
				imagefile = "fiori.jpg";
		break;
		case 'coursecatalogue'	:
			imagefile = "fiori.jpg";
		break;
		case 'profile'	:
			imagefile = "fiori.jpg";
		break;
		case 'login'	:
			imagefile = "nuvole.jpg";
		break;
		case 'advice'	:
			imagefile = "margherite.jpg";
//			imagefile = "nuoto.jpg";
		break;
		case 'gradebook'	:
			imagefile = "ole.jpg";
		break;
		case 'notes'	:
			imagefile = "paesaggio.jpg";
		break;
		case 'organization'	:
			imagefile = "girasole.jpg";
		break;
		case 'message'	:
			imagefile = "aquila.jpg";
		break;
		case 'forum'	:
			imagefile = "famiglia.jpg";
		break;
		case 'chat'	:
//			imagefile = "coppia.jpg";
			imagefile = "fiore_rosa.jpg";
		break;
		case 'teleskill'	:
			imagefile = "family.jpg";
		break;
		case 'project'	:
			imagefile = "gruppo.jpg";
		break;
		default:
			imagefile = "nuvole.jpg";
	}
	//Composizione dell'URL finale dell'immagine
	var urilmage = host + template_dir + imagefile;
	//Impostazione stile dell'elemento
	schermo.style.backgroundImage =  "url(" + urilmage +")";
	if(imagefile=='nuvole.jpg')
		schermo.style.backgroundPosition = "left 5px";
	else
		schermo.style.backgroundPosition = "left -10";
	schermo.style.backgroundRepeat = "no-repeat";
	schermo.style.backgroundColor = "#FFFFFF";
}

function InsertFlashContent(DivEmbedder,ObjectName,Width,Height,URLname,Alignment,Color){
	var embeddiv = document.getElementById(DivEmbedder);
	if(Color==undefined)
		Color="#ffffff";
	embeddiv.innerHTML ='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width='+Width+' height='+Height+'  align='+Alignment+' VIEWASTEXT >'+'<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' +URLname +'" />'+'<param name="quality" value="high" /><param name="menu" value="false" /><param name="bgcolor" value='+Color+' />'+'<embed src="'+URLname+'" quality="high" bgcolor='+Color+' width='+Width+' height='+Height+' name='+ObjectName+' align='+Alignment+' allowScriptAccess="sameDomain" type="application/x-shockwave-flash" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>';
}

//Funzione che inibisce il tasto destreo del mouse
var message="";
function clickIE() {
	if (document.all) 
	{
		return false;
	}
}
function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all)) {
		if (e.which==2||e.which==3) {
			return false;}
		}
}
if (document.layers){
	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
}else{
	document.onmouseup=clickNS;
	document.oncontextmenu=clickIE;
}
document.oncontextmenu = new Function("return false");

function SetDimensions(){
	var bIE = navigator.appName=="Microsoft Internet Explorer";
	if(bIE){
		var corpo_w = document.width;
		var corpo = document.body.clientWidth;
		alert(corpo_w);
		var margine = (corpo_w-corpo)/2;
		document.body.marginLeft=margine;
		alert(margine);
	}
	else{
		var corpo_w = window.innerWidth;
		var corpo = document.body.clientWidth;
		var margine = (corpo_w-corpo)/2;
		document.body.leftMargin=margine;
		document.tags.BODY.marginLeft=margine;
		alert(margine);		
	}
}
