
/***********************************************
* IFrame SSI script II- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use
***********************************************/

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. 
var iframeids=["solucionesarriba","solucionesabajo","frproducto"];


//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes";
//var iframehide="no";

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1];
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 ;//extra height in px to add to iframe in FireFox 1.0+ browsers

var esIE=0;
if (window.navigator.appName == "Microsoft Internet Explorer")
		esIE=1;
		

function resizeCaller() {
	
	var dyniframe=new Array();
	for (i=0; i<iframeids.length; i++){
		if (document.getElementById)
		resizeIframe(iframeids[i]);
		//reveal iframe for lower end browsers? (see var above):
		if ((document.all || document.getElementById) && iframehide=="no"){
			var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])
			tempobj.style.display="block";
		}
	}
}


var timeOut='';
var frameId='';
function resizeIframe(frameid ){

try {

var currentfr=document.getElementById(frameid);	

if( currentfr=="" || currentfr==undefined ) { 
		return;
}

  //currentfr.height=100;
  //window.resizeTo(800, 600);
  //document.recalc(true);	

	if (currentfr && !window.opera){
		currentfr.style.display="block";
		
		
			if (esIE==0 && currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) { //ns6 syntax
			
			if (currentfr.contentWindow.frames != null && currentfr.contentWindow.frames.length>0 ){ // && currentfr.contentDocument.body.frames.length>0  ) { 
			//Aniadido para cuando hay frames. El caso no normal ...

			
				var iH=0;
				for (var i=0;i<currentfr.contentWindow.frames.length;i++){
					iH+=currentfr.contentWindow.frames[i].document.body.offsetHeight;
					//alert('firefox '+iH);	
				}
				
				currentfr.height=iH+25;
			}else { //El caso normal (No hay frames dentro del iframa).Lo que habia en la funcion original
				currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight+25; 	
			}
			//alert( currentfr.height );
		} else if (currentfr.Document&& currentfr.Document.body && currentfr.Document.body.scrollHeight) {//ie5+ syntax
		
		
		   nodelist = currentfr.Document.getElementsByTagName('IFRAME');	
		   if( nodelist && nodelist.length>0 ){
		   //Aniadido para cuando hay iframes dentro del iframe ...	
		   	for( var cnt=0; cnt<nodelist.length;cnt++ )
		   	{
		   		iFA=nodelist[cnt].height;
		   	}
		   	currentfr.height=iFA;
		   }else  if (currentfr.Document.frames.length) { 
		   //Aniadido para cuando hay frames
			var iH=0;
			for (var i=0;i<currentfr.Document.frames.length;i++){
				try { 
					iH+=currentfr.Document.frames[i].document.body.scrollHeight;
				} catch ( e ) { 
					//alert ( 'we got it ' + e ); Si no nos deja, pasamos de el Frame Borde
 				}
			}
			//alert('frames');
			currentfr.height=iH;
		   }else { //Caso Normal no hay frames
			currentfr.height = currentfr.Document.body.scrollHeight+15;
		   }
		}
	
		if (currentfr.addEventListener) {
		//Esto es mozilla
			currentfr.addEventListener("load", readjustIframe, false);
		} else if (currentfr.attachEvent){
		//Esto es ie
			currentfr.detachEvent("onload", readjustIframe); // Bug fix line
			currentfr.attachEvent("onload", readjustIframe);
		}
		
		
	}
	
  }catch( e ){
  	//alert('iframe.js: Excepcion '+e  );
  	
  }
}

function readjustIframe(loadevt) {
	
	
	var crossevt=(window.event)? event : loadevt;
	var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement;
	if (iframeroot){
		resizeIframe(iframeroot.id);
		//alert( 'readjust '+ iframeroot.id);
	}
}

function loadintoIframe(iframeid, laUrl){
	if (document.getElementById) {
		document.getElementById(iframeid).src=laUrl;
	}
}

if (window.addEventListener) {
	window.addEventListener("load", resizeCaller, false)
} else if (window.attachEvent) {
	window.attachEvent("onload", resizeCaller)
} else {
	window.onload=resizeCaller
}


