﻿function ltrim(palavra){
   for(i=0;i<palavra.length;i++){
      letra=palavra.charAt(i);
      if(letra!=' '){
         return(palavra.substring(i,palavra.length));
      }
   }
   return("");
}

function makeStatic() {

    //if (ie4) {object1.style.pixelTop=document.body.scrollTop+offsettop}
    if (ie4) {object1.style.pixelTop=document.documentElement.scrollTop+offsettop}
    else if (ns6) {document.all['object1'].style.top=window.pageYOffset+offsettop}
    else if (ns4) {eval(document.object1.top=eval(window.pageYOffset+offsettop));}

    if (ie4) {object2.style.pixelTop=document.documentElement.scrollTop+offsettop}
    else if (ns6) {document.all['object2'].style.top=window.pageYOffset+offsettop}
    else if (ns4) {eval(document.object2.top=eval(window.pageYOffset+offsettop));}
    
    setTimeout("makeStatic()",0);
}

function rtrim(palavra){
   for(i=palavra.length-1;i>=0;i--){
      letra=palavra.charAt(i);
      if(letra!=' '){
         return(palavra.substring(0,i+1));
      }
   }
   return("");
}

function trim(palavra){
   return(ltrim(rtrim(palavra)));
}

function formataMoeda(str){
	str = str + '';
	str = replaceAll(str, ".", ",");
	var antVirgula = "";
	cont = str.indexOf(",")-1;
	if (cont <= -1) {
		antVirgula = str; 
		posVirgula = "";
	}else{ 
		antVirgula = str.substring(0,cont+1);
		posVirgula = str.substring(cont+1,str.length);
		if ((posVirgula.length < 3) ){
			posVirgula = posVirgula + "0";
		}
	}
	auxValor = "";
	numVig = 0;	
	for (n=antVirgula.length-1;n>=0;n--){
		auxValor = antVirgula.charAt(n) + auxValor;
		if ((auxValor.length - numVig) % 3 == 0) {
			auxValor = "." + auxValor;
			numVig++;
		}
	}
	if (auxValor.substring(0,1) == '.') {
		auxValor = auxValor.substring(1,auxValor.length);
	}
	antVirgula = auxValor;
	if (cont <= -1){
		antVirgula = antVirgula + ",00";
	}else{
		if (posVirgula.length > 3){
			if (posVirgula.substring(3,4) >= 5){
				posVirgula = "," + (parseInt(posVirgula.substring(1,3),10) + 1);
			}
			else{
				posVirgula = posVirgula.substring(0,3);
			}
		}
	}
	str = antVirgula + posVirgula;
	return str;
}

function replaceAll(str, c1, c2) {
	temp = "" + str; 
	while (temp.indexOf(c1)>-1) {
		pos= temp.indexOf(c1);
		temp = "" + (temp.substring(0, pos) + c2 + 
		temp.substring((pos + c1.length), temp.length));
	}
	return temp;
}

// Compare two options within a list by VALUES
function compareOptionValues(a, b) { 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = parseInt( a.value, 36 );  
  var sB = parseInt( b.value, 36 );  
  return sA - sB;
}

// Compare two options within a list by TEXT
function compareOptionText(a, b) { 
  // Radix 10: for numeric values
  // Radix 36: for alphanumeric values
  var sA = 0;  
  var sB = 0;
  var r = 0;
  for (i=0; sA==sB; i++){
	sA = parseInt( a.text.substring(i,i+1), 36 );  
	sB = parseInt( b.text.substring(i,i+1), 36 );
	r = sA - sB;
  }
  return r;
}

// Dual list move function
function moveDualList( srcList, destList, moveAll ) {

  // Do nothing if nothing is selected
  if (  ( srcList.selectedIndex == -1 ) && ( moveAll == false )   )  {
    return;
  }
  newDestList = new Array( destList.options.length );

  var len = 0;

  for( len = 0; len < destList.options.length; len++ )   {
    if ( destList.options[ len ] != null )  {
      newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
    }
  }

  for( var i = 0; i < srcList.options.length; i++ )  { 
    if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) )    {
       newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
       len++;
    }
  }

  // Sort out the new destination list
  //newDestList.sort( compareOptionValues );   // BY VALUES
  //newDestList.sort( compareOptionText );   // BY TEXT

  // Populate the destination with the items from the new array
  for (var j = 0; j < newDestList.length; j++)  {
    if (newDestList[j] != null)  {
      destList.options[j] = newDestList[ j ];
    }
  }

  // Erase source list selected elements
  for(var i = srcList.options.length - 1; i >= 0; i-- )  { 
    if (srcList.options[i] != null && (srcList.options[i].selected == true || moveAll)){
       srcList.options[i] = null;
    }
  }

} // End of moveDualList()

function EmiteBoleto(){
		var w = window.open("", "UnibancoBoleto", "scrollbars=yes, resizable=no, toolbar=yes, location=no, menubar=no, left=0, top=0");
		
		window.document.forms[0].action = "https://cobrancaoff.unibanco.com.br/Boleto/UnibancoEmiteBoleto.asp";
		//window.document.forms[0].action = "http://localhost/seac/Unibanco.asp";
		window.document.forms[0].target = w.name;
		window.document.forms[0].submit();
		window.document.forms[0].action = "norma_compra.aspx";
		window.document.forms[0].target = this.window.name;
}

