function getDocHeight(doc) {
	var docHt = 0, sh, oh;
	if (doc.height)
 		docHt = doc.height;
 	else if (doc.body) {
 		if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
 		if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
 		if (sh && oh) docHt = Math.max(sh, oh);
	}
 return docHt;
}

function setIframeHeight(padre, iframeName) {
	var iframeWin = parent.window.frames[iframeName];
 	var iframeEl = parent.document.getElementById? parent.document.getElementById(iframeName): parent.document.all? parent.document.all[iframeName]: null;
 	if ( iframeEl && iframeWin ) {
 		iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous
 		var docHt = getDocHeight(iframeWin.document);
 		// need to add to height to be sure it will all show
 		if (docHt) iframeEl.style.height = docHt + 30 + "px";
	}
}

function goSetHeight(){
 	if (parent == window)
 		return;
 	else{
 		try {
 			// arg: id of iframe element this doc is to be loaded into
 			setIframeHeight(parent,this.name);
 		} catch(e){}
 	}
}

function terminoAjax(resp){
	goSetHeight();
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else return true;
}

function setParentHeight(iframeCarga, relative, who) {
	var actualH = getDocHeight(document);
	
	if ( who == 'parent' ) {
		alert(getDocHeight(document.getElementById(relative)));
		var nuevaH = actualH + getDocHeight(document.getElementById(relative));
		alert(nuevaH);

		window.parent.document.getElementById(iframeCarga).style.height = nuevaH + "px";
	} else {
		var abuelo = window.parent.window.parent;

		window.parent.document.getElementById(iframeCarga).style.height = actualH + "px";
		var parentH = getDocHeight(abuelo.document);
alert(parentH);
		abuelo.document.getElementById(relative).style.height = parentH + "px";
	}
}

function resizeFrame ( actualFrameObj, parentFrameObj, childFrameObj ) {
	alert( "prueba script iframe: resizeFrame" );
	if( actualFrameObj!=null ) {
	if( parentFrameObj==null ) {
		//alert( 'externo (child): ' + getDocHeight(childFrameObj.contentWindow.document) );
		//alert( 'externo (actual): ' + getDocHeight(actualFrameObj.contentWindow.document) );
		var actualH = getDocHeight(actualFrameObj.contentWindow.document);
		//var nuevaH = actualH + getDocHeight(childFrameObj.contentWindow.document);
		actualFrameObj.style.height = actualH + 30 + "px";
	} else {
		//alert('interno ' + getDocHeight(document));
		var actualH = getDocHeight(document);
		actualFrameObj.style.height = actualH + 30 + "px";
		resizeFrame( parentFrameObj, null, actualFrameObj );
	}
	}
}

function resizeSingleFrame ( frameName ) {
	var frame = window.parent.document.getElementById(frameName);
	if (frame!=null) {
		var actualH = getDocHeight(document);
		frame.style.height = actualH -1 + "px";
	}
}
 
function resizeSingleFrameTest ( frameName ) {
	var frame = window.parent.document.getElementById(frameName);
	if (frame!=null) {
		var actualH = getDocHeight(document);
		frame.style.height = actualH -1 + "px";
	}
}
 

function rsizeFrame( frame) {
	window.top.scrollTo(0,0);
	if( frame ){				
		if( window.parent && window.parent.frameElement){			
			resizeFrame( frame, window.parent.frameElement, null );
		}else{			
			resizeFrame( frame, null, null );
		}		
	}		
}

function rsizeFrameNoScroll( frame ) {
	if( frame ){				
		if( window.parent && window.parent.frameElement){			
			resizeFrame( frame, window.parent.frameElement, null );
		}else{			
			resizeFrame( frame, null, null );
		}		
	}		
}