
//size


var nowW = 0;
var maxW = eval(document.documentElement.clientWidth - 10);
var maxH = eval(document.documentElement.clientHeight - 10);

function resize(i){
	document.getElementById('dettaglio-container').style.border = '2px solid #000';
	document.getElementById('dettaglio-container').style.padding = '0';
	nowW = i + 60;
	resizeDynamicDettaglioContainer(nowW, nowW);
	if(nowW<maxW)
		setTimeout('resize(nowW);', 1);
	else{
		Richiesta('dettaglio.php?img=' + currentImg,'dettaglio-container');
		resizeDettaglioContainer();
		document.getElementById('dettaglio-container').style.display = 'block';
		var dett = document.getElementById("dettaglio-img");
		if(dett!=null)
			dett.style.display = 'block';
		a = 0;
		AlphaShow(a);
		centerImage();
	}
}

function resizeDynamicDettaglioContainer(w, h){
	var y = eval(((maxH-h)/2)+100)
	if(y>-100)
		document.getElementById('dettaglio-container').style.top = y + 'px';
	else
		document.getElementById('dettaglio-container').style.top = '-100px';
	var x = eval(((maxW-w)/2)-100);
	if(x>-100)
		document.getElementById('dettaglio-container').style.left = x + 'px';
	else
		document.getElementById('dettaglio-container').style.left = '-100px';
		
	if(h<maxH)
		document.getElementById('dettaglio-container').style.height = h + 'px';
	document.getElementById('dettaglio-container').style.width = w + 'px';
	
}


function resizeDettaglioContainer(){
	//document.getElementById('dettaglio-container').style.border = '0px solid #000';
	var w = document.documentElement.clientWidth;
	var h = document.documentElement.clientHeight;
	document.getElementById('dettaglio-container').style.width = eval(w - 10) + 'px';
	document.getElementById('dettaglio-container').style.height = eval(h -10) + 'px';
}

function centerImage(){
}


//opacity

function hideDettaglio(){
	document.getElementById('dettaglio-container').style.display = 'none';
	Richiesta('wait.php','dettaglio-container');
}

function AlphaShow(i){
	a = i + 1;
	setOpacity(a);
	if(a<100)
		setTimeout('AlphaShow(a)', 40 ); 
}

function setOpacity(value) {
	var dett = document.getElementById('dettaglio-img');
	if(dett!=null){
		dett.style.opacity = value/10;
		document.getElementById('dettaglio-img').style.filter = 'alpha(opacity=' + value*10 + ')';
	}
}


var a = 0;


function Color(i){
	a = i +1;
	var c = getColor(a);
	document.getElementById('dettaglio-container').style.backgroundColor = '#' + c + '' + c + '' + c;
	if(a<15)
		setTimeout('Color(a)', 40 ); 
}

function getColor(a){
	if(a<10)
		return a;
	else if(a==10){
		return "a";
	}
	else if(a==11){
		return "b";
	}
	else if(a==12){
		return "c";
	}
	else if(a==13){
		return "d";
	}
	else if(a==14){
		return "e";
	}
	else if(a==15){
		return "f";
	}
}
