/*
 * positionAndSize.js
 *
 * Scrolla la pagina che contiene l'iframe all'inizio e ridimensiona l'iframe 
 * alla dimensione verticale del suo contenuto.
 *
 * $Id: positionAndSize.js,v 1.3 2009-04-20 10:24:02 stefano Exp $
 */
function positionAndSize() {
	var debug = 0;
	var element;

	if(!parent)
		return;

	parent.scroll(0,0);

	// If login frame, ignore the rest
	if(document.location.href.indexOf('login.php') != -1)
		return;

	// Cerco l'iframe contenitore
	if(debug)
		output = '';
	
	iframe = parent.document.getElementsByTagName('iframe');

	for(i = 0; i < iframe.length; i++) {
		if(iframe[i].name == 'iframe') {
			element = iframe[i];
		}
	}

	if(element) {
		if(debug) {
			output += element.height + '\n';
			output += document.body.scrollHeight + '\n';

			alert(output);
		}
		newHeight = parseInt(document.body.scrollHeight) + 60;

		if(newHeight > element.height || !isIe6())
			element.height = newHeight;
	}
}

function isIe6() {
	var browser=navigator.appName;
	var b_version=navigator.appVersion;

	if(browser == "Microsoft Internet Explorer" && b_version.indexOf('MSIE 6') != -1)
		return true;
	else
		return false;
}

