
function resizeFrames(){
  try{
    // Resizing Left Frame
    var frame = document.getElementById( 'bm_left_frame');
    var frameHeight;

    // calculating frame's height
    if(frame.contentDocument!=null){
      frameHeight = parseInt(frame.contentDocument.body.scrollHeight);
    } else if(frame.contentWindow!=null){
      frameHeight = parseInt(frame.contentWindow.document.body.scrollHeight);
    } else if(frame.document!=null){
      frameHeight = parseInt(frame.document.body.offsetHeight);
    } else {
      return true;
    }
    // stablishing height
    if(parseInt(document.body.scrollHeight)-125<frameHeight){
      frame.style.height = frameHeight+"px";
    } else {
      frame.style.height = (parseInt(document.body.scrollHeight)-125)+"px";
    }

    // Resizing Top Frame
    frame = document.getElementById( 'bm_top_frame');
    var body = document.getElementById( 'bm_body');
    var frameWidth;
    var clientWidth;

    // calculating frame's width
    if(frame.contentDocument!=null){
      frameWidth = parseInt(frame.contentDocument.body.scrollWidth);
    } else if(frame.contentWindow!=null){
      frameWidth = parseInt(frame.contentWindow.document.body.scrollWidth);
    } else if(frame.document!=null){
      frameWidth = parseInt(frame.document.body.offsetWidth);
    } else {
      return true;
    }
    // stablishing width
    clientWidth = parseInt(document.body.scrollWidth);
    if(clientWidth<frameWidth){
      frame.style.width = frameWidth+"px";
      body.style.width = (frameWidth-161)+"px";
    } else {
      frame.style.width = "100%";
      body.style.width = "100%";
    }
	
  }catch( err){}
  expandffiframe();
}

// Resize an Iframe to fit the COMPLETE content area.
function resizeIFrame(frameName){
  try{
    var ifrm = document.getElementById(frameName);
    var leftIfrm = document.getElementById('bm_left_frame');
    var height;

    if(ifrm == null || leftIfrm == null){
      return;
    }

    if(ifrm.contentDocument!=null){
      try{
        ifrm.contentDocument.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.contentDocument.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.contentDocument.body.scrollHeight);
    } else if(ifrm.contentWindow!=null){
      try{
        ifrm.contentWindow.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.contentWindow.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.contentWindow.document.body.scrollHeight);
    } else if(ifrm.document!=null){
      try{
        ifrm.document.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.document.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.document.body.offsetHeight);
    } else {
      return true;
    }
    var IfrmHeight;
    // calculating left frame's height
    if(leftIfrm.contentDocument!=null){
      leftIfrmHeight = parseInt(leftIfrm.contentDocument.body.scrollHeight);
    } else if(leftIfrm.contentWindow!=null){
      leftIfrmHeight = parseInt(leftIfrm.contentWindow.document.body.scrollHeight);
    } else if(leftIfrm.document!=null){
      leftIfrmHeight = parseInt(leftIfrm.document.body.offsetHeight);
    } else {
      return true;
    }
    // stablishing height
    if(parseInt(document.body.scrollHeight)-125>leftIfrmHeight){
      leftIfrmHeight = (parseInt(document.body.scrollHeight)-125);
    }

    if( parseInt(leftIfrmHeight)>height){
      ifrm.style.height = leftIfrmHeight-16+"px";
    }  else {
      leftIfrm.style.height = (height+16)+"px";
    }
	ifrm.style.height = leftIfrmHeight+"px";

  }catch(err){ }
}


function resizePortlet(frameName){
  try{
    var ifrm = document.getElementById(frameName);
    var height;

    if(ifrm == null){
      return;
    }

    if(ifrm.contentDocument!=null){
      try{
        ifrm.contentDocument.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.contentDocument.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.contentDocument.body.scrollHeight);
    } else if(ifrm.contentWindow!=null){
      try{
        ifrm.contentWindow.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.contentWindow.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.contentWindow.document.body.scrollHeight);
    } else if(ifrm.document!=null){
      try{
        ifrm.document.attachEvent('onunload', function () {top.document.getElementById(frameName).style.height='100%';});
      }catch(ex){
        try{ifrm.document.addEventListener('unload', function () {top.document.getElementById(frameName).style.height='100%';}, false);}catch(ex1){}
      }
      height = parseInt(ifrm.document.body.offsetHeight);
    } else {
      return true;
    }
    ifrm.style.height = height+"px";
    resizeFrames();

  }catch(err){ }
}