function MM_timelinePlay(tmLnName, myID) { //v1.2
  //Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Macromedia, Inc. All rights reserved.
  var i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;
  if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
  tmLn = document.MM_Time[tmLnName];
  if (myID == null) { myID = ++tmLn.ID; firstTime=true;}//if new call, incr ID
  if (myID == tmLn.ID) { //if Im newest
    setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
    fNew = ++tmLn.curFrame;
    for (i=0; i<tmLn.length; i++) {
      sprite = tmLn[i];
      if (sprite.charAt(0) == 's') {
        if (sprite.obj) {
          numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
          if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {//in range
            keyFrm=1;
            for (j=0; j<sprite.values.length; j++) {
              props = sprite.values[j]; 
              if (numKeyFr != props.length) {
                if (props.prop2 == null) sprite.obj[props.prop] = props[fNew-firstKeyFr];
                else        sprite.obj[props.prop2][props.prop] = props[fNew-firstKeyFr];
              } else {
                while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm]) keyFrm++;
                if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
                  if (props.prop2 == null) sprite.obj[props.prop] = props[keyFrm-1];
                  else        sprite.obj[props.prop2][props.prop] = props[keyFrm-1];
        } } } } }
      } else if (sprite.charAt(0)=='b' && fNew == sprite.frame) eval(sprite.value);
      if (fNew > tmLn.lastFrame) tmLn.ID = 0;
  } }
}

function MM_initTimelines() { //v4.0
    //MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.
    var ns = navigator.appName == "Netscape";
    var ns4 = (ns && parseInt(navigator.appVersion) == 4);
    var ns5 = (ns && parseInt(navigator.appVersion) > 4);
    var macIE5 = (navigator.platform ? (navigator.platform == "MacPPC") : false) && (navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4);
    document.MM_Time = new Array(1);
    document.MM_Time[0] = new Array(1);
    document.MM_Time["Timeline1"] = document.MM_Time[0];
    document.MM_Time[0].MM_Name = "Timeline1";
    document.MM_Time[0].fps = 15;
    document.MM_Time[0][0] = new String("sprite");
    document.MM_Time[0][0].slot = 1;
    if (ns4)
        document.MM_Time[0][0].obj = document["anuncio"];
    else if (ns5)
        document.MM_Time[0][0].obj = document.getElementById("anuncio");
    else
        document.MM_Time[0][0].obj = document.all ? document.all["anuncio"] : null;
    document.MM_Time[0][0].keyFrames = new Array(1, 90);
    document.MM_Time[0][0].values = new Array(2);
    if (ns5 || macIE5)
        document.MM_Time[0][0].values[0] = new Array("24px", "30px", "35px", "41px", "47px", "53px", "58px", "64px", "70px", "76px", "81px", "87px", "93px", "98px", "104px", "110px", "116px", "121px", "127px", "133px", "139px", "144px", "150px", "156px", "162px", "167px", "173px", "179px", "184px", "190px", "196px", "202px", "207px", "213px", "219px", "225px", "230px", "236px", "242px", "247px", "253px", "259px", "265px", "270px", "276px", "282px", "288px", "293px", "299px", "305px", "311px", "316px", "322px", "328px", "333px", "339px", "345px", "351px", "356px", "362px", "368px", "374px", "379px", "385px", "391px", "396px", "402px", "408px", "414px", "419px", "425px", "431px", "437px", "442px", "448px", "454px", "460px", "465px", "471px", "477px", "482px", "488px", "494px", "500px", "505px", "511px", "517px", "523px", "528px", "534px");
    else
        document.MM_Time[0][0].values[0] = new Array(24,30,35,41,47,53,58,64,70,76,81,87,93,98,104,110,116,121,127,133,139,144,150,156,162,167,173,179,184,190,196,202,207,213,219,225,230,236,242,247,253,259,265,270,276,282,288,293,299,305,311,316,322,328,333,339,345,351,356,362,368,374,379,385,391,396,402,408,414,419,425,431,437,442,448,454,460,465,471,477,482,488,494,500,505,511,517,523,528,534);
    document.MM_Time[0][0].values[0].prop = "left";
    if (ns5 || macIE5)
        document.MM_Time[0][0].values[1] = new Array("17px", "20px", "22px", "25px", "28px", "31px", "33px", "36px", "39px", "42px", "44px", "47px", "50px", "53px", "55px", "58px", "61px", "64px", "66px", "69px", "72px", "75px", "77px", "80px", "83px", "86px", "88px", "91px", "94px", "97px", "99px", "102px", "105px", "107px", "110px", "113px", "116px", "118px", "121px", "124px", "127px", "129px", "132px", "135px", "138px", "140px", "143px", "146px", "149px", "151px", "154px", "157px", "160px", "162px", "165px", "168px", "171px", "173px", "176px", "179px", "181px", "184px", "187px", "190px", "192px", "195px", "198px", "201px", "203px", "206px", "209px", "212px", "214px", "217px", "220px", "223px", "225px", "228px", "231px", "234px", "236px", "239px", "242px", "245px", "247px", "250px", "253px", "256px", "258px", "261px");
    else
        document.MM_Time[0][0].values[1] = new Array(17,20,22,25,28,31,33,36,39,42,44,47,50,53,55,58,61,64,66,69,72,75,77,80,83,86,88,91,94,97,99,102,105,107,110,113,116,118,121,124,127,129,132,135,138,140,143,146,149,151,154,157,160,162,165,168,171,173,176,179,181,184,187,190,192,195,198,201,203,206,209,212,214,217,220,223,225,228,231,234,236,239,242,245,247,250,253,256,258,261);
    document.MM_Time[0][0].values[1].prop = "top";
    if (!ns4) {
        document.MM_Time[0][0].values[0].prop2 = "style";
        document.MM_Time[0][0].values[1].prop2 = "style";
    }
    document.MM_Time[0].lastFrame = 90;
    for (i=0; i<document.MM_Time.length; i++) {
        document.MM_Time[i].ID = null;
        document.MM_Time[i].curFrame = 0;
        document.MM_Time[i].delay = 2500/document.MM_Time[i].fps;
    }
}

