// JavaScript Document
//////////////////////////////////////////////////////////
/////////////////funcao p/ jump menu//////////////////////
//////////////////////////////////////////////////////////
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/////////////////////////////////////////////////////////////////
//Função preload das imagens (rollover e rollout) - home DZ Comex
/////////////////////////////////////////////////////////////////

//botao institucional
botao_inst_on = new Image(97,15)
botao_inst_on.src = "imgs/bt_inst_on.gif"
botao_inst_off = new Image(97,15)
botao_inst_off.src = "imgs/bt_inst_off.gif"

//botao missao
botao_miss_on = new Image(51,15)
botao_miss_on.src = "imgs/bt_miss_on.gif"
botao_miss_off = new Image(51,15)
botao_miss_off.src = "imgs/bt_miss_off.gif"

//botao visao
botao_visa_on = new Image(41,15)
botao_visa_on.src = "imgs/bt_visa_on.gif"
botao_visa_off = new Image(41,15)
botao_visa_off.src = "imgs/bt_visa_off.gif"

//botao valores
botao_valo_on = new Image(57,15)
botao_valo_on.src = "imgs/bt_valo_on.gif"
botao_valo_off = new Image(57,15)
botao_valo_off.src = "imgs/bt_valo_off.gif"

function centerPopup(mypage, myname, w, h, scroll, resize) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable='+resize+',scrollbars='+scroll
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

function urlDecode(string, overwrite){
    if(!string || !string.length){
        return {};
    }
    var obj = {};
    var pairs = string.split('&');
    var pair, name, value;
    var lsRegExp = /\+/g;
    for(var i = 0, len = pairs.length; i < len; i++){
        pair = pairs[i].split('=');
        name = unescape(pair[0]);
        value = unescape(pair[1]).replace(lsRegExp, " ");
        //value = decodeURIComponent(pair[1]).replace(lsRegExp, " ");
        if(overwrite !== true){
            if(typeof obj[name] == "undefined"){
                obj[name] = value;
            }else if(typeof obj[name] == "string"){
                obj[name] = [obj[name]];
                obj[name].push(value);
            }else{
                obj[name].push(value);
            }
        }else{
            obj[name] = value;
        }
    }
    return obj;
}


function jsGet(param)
{
	var wl = window.location.href;
	var params = urlDecode(wl.substring(wl.indexOf("?")+1));
	return(params[param]);
}

function excluiImagem(id_categoria,id_imagem)
{	
confirma = confirm('Tem certeza que deseja excluir esta imagem?');
	if(confirma)
	{
		location.href='fotos_visualizar.php?remover=imagem&id_categoria='+id_categoria+'&id_imagem='+id_imagem;
	}else{
			return false;
	}
}

function bloqueiaComment(cod){

		document.getElementById('acao').value = "bloqueiaComment";
		document.getElementById('id_comentario').value = cod;
		document.comentarios.action = 'comentarios_visualizar.php';
		//location.href='fotos_visualizar.php?&id_imagem='+codImagem+'&acao=remover';
		document.comentarios.submit();

}

function removeComment(cod){

		document.getElementById('acao').value = "removeComment";
		document.getElementById('id_comentario').value = cod;
		document.comentarios.action = 'comentarios_visualizar.php';
		//location.href='fotos_visualizar.php?&id_imagem='+codImagem+'&acao=remover';
		document.comentarios.submit();

}

function addVideo(){

	var totalCampos = parseInt(document.getElementById('totalAp').value);
	var idAtual = parseInt(totalCampos + 1);

	var string = '<table width="100%" cellspacing="1" cellpadding="0" id="ap'+idAtual+'" class="formulario">';
	string += 		'<tr>';
	string += 			'<td class="branco">&nbsp;</td>';
	string += 			'<td class="branco">&nbsp;</td>';
	string += 		'</tr>';
	string += 		'<tr>';
	string += 			'<th scope="row" width="120">Título</th>';
	string += 			'<td><input name="titulo[]" type="text" id="titulo[]" style="width:300px; "></td>';
	string += 		'</tr>';
	string += 		'<tr>';
	string += 			'<th scope="row" width="120">Descrição</th>';
	string += 			'<td><textarea name="descricao[]" id="descricao[]" rows="6" style="width:300px; "></textarea></td>';
	string += 		'</tr>';	
	string += 		'<tr>';
	string += 			'<th scope="row" width="120">Link do YouTube</th>';
	string += 			'<td><textarea name="url_video[]" id="url_video[]" rows="6" style="width:300px; "></textarea></td>';
	string += 		'</tr>';
	string += 		'<tr>';
	string += 			'<th scope="row">Icone do Youtube</th>'
	string += 			'<td><input name="arquivo[]" type="file" id="arquivo" style="width:306px; "/></td>';
	string += 		'</tr>';
	string += '</table>';

	document.getElementById('totalAp').value = idAtual;
	var campo = document.getElementById('ap');
	campo.innerHTML =  campo.innerHTML += string;
	//campo.insertAdjacentHTML('BeforeEnd',string);
}

function addImagem(){

	var totalCampos = parseInt(document.getElementById('totalAp').value);
	var idAtual = parseInt(totalCampos + 1);

	var string = '<table width="100%" cellspacing="1" cellpadding="0" id="ap'+idAtual+'" class="formulario">';
	string += 	'<tr>';
    string +=		'<th scope="row" width="120">Imagem</th>';
    string +=		'<td><input name="arquivo[]" type="file" id="arquivo[]" size="35" style="float:left"><a href="javascript:removerCampo(\'ap'+idAtual+'\');"><img src="images/icone_excluir2.gif" border="0" alt="Excluir Imagem" style="float:right" /></a></td>';
    string +=    '</tr>';
	string += '</table>';

	document.getElementById('totalAp').value = idAtual;
	var campo = document.getElementById('ap');
	campo.innerHTML =  campo.innerHTML += string;
	//campo.insertAdjacentHTML('BeforeEnd',string);
}
function removerCampo(idCampo){

		var campo = document.getElementById(idCampo);
		var tamanho = campo.rows.length;

		for(var i=0; i < tamanho; i++){
			campo.deleteRow(0);
		}

	navegador = /msie/i.test(navigator.userAgent);

	if(navegador == false){
		campo.innerHTML = ""
	}

}

$(document).ready(function() {
	
	$('.botao').click(function() {
	
		$.ajax(
			{

				type: "POST",
				url: "get_dados.php",
				dataType: "html",
				data: "op="+$(this).get(0).id,
				success: function(msg){
							// limpa o span para nova entrada
							$("#resultado").html(msg);
						 },
				beforeSend: function(){
					// define a cor da fonte para o span
					//$("#loading_ajax").css({ color: "black" });
					// escreve o html dentro do span
					$("#loading_ajax").html("<img src=\"imgs/loading.gif\"/> Carregando ...").fadeIn('slow');
				}
			}
		)
	}
  );

});

<!-- 
function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else 
		countfield.value = maxlimit - field.value.length;
}
// -->