function resizePIFrame( frameName){
  var ifrm = document.getElementById( frameName);
  var height;
  if(ifrm.contentDocument!=null){
    height = parseInt(ifrm.contentDocument.body.scrollHeight);
  } else if(ifrm.contentWindow!=null){
    height = parseInt(ifrm.contentWindow.document.body.scrollHeight);
  } else if(ifrm.document!=null){
    height = parseInt(ifrm.document.body.offsetHeight);
  } else {
    return true;
  }
  ifrm.height = height;
  ifrm.width = "100%";
}


function ffBrowser() {
	return(navigator.userAgent.indexOf("Firefox")>0);
}


function expandffiframe() {
	if (ffBrowser()) {
		var iframes = document.getElementsByTagName('iframe');
		for (i=0; i<iframes.length; i++) {
			//alert('iframes['+i+'].style.height='+iframes[i].style.height+', .height='+iframes[i].height);
			if (iframes[i].style.height=='100%') {
				//alert('id='+iframes[i].getAttribute('id'));
				if (iframes[i].getAttribute('id')==null) {
					iframes[i].setAttribute('id','mainIFrame');
				}
				resizeIFrameObject(iframes[i]);
			}
		}
	}
}

// Resize an Iframe to fit the COMPLETE content area.
function resizeIFrameObject(ifrm){
  try{
    var leftIfrm = document.getElementById('bm_left_frame');
    var height;

    if(ifrm == null){
      return;
    }

    var IfrmHeight;
    // calculating left frame's height
    if(leftIfrm.contentDocument!=null){
      leftIfrmHeight = parseInt(leftIfrm.contentDocument.body.scrollHeight);
    } else if(leftIfrm.contentWindow!=null){
      leftIfrmHeight = parseInt(leftIfrm.contentWindow.document.body.scrollHeight);
    } else if(leftIfrm.document!=null){
      leftIfrmHeight = parseInt(leftIfrm.document.body.offsetHeight);
    } else {
      return true;
    }
    // stablishing height
    if(parseInt(document.body.scrollHeight)-125>leftIfrmHeight){
      leftIfrmHeight = (parseInt(document.body.scrollHeight)-125);
    }

	ifrm.style.height = (leftIfrmHeight-39)+"px";

  }catch(err){ }
}



function loadExternal(url) {
  try{
    var bufferFrame = document.getElementById('bm_container');
    var bufferDocument;

    // Obtain Document object
    // for IE, NN, Moz
    if( bufferFrame.contentDocument!=null){
      bufferDocument = bufferFrame.contentDocument;
    } else if( bufferFrame.contentWindow!=null){
      bufferDocument = bufferFrame.contentWindow.document;
    } else if( bufferFrame.document!=null){
      bufferDocument = bufferFrame.document;
    }

    bufferDocument.location = url;
    alert('listo');
    var body = document.getElementById('bm_body');
    body.innerHTML = '<img src="/images/loading.gif" alt="">';
    return false;
  } catch( error){
    alert(error.message);
    return true; // other browsers follow link
  }
}

// called when documents loaded into iframe (from their body's onload attribute)
function displayExternal() {
  try{
    var bufferFrame = document.getElementById('bm_container');
    var bufferDocument;

    // Obtain Document object
    // for IE, NN, Moz
    if( bufferFrame.contentDocument!=null){
      bufferDocument = bufferFrame.contentDocument;
    } else if( bufferFrame.contentWindow!=null){
      bufferDocument = bufferFrame.contentWindow.document;
    } else if( bufferFrame.document!=null){
      bufferDocument = bufferFrame.document;
    }

    var body = document.getElementById('bm_body');
    body.innerHTML = bufferDocument.body.innerHTML;
  } catch( error){
    alert(error.message);
  }
}

function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}



//EMBED.JS

/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}


