var urlBase = location.protocol + '//' + location.host + '/';
if(location.host == 'www'){
	var pos = location.pathname.indexOf('/', 1);
	urlBase += location.pathname.substr(1, pos);
}else if(/mktvirtual\.com\.br/.test(location.host)){
	urlBase += 'aprovacao/carmo/';
}

///////////////////////////////////=======================================
// funcao para mostrar DIV
var varAtivado = false
			
function mostraTBody(id){
	if ( id == varAtivado) {
		return
		}
	if (document.getElementById(id).style.display == '') {
		document.getElementById(id).style.display = 'none';
//		varAtivado = false;
	} else {
		document.getElementById(id).style.display = '';
		varAtivado ? document.getElementById(varAtivado).style.display = 'none' : null;
		varAtivado = id;
	}
}

///////////////////////////////////=======================================
// funcao para centralizar página	
function centraliza(w,h){
	largura = w;
	altura = h;
	if (parseInt(navigator.appVersion) >= 4) 
		window.moveTo((screen.width/2)-(largura/2+10),(screen.height/2)-(altura/2+20));
}

///////////////////////////////////=======================================
// funcao para alterar fotos em esquema de thumbs
function mudarImagem(no,leg) {
	    var agt=navigator.userAgent.toLowerCase();
		var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
					&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
					&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
		var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
	  if(is_ie){
		  var table = 1;
		  var tbody = 0;
		  var start = 0;
		  var incremento = 1;
	  }else if(is_nav){	  
		  var table = 3;
		  var tbody = 1;
		  var start = 1;
		  var incremento = 2;
	  }	
	
    var fotos = document.getElementById('fotos');
    var thumbs = document.getElementById('thumbs');
    var legenda = document.getElementById('legenda');

    for (var i=start; i<thumbs.childNodes.length; i=i+incremento) {
        if (thumbs.childNodes[i].firstChild) {
			if (thumbs.childNodes[i].firstChild.className == 'ativo') {
				var activeNr = thumbs.childNodes[i].className;
                activeNr = activeNr.substr(1,2);
            }
            thumbs.childNodes[i].firstChild.className = "";
        }
    }
	
    for (var i=start; i<thumbs.childNodes.length; i=i+incremento) {
        if (thumbs.childNodes[i].firstChild && thumbs.childNodes[i].className == "s" + no) {
            thumbs.childNodes[i].firstChild.className = 'ativo';
            var regEx = new RegExp (activeNr, 'gi');
            oldSrc = fotos.childNodes[table].childNodes[tbody].src;
            fotos.childNodes[table].childNodes[tbody].src = oldSrc.replace(regEx, no);
			legenda.innerHTML = leg;
        }
    }
	
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
