function trim(valor){
	var re = /^(\s)*|(\s)*$/;
	var str = (valor ? valor : this);
	return str.replace(re,'');
}
String.prototype.trim = trim;
//1.
//<a id="headerLogin"         href="javascript:ingresasPOPComentario();" title="Ingresar">Ingresar</a>

//2.
function ingresasPOPComentario(url, ancho_win_m1, alto_win_m1){
    carga_pag_ajax('../include/precarga_ajax.php', 'iFrameContenedor');
	//muestraPopUp("../interior/login_pop.php?submitTo=" + url);
	muestraPopUp(url, "hidden", "", 99999999, ancho_win_m1, alto_win_m1);
	//carga_pag_ajax(url, 'DivContenedor');
	carga_pag_ajax(url, 'iFrameContenedor');
}	
	
//3.
function muestraPopUp(sUrl,overflow,showElement,zIndexElement,ancho_win_m2,alto_win_m2){
	window.scrollBy(0,-1000); //Antes que nada hago el scroll
	var overflow          = overflow      || "hidden" ;
    var showElement       = showElement   || "" ;
    var zIndexElement     = zIndexElement || 99999999;
	var objDivBackground;
	var objDivContenedor;
	var objIframe;
	var appendBackground  = false;
	var appendContenedor  = false;
	var appendIframe      = false;


	if( ! (objDivBackground = document.getElementById('divBackground')) ){
		objDivBackground	  = document.createElement('DIV');
		appendBackground = true;
	}
	  
	objDivBackground.name 				   = "divBackground";
	objDivBackground.id 				   = "divBackground";
	objDivBackground.style.top 			   = "0px";
	objDivBackground.style.left 		   = "0px";
	objDivBackground.style.position 	   = "absolute";
	objDivBackground.style.backgroundColor = "#000000";
	objDivBackground.style.background 	   = "#000000"
	objDivBackground.style.filter 		   = "alpha (opacity=60);";
	objDivBackground.style.MozOpacity 	   = ".6";
	objDivBackground.style.Opacity 		   = ".6";
	objDivBackground.style.width 		   = "100%";
	
	objDivBackground.style.height          = "100%";
	
	/* [EKA] 17/03/2009 07:38:03 p.m. */
	//objDivBackground.style.width 					 = document.body.offsetWidth+'px';
	/* [EKA] 17/03/2009 07:38:03 p.m. */
	//objDivBackground.style.height 				 = document.body.offsetHeight+'px';

	//objDivBackground.style.height 				 = document.documentElement.clientHeight+'px';
	//objDivBackground.style.height       =document.body.parentNode.offsetHeight+'px';

	//alert('heigth2='+document.body.scrollHeight);  
	
	objDivBackground.style.height = document.body.scrollHeight+'px'; //Solucionado para mostrar hasta el fondo.
	
	//objDivBackground.style.height = "auto";
	//objDivBackground.style.width 					 = "auto";
	


	objDivBackground.style.display         = "block";
	
	sUrl = sUrl.trim();
	//alert(sUrl);
  if(sUrl.trim()){
	  if( !(objDivContenedor = document.getElementById('DivContenedor')) ){
      objDivContenedor 	= document.createElement('DIV');
      appendContenedor  = true;
	  }

    objDivContenedor.className 			   = "DivContenedor";
    objDivContenedor.id 				   = "DivContenedor";
    objDivContenedor.name 				   = "DivContenedor";
    objDivContenedor.style.backgroundColor = "#FFFFFF";
    objDivContenedor.style.border 		   = "0px none";
    objDivContenedor.style.top	 		   = "20px";
    objDivContenedor.style.left 		   = "350px";
    /* [EKA] 18/03/2009 */
    /*objDivContenedor.style.position 			 = "fixed";*/
    /*objDivContenedor.style.position 			 = "absolute";*/
    /* [EKA] 18/03/2009 */
    objDivContenedor.style.width 		   = ancho_win_m2+"px"; //520
    objDivContenedor.style.height 		   = alto_win_m2+"px"; //436
    objDivContenedor.style.overflow 	   = "hidden";
    objDivContenedor.style.display         = 'block';

    /* REMARCADO ADRIAN PARA PROBAR POR AJAX*/
	if( !(objIframe = document.getElementById('iFrameContenedor')) ){
            objIframe = document.createElement('IFRAME');
           appendIframe = true;
           }      

  	objIframe.name 						= "iFrameContenedor";
  	objIframe.id	 						= "iFrameContenedor";
  	objIframe.src 						= sUrl
  	objIframe.width 					= "100%";
  	objIframe.height					= "100%";
  	objIframe.frameBorder 		= "none";
  	objIframe.overflow 				= overflow;
  	objIframe.style.overflow 	= overflow;
  	objIframe.style.display   = 'block';
	/**/
  }
  
  if(appendBackground){
	  document.body.appendChild(objDivBackground);
	}


	if(sUrl && appendContenedor){
	  document.body.appendChild(objDivContenedor);
	}

	if(sUrl && appendIframe){
	  document.getElementById('DivContenedor').appendChild(objIframe);
	}

	if(!sUrl && showElement){
	  document.getElementById(showElement).style.display = "block";
	  document.getElementById(showElement).style.zIndex  = zIndexElement;
	}
  //block();
	//window.scrollBy(0,-1000);
}

function ClosePopUpTipo2(Reload) {
//    carga_pag_ajax('../include/precarga_ajax.php', 'iFrameContenedor');

	if(document.getElementById('divBackground')   ) { document.getElementById('divBackground').style.display = 'none';    }
	if(document.getElementById('DivContenedor')   ) { document.getElementById('DivContenedor').style.display = 'none';    }
	if(document.getElementById('iFrameContenedor')) { 
	  document.getElementById('iFrameContenedor').style.display = 'none'; 
	  //carga_pag_ajax('../include/precarga_ajax.php', 'iFrameContenedor');
	}
	//unblock();
	if(Reload == 1) {
	  
	}
}	