var popups=new Array();var idsPopups=new Array();var forcedURL;var agent=navigator.appVersion;var is_ie=false;var is_ns=false;var is_fox=false;var is_opera=false;var is_chrome=false;if(agent.indexOf("Chrome")>0) is_chrome=true;else if(agent.indexOf("Gecko")>0){if(agent.indexOf("Netscape")>0) is_ns=true;else if(agent.indexOf("Firefox")>0) is_fox=true;}if(agent.indexOf("MSIE")>0){if(agent.indexOf("Opera")>0) is_opera=true;else is_ie=true;}function setCookie(name,value,days){if(days){var date = new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires = "; expires="+date.toGMTString();}else var expires = "";var ck = name+"="+escape(value)+expires+"; path=/";document.cookie = ck;}function getCookie(name){var nameEQ = name + "=";var ca = document.cookie.split(';');for(var i=0;i<ca.length;i++){var c = ca[i];while(c.charAt(0)==' ') c = c.substring(1,c.length);if(c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length,c.length));}return null;}function deleteCookie(name){setCookie(name,"",-1);}function getParametroURL(nome){var result;if(forcedURL){result=forcedURL.replace("?","&");}else{result=location.search.replace("?","&");if(result=="" || result.indexOf(nome+"=")<0) result=parent.location.search.replace("?","&");if(result=="" || result.indexOf(nome+"=")<0) result=parent.parent.location.search.replace("?","&");if(result=="" || result.indexOf(nome+"=")<0) return "";}result+="&";while(result.indexOf("%26")>0) result=result.replace("%26","&");while(result.indexOf("%20")>0) result=result.replace("%20"," ");if(result.indexOf("&"+nome+"=")<0) return "";result=result.substring(result.indexOf("&"+nome+"=")+nome.length+2,result.indexOf("&",result.indexOf("&"+nome+"=")+nome.length+2));return result;}function exibePopup(id,url,x,y,width,height,scrollbars,theOpener){if(!top.totem && top.window.opener){top.window.opener.exibePopup(id,url,x,y,width,height,scrollbars,theOpener);return;}fechaPopup(id);if(x=="C" || x=="center") x=(screen.width-width)/2;if(y=="C" || y=="center") y=(screen.height-height)/2;jan=window.open(url,"","width="+width+",height="+height+",titlebar=no,resizable=yes,scrollbars="+scrollbars+",status=no,left="+x+",top="+y);if(theOpener) jan.opener=theOpener;jan.focus();try{if(top.totem && top.totem.popups) top.totem.popups[id]=jan;if(top.totem && top.totem.idsPopups) top.totem.idsPopups[top.totem.idsPopups.length]=id;}catch(ex){}return;if(!ie5&&!ns6) window.open(url,"","width=width,height=height,scrollbars=1");else{document.getElementById(id).style.display='';if(width!=-1) document.getElementById(id).style.width=width;if(height!=-1) document.getElementById(id).style.height=height;if(x.indexOf("+")==0) x=x.substring(1);if(y.indexOf("+")==0) y=y.substring(1);document.getElementById(id).style.left=x;document.getElementById(id).style.top=ns6? window.pageYOffset*1+parseInt(y) : document.body.scrollTop*1+parseInt(y);document.getElementById("cframe").src=url;document.getElementById(id).style.left=document.body.scrollWidth-width;}}function fechaPopup(id){try{if(top.totem && top.totem.popups[id]!=null && top.totem.popups[id]){top.totem.popups[id].close();top.totem.popups[id]=null;}return;if(document.getElementById(id)) document.getElementById(id).style.display="none";else if(parent.document.getElementById(id)) parent.document.getElementById(id).style.display="none";}catch(ex){}}function fechaTodosPopups(){if(!top.totem) return;if(!top.totem.idsPopups) return;for(var i=0; i<top.totem.idsPopups.length; i++){fechaPopup(top.totem.idsPopups[i]);}top.totem.idsPopups=new Array();top.totem.popups=new Array();}function criaPopup(id){document.write("<div align=right id='"+id+"' style='position:absolute;background-color:yellow;cursor:hand;display:none' onMousedown='fechaPopup(\""+id+"\")'>\n");document.write("  <iframe id=\"cframe\" src=\"\" width=100% height=100%></iframe>\n");document.write("</div>\n");}function criaCaixa(id,style,url,noHideOnClick){if(!style) style="";if(!url) url="";document.write("<div align=left id='"+id+"' style='position:absolute;background-color:yellow;display:none;padding:3;"+style+"' "+(noHideOnClick?"":"onMousedown='ocultaCaixa(\""+id+"\")'")+">\n");document.write("  <iframe id=\"cframe"+id+"\" name=\"cframe"+id+"\" src=\""+url+"\" width=100% height=100% frameborder=0 style=\"border:none 0px;display:none\"></iframe>\n");document.write("</div>\n");}function ocultaCaixa(id){if(document.getElementById(id)) document.getElementById(id).style.display="none";else if(parent.document.getElementById(id)) parent.document.getElementById(id).style.display="none";}function exibeCaixa(id,url,texto,x,y,width,height){document.getElementById(id).style.display='';if(width!=-1) document.getElementById(id).style.width=width;if(height!=-1) document.getElementById(id).style.height=height;if(x<0){document.getElementById(id).style.right=-x;}else{document.getElementById(id).style.left=x;}document.getElementById(id).style.top=y;if(url) document.getElementById("cframe"+id).src=url;if(texto) document.getElementById(id).innerHTML=texto;else document.getElementById("cframe"+id).style.display="";}function replaceAll(texto,str1,str2){if(!texto) return texto;if(texto.indexOf(str1)<0) return texto;var pos=0;while((pos=texto.indexOf(str1,pos))>=0){texto=texto.substring(0,pos)+str2+texto.substring(pos+str1.length);pos+=str2.length;}return texto;}function translate(texto,str1,str2){for(var i=0; (i<str1.length && i<str2.length); i++){var pos=0;while((pos=texto.indexOf(str1.charAt(i),pos))>=0){texto=texto.replace(str1.charAt(i),str2.charAt(i));pos++;}}return texto;}function limpaTexto(texto,preserveSpecial){texto=texto.toUpperCase();if(!preserveSpecial){while(texto.indexOf(".")>=0) texto=texto.replace(".", "");while(texto.indexOf("/")>=0) texto=texto.replace("/", "");while(texto.indexOf("-")>=0) texto=texto.replace("-", "");}while(texto.indexOf("Ã")>=0) texto=texto.replace("Ã","A");while(texto.indexOf("Á")>=0) texto=texto.replace("Á","A");while(texto.indexOf("À")>=0) texto=texto.replace("À","A");while(texto.indexOf("Â")>=0) texto=texto.replace("Â","A");while(texto.indexOf("Ê")>=0) texto=texto.replace("Ê","E");while(texto.indexOf("É")>=0) texto=texto.replace("É","E");while(texto.indexOf("Î")>=0) texto=texto.replace("Î","I");while(texto.indexOf("Í")>=0) texto=texto.replace("Í","I");while(texto.indexOf("Ó")>=0) texto=texto.replace("Ó","O");while(texto.indexOf("Ô")>=0) texto=texto.replace("Ô","O");while(texto.indexOf("Õ")>=0) texto=texto.replace("Õ","O");while(texto.indexOf("Û")>=0) texto=texto.replace("Û","U");while(texto.indexOf("Ú")>=0) texto=texto.replace("Ú","U");while(texto.indexOf("Ç")>=0) texto=texto.replace("Ç","C");return texto;}function retiraTags(texto){if(texto.indexOf('<')<0) return texto;var inTag=false;var result="";for(var i=0; i<texto.length; i++){if(texto.charAt(i)=='<') inTag=true;else if(texto.charAt(i)=='>') inTag=false;else if(!inTag) result+=texto.charAt(i);}return result;}function money(valor,decimalSeparator){if(!decimalSeparator) decimalSeparator=",";valor+="";while(valor.length<3) valor="0"+valor;valor=valor.substring(0, valor.length-2)+decimalSeparator+valor.substring(valor.length-2);return valor;}function lpad(texto,len,ch){if(!ch) ch=" ";while(texto.length<len) texto=ch+texto;return texto;}function rpad(texto,len,ch){if(!ch) ch=" ";while(texto.length<len) texto=texto+ch;return texto;}function trim(str, chars){return ltrim(rtrim(str, chars), chars);}function ltrim(str, chars){if(!chars) chars="";chars = chars || "\\s";return str.replace(new RegExp("^[" + chars + "]+", "g"), "");}function rtrim(str, chars){if(!chars) chars="";chars = chars || "\\s";return str.replace(new RegExp("[" + chars + "]+$", "g"), "");}function htmlEncode(source){var result='';for(var i=0; i<source.length; i++){if(source.charCodeAt(i)>=128) result+='&#'+source.charCodeAt(i)+';';else result+=source.charAt(i);}return result;}function encode_utf8(s){return unescape(encodeURIComponent(s));}function decode_utf8(s){return decodeURIComponent(escape(s));}function nvl(valor, padrao){if(!valor) return padrao;return valor;}function funcname(f) {var s = f.toString().match(/function (\w*)/)[1];if((s == null) || (s.length==0)) return "anonymous";return s;}function stacktrace() {var s = window.location.pathname.substring(window.location.pathname.lastIndexOf('/')+1);for(var a = arguments.caller; a !=null; a = a.caller) {s += "->"+funcname(a.callee) + "\n";if(a.caller == a) {s+="*"; break;}}return s;}function getAbsoluteX(elementID,relative){var result=0;var el=document.getElementById(elementID);if(el.offsetParent){while(el.offsetParent){if(relative && (getStyle(el,"position")=='relative' || getStyle(el,"position")=='absolute')) break;result += el.offsetLeft;el = el.offsetParent;}}else if(el.x) result += el.x;return result;}function getAbsoluteY(elementID,relative){var result=0;var el=document.getElementById(elementID);if(el.offsetParent){while(el.offsetParent){if(relative&&(getStyle(el, "position")=='relative'||getStyle(el, "position")=='absolute')) break;result += el.offsetTop;el = el.offsetParent;}}else if(el.y) result += el.y;return result;}function getAbsoluteX2(element){var result=0;var el=element;result=el.offsetLeft;while(el.parentNode){el=el.parentNode;if(el.offsetLeft) result+=el.offsetLeft;}return result;}function getAbsoluteY2(element){var result=0;var el=element;result=el.offsetTop;while(el.parentNode){el=el.parentNode;if(el.offsetTop){result+=el.offsetTop;}}return result;}function getScrollY(elementID){var result=0;var el=document.getElementById(elementID);if(el.parentNode){while(el){if(el.style && getStyle(el,"overflow")=='auto') result += el.scrollTop;el = el.parentNode;}}return result;}function getScrollX(elementID){var result=0;var el=document.getElementById(elementID);if(el.parentNode){while(el){if(el.style && getStyle(el,"overflow")=='auto') result += el.scrollLeft;el = el.parentNode;}}return result;}function getStyle(el,styleProp){var result;if(el.currentStyle) result=el.currentStyle[styleProp];else if(window.getComputedStyle) result=document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);return result;}function cursorWait(id){document.body.style.cursor='wait';document.getElementById(id).style.cursor='wait';}function cursorDefault(id){document.body.style.cursor='default';document.getElementById(id).style.cursor='pointer';}function resizeDiv(container,content,pos){var el=document.getElementById(content);var elPai=document.getElementById(container);if(!el) return;if(!elPai) return;if(pos=='top') elPai.style.paddingTop=el.offsetHeight;if(pos=='bottom') elPai.style.paddingBottom=el.offsetHeight;if(pos=='left') elPai.style.paddingLeft=el.offsetWidth;if(pos=='right') elPai.style.paddingRight=el.offsetWidth;}function verticalCenter(){var divs=document.getElementsByTagName("div");for(var i=0; i<divs.length; i++){if(divs[i].className.indexOf("verticalCenter")>=0){var parent=divs[i].parentNode;divs[i].style.top=(parent.offsetHeight-divs[i].offsetHeight)/2;}}}function getIFrameDocument(ifr){var doc=null;if(ifr.contentDocument){doc = ifr.contentDocument;}else if(ifr.contentWindow){doc = ifr.contentWindow.document;}else if(ifr.document){doc = ifr.document;}return doc;}function getCaretPos(edt){var iCaretPos=0;if(document.selection){edt.focus();var oSel = document.selection.createRange();oSel.moveStart('character', -edt.value.length);iCaretPos = oSel.text.length;}else if(edt.selectionStart || edt.selectionStart == '0') iCaretPos = edt.selectionStart;return iCaretPos;}function setCaretPos(edt, pos){if(document.selection){edt.focus();var oSel = document.selection.createRange();oSel.moveStart('character', -edt.value.length);oSel.moveStart('character', pos);oSel.moveEnd('character', 0);oSel.select();}else if(edt.selectionStart || edt.selectionStart == '0'){edt.selectionStart = pos;edt.selectionEnd = pos;edt.focus();}}/*//Calcula a semana de uma data (ano*10+semana)function getWeekId(dt){var onejan = new Date(dt.getFullYear(), 0, 1);return dt.getFullYear() * 100 + Math.ceil((((dt - onejan) / 86400000) + onejan.getDay() + 1) / 7); //Isso é muito legal. Veja: http://javascript.about.com/library/blweekyear.htm}function getWeekStartDate(weekId){var year = Math.floor(weekId / 100);var week = weekId - year * 100;var onejan = new Date(year, 0, 1);return new Date((onejan - (onejan.getDay() * 86400000)) + (week * 7 * 86400000));}function getWeekEndDate(weekId){var year = Math.floor(weekId / 100);var week = weekId - year * 100;var onejan = new Date(year, 0, 1);return new Date((onejan - (onejan.getDay() * 86400000)) + ((week + 1) * 7 * 86400000));}*/function getAbsWeek(dt){var onejan = new Date(1970, 0, 1);return Math.ceil((((dt - onejan) / 86400000) + onejan.getDay() + 1) / 7); //Isso é muito legal. Veja: http://javascript.about.com/library/blweekyear.htm}function getAbsWeekStartDate(week){var onejan = new Date(1970, 0, 1);return new Date((onejan - ((onejan.getDay()-1) * 86400000)) + ((week-1) * 7 * 86400000));}
