
function autoFit() {
	/*
	alert("This web page containg " + document.frames.length + " iframe element");
	alert(document.frames[0].document.body.scrollHeight);
	*/
	
	// document.frames[0].resizeTo(document.frames[0].document.body.scrollWidth, document.frames[0].document.body.scrollHeight)
	/*
	var thisIndex = new Number;
	for(thisIndex=0;thisIndex<=document.frames.lenght;thisIndex++) {
		alert(document.frames[thisIndex].document.body.scrollheight);
		document.frames[thisIndex].resizeTo(document.frames[thisIndex].document.body.scrollWidth, document.frames[thisIndex].document.body.scrollHeight)
	}
	*/
}

function autoFit2(layerName) {
	var iObj = eval('IFRAME_' + layerName);
	try {
		if(iObj.document.domain==document.domain) {
			iObj.resizeTo(iObj.document.body.scrollWidth, iObj.document.body.scrollHeight);
		}
	} catch (iExp) {
		// ...
	}
}

var reloadCounter = new Number;
function restartRequest(iCount) {
	reloadCounter = iCount;
	setTimeout("reloadPage()", 1000);
} 

function reloadPage() {
	document.location.reload();
}

function quickEditWebpart(iWebpart) {
	var regExp = /WEBPART_/g;
	var iElement = iWebpart.replace(regExp,'');
	window.open('layout/handleWebpart.asp?OBJ=' + iElement);
}

function quickEditArea(iArea) {
	window.open('layout/editArea.asp?AREA=' + iArea + '&PAGE=' + iPageName);
}

var parentElement = new String;

function supportTextshowLayer(childElement, xPos, yPos) {
	// ...
	var regExp = /CHILD_/g;
	parentElement = childElement.replace(regExp, '');

	SUPPORT_TEXT_LAYER_CONTENT.innerHTML = '<img style=\"cursor: hand;\" onClick=javascript:supportTextHideLayer(\"' + childElement + '\") src=layout\\imag\\hidepane.gif align=center border=1><br>';
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML += 'Technical information: <br>Nome fisico: <b>' + parentElement + '</b>';
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML += '<br>Posizione: (left,top): ' + xPos + ',' + yPos;
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML += '<br>Dimensione: (WxH): ' + (eval(parentElement).getBoundingClientRect().right - eval(parentElement).getBoundingClientRect().left) + ',' + (eval(parentElement).getBoundingClientRect().bottom - eval(parentElement).getBoundingClientRect().top);
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML += '<br>Peso del testo (escluse immagini): ' + eval(parentElement).innerText.length + ' bytes';
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML += '<br><a style=\"font-weight: bold;\" href=javascript:quickEditWebpart(\"' + parentElement + '\") >Configura questa webpart</a>';
	
	SUPPORT_TEXT_LAYER.style.left = xPos + 10;
	SUPPORT_TEXT_LAYER.style.top = yPos + 10;
	SUPPORT_TEXT_LAYER.style.display = '';
	
}

function supportTextHideLayer(childElement) {
	SUPPORT_TEXT_LAYER_CONTENT.innerHTML = '';
	SUPPORT_TEXT_LAYER.style.display = 'none';
	eval(parentElement).style.border='solid 1pt #ffcc00';
}

function supportTextHideLayer2(childElement) {
	// ...
}

function showWebparts() {

	window.scrollTo(0,0);
	// highlight webpart items...
	for(var thisIndex=0;thisIndex<document.all.length;thisIndex++) {
		if(document.all[thisIndex].tagName=='DIV' && document.all[thisIndex].className=='web_part') {
			document.all[thisIndex].style.border='solid 1pt #ffcc00';
			document.body.innerHTML+='<DIV ID=CHILD_' + document.all[thisIndex].id + ' onMouseOver=javascript:supportTextshowLayer(\"CHILD_' + document.all[thisIndex].id + '\",' + document.all[thisIndex].getBoundingClientRect().left + ',' + document.all[thisIndex].getBoundingClientRect().top + ') onMouseOut=javascript:supportTextHideLayer2(\"CHILD_' + document.all[thisIndex].id + '\") onclick=javascript:quickEditWebpart(\"' + document.all[thisIndex].id + '\") style=\"cursor: hand; color: white; font: 7pt verdana; height: 12pt; width: 14pt; background: black; position: absolute; left: ' + document.all[thisIndex].getBoundingClientRect().left + 'px; top: ' + document.all[thisIndex].getBoundingClientRect().top + 'px;\" >&nbsp;webpart&nbsp;</DIV>';
		}
	}
	PORTAL_LINK_WEBPART.disabled = true;
	PORTAL_LINK_WEBPART.href = 'javascript:document.location.reload()';
}

function showAreas() {
	window.scrollTo(0,0);
	for(var thisIndex=0;thisIndex<document.all.length;thisIndex++) {
		if(document.all[thisIndex].tagName=='DIV' && document.all[thisIndex].className=='COLUMN_AREA') {
			document.all[thisIndex].style.border='solid 1pt #ff0000';
			document.body.innerHTML+='<DIV ID=AREA_' + document.all[thisIndex].parentElement.id + ' onclick=javascript:quickEditArea(\"' + document.all[thisIndex].parentElement.id + '\") style=\"cursor: hand; color: white; font: 7pt verdana; height: 12pt; width: 14pt; background: black; position: absolute; left: ' + document.all[thisIndex].getBoundingClientRect().left + 'px; top: ' + document.all[thisIndex].getBoundingClientRect().top + 'px;\" >&nbsp;area&nbsp;</DIV>';		}
	}
	PORTAL_LINK_AREA.disabled = true;
	PORTAL_LINK_AREA.href = 'javascript:document.location.reload()';

}

function changeStyle() {
	// alert(document.styleSheets[0].id);
	document.styleSheets[0].disabled = true;
	
	document.createStyleSheet('lib\\accessibleStyle.txt');
}


