var LastClick="";
var LastColor="white";

function ColorObj(id,vColor)
   {
      var temp_Obj = attach(id);
      if (LastClick!="") {LastClick.style.backgroundColor=LastColor;}
      LastClick=temp_Obj;
      LastColor=temp_Obj.style.backgroundColor;
      temp_Obj.style.backgroundColor=vColor;
   }

function setWorkspace(sHeader,sBody,sFooter,statusBarHeight)
   {
       var header=attach(sHeader);
       var body=attach(sBody);
       var footer=attach(sFooter);
       body.style.display='none';
       var h_offset=(header.style.height.replace("px","")*1+footer.style.height.replace("px","")*1+statusBarHeight*1);
       fullHeightResize(sBody,h_offset);
       body.style.display='block';
       transicion.call(body,0,1,1); 
   }

function DisplayNone(sObj)
   {
      try
      {
         var oobj = attach(sObj);   
         oobj.style.display='none';
      }
      catch(e){}
   }

function DisplayBlock(sObj)
   {
      try
      {
          var oobj = attach(sObj);   
          oobj.style.display='block';
      }
      catch(e){}
   }

function fullResize(sObj,h_offset,w_offset)
    { 
       try
       {
           fullHeightResize(sObj,h_offset);
           fullWidthResize(sObj,w_offset);
        } catch(e){}      
    } 

function fullHeightResize(sObj,h_offset)
    { 
       try
       {
           var htmlheight=f_clientHeight()-(h_offset*1);
           var oObj = attach(sObj);
           oObj.style.height = htmlheight + "px"; 
        } catch(e){}      
    } 

function fullWidthResize(sObj,w_offset)
    { 
       try
       {
           var htmlwidth=f_clientWidth()-(w_offset*1);
           var oObj = attach(sObj);
           oObj.style.width = htmlwidth + "px"; 
        } catch(e){}      
    } 

function f_clientWidth() 
{
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		window.document.documentElement ? window.document.documentElement.clientWidth : 0,
		window.document.body ? window.document.body.clientWidth : 0
	);
}

function f_clientHeight() 
{
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		window.document.documentElement ? window.document.documentElement.clientHeight : 0,
		window.document.body ? window.document.body.clientHeight : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) 
{
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function attach(id)
  {
     var obj;
     try
     {
        obj = window.document.all ? window.document.all[id] : window.document.getElementById(id);
     }
     catch(e){}
     return obj
  }

function set_opacity(div, value) 
{ 
    div.style.opacity = value; 
    div.style.MozOpacity = value; 
    div.style.KhtmlOpacity = value; 
    div.style.filter = 'alpha(opacity=' + value*100 + ')'; 
    div.style.zoom=1;
} 

var transicion=function(inicio,fin,segundos)
{ 
    var _this=this; 
    this.test=0; 
    if(_this.intervalo)clearInterval(_this.intervalo); 
    if(this.val && Math.abs(fin-_this.val)<0.01)return; 
    this.val=!this.val?inicio<1?inicio+.0001:inicio:this.val; 
    set_opacity(this, this.val); 
    this.pasos=(fin-inicio)/10; 
    this.pausa=segundos*1; 
    this.intervalo=setInterval( 
    function()
    { 
        if(_this.test>80 || Math.abs(fin-_this.val)<0.20)
        { 
          clearInterval(_this.intervalo); 
        } 
        _this.test++; 
        _this.val=_this.val+_this.pasos; 
        if(_this.val<=0.25)  
           {
              set_opacity(_this, 0); 
           }
        else 
           {
              if (_this.test>80)
                 {
                    set_opacity(_this, 100); 
                 }
              else
                 {
                    set_opacity(_this, _this.val); 
                 }       
           }
    },this.pausa); 
} 

function calcHeight(sID)
{
  try
     {
        var oH=attach(sID);
        var oW=attach(sID);
        var iH=oH.contentWindow.document.body.scrollHeight;
        var iW=oW.contentWindow.document.body.scrollWidth;
        var oObj=attach(sID);
        oObj.height=iH + 25;
     }
     catch(e) {}
}

function SubmitToURL(sUrl,sFrame)
   {
       window.document.form1.action=sUrl;
       window.document.form1.target=sFrame;
       window.document.form1.submit();
   }

