function openLocalizacao(){
	window.open("../files/locais/localizacao.jpg",null,"height=500,width=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");	
}

function openCalendario(id){
	//h = screen.height-10;
	//w = screen.width-10;
	h = 500;
	w = 700;
	var win = window.open("pages/cursos/popCalendario.php?idLocal="+id,null,"height="+h+",width="+w+",status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes");
}	

function abrirBrowseEuropeu(){
	window.open("http://downloadcentre.omron-industrial.com/dlc3/home.do?language=pt&amp;country=pt", "downloadcentre", "dependent=yes,toolbar=no,status=yes,menubar=no,location=no,personalbar=no,hotkeys=no,scrollbars=auto,resizable=no,width=900,height=700", false);
	
	//var popup = window.open("externas.php?url=http://downloadcentre.omron-industrial.com/dlc3/search.do&metodo=POST&campo=utf8Field(query)", "externo", "toolbar=no,status=yes,menubar=no,location=no,personalbar=no,hotkeys=no,scrollbars=auto,resizable=no,width=900,height=700");
}

function download(lugar, tipo, caminho, arquivo){
	switch(lugar){
		case "browse":
			var url = '../../download.php?tipo='+tipo+'&file='+arquivo+'&caminho='+caminho;
			document.getElementById('branca').src = url;
			break;
		
		case "pagina":
			var url = 'download.php?tipo='+tipo+'&file='+arquivo+'&caminho='+caminho;
			document.getElementById('branca').src = url;
			break;
	}
}

function abrirBrowse(cat, subcat, fami, prod){
	window.open('pages/produtos/browse.php?idCategoria='+cat+'&idSub='+subcat+'&idFam='+fami+'&idProd='+prod+'', 'browse', 'dependent=yes,toolbar=no,status=yes,menubar=no,location=no,personalbar=no,hotkeys=no,scrollbars=auto,resizable=no,width=900,height=700');
}

function puxarCidade(cidade, page, menu){
	location="internas.php?pagina="+page+"&menu="+menu+"&uf="+cidade;
}
function linkBrowse(categoria, subcat, fami, prod){
	
	//id categoria
	if ( categoria )	categoria = '&idCategoria='+ categoria;
	else				categoria = '';
	
	//id subcategoria
	if ( subcat )	subcat = '&idSub='+ subcat;
	else			subcat = '';
	
	//id familia
	if ( fami )	fami = '&idFam='+ fami;
	else		fami = '';
	
	//id produto
	if ( prod )	prod = '&idProd='+ prod;
	else		prod = '';
	
	window.location="browse.php?" + categoria + subcat + fami + prod;
}

function linkPage(pagina, categoria, subcat, fami, prod, menu)
{	
	if( pagina )	pagina = 'pagina='+ pagina;
	else			pagina = '';
	
	//id categoria
	if ( categoria )	categoria = '&idCategoria='+ categoria;
	else				categoria = '';
	
	//id subcategoria
	if ( subcat )	subcat = '&idSub='+ subcat;
	else			subcat = '';
	
	//id familia
	if ( fami )	fami = '&idFam='+ fami;
	else		fami = '';
	
	//id produto
	if ( prod )	prod = '&idProd='+ prod;
	else		prod = '';

	//a variável menu indica qual link do menu a esquerda do site pertence
	if ( menu )	menu = '&menu='+ prod;
	else		menu = '';
	
	local = "internas.php?" + pagina + categoria + subcat + fami + prod + menu;
	window.location.href = local;
}

function linkPageInterno(pagina, menu){
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu){ 
		if(menu.toString().indexOf('z') != -1)
		{
			menu = "&menu="+menu+"&idEdicao="+menu.substr(3,menu.length); 
		}
		else
		{
			menu = "&menu="+menu;	
		}
		//menu = "&menu="+menu;	
	}else{ 
		menu = "&menu=0";
	}
	
	url = "../site/internas.php?pagina="+pagina+menu;

	window.location.href = url;
}

function linkPageNoticias(pagina, noticia, menu){
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu)	menu = "&menu="+menu; 
	else 		menu = "&menu=0";
	
	//indica qual notícia deverá ser exibida
	if(noticia) noticia = "&idNoticia= " + noticia;
	else 		noticia = "";
	
	url = "internas.php?pagina=" + pagina + noticia + menu;
	window.location.href = url;
}

function linkPageCursos(pagina, curso, menu){
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu)	menu = "&menu="+menu; 
	else 		menu = "&menu=0";
	
	//indica qual curso deverá ser exibida
	if(curso) curso = "&idCurso= " + curso;
	else 		curso = "";
	
	url = "internas.php?pagina=" + pagina + curso + menu;
	window.location.href = url;
}

function linkPageEventos(pagina, evento, menu){ 
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu)	menu = "&menu="+menu; 
	else 		menu = "&menu=0";
	
	//indica qual evento deverá ser exibido
	if(evento) evento = "&idEventoFoto= " + evento;
	else 		evento = "";
	
	url = "internas.php?pagina=" + pagina + evento + menu;
	window.location.href = url;
}

function linkPageAplicacoes(pagina, evento, menu){ 
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu)	menu = "&menu="+menu; 
	else 		menu = "&menu=0";
	
	//indica qual evento deverá ser exibido
	if(evento) evento = "&idAplicacao= " + evento;
	else 		evento = "";
	
	url = "internas.php?pagina=" + pagina + evento + menu;
	window.location.href = url;
}

function linkPageGalerias(pagina, galeria, menu){ 
	
	//a variável menu indica qual link do menu a esquerda do site pertence
	if(menu)	menu = "&menu="+menu; 
	else 		menu = "&menu=0";
	
	//indica qual evento deverá ser exibido
	if(galeria) galeria = "&idGaleria= " + galeria;
	else 		galeria = "";
	
	url = "internas.php?pagina=" + pagina + galeria + menu;
	window.location.href = url;
}

//funções do admin
//sessão produtos

function AdicionaBrochures() {

	var broc = document.getElementById('brochures');
	var qtdBroc = document.getElementById('QtdBroch');
	var ids = document.getElementById('idsBroch');
	
	if(broc.options[broc.options.selectedIndex].value != ""){
		ObjTbBroch = document.getElementById('TbBrochures');
		var LinhasBroch = ObjTbBroch.rows;
		
		Indice = qtdBroc.value;
		var tr = ObjTbBroch.insertRow(LinhasBroch.length);
		
		qtdBroc.value = parseInt(qtdBroc.value) + 1;
		var td0 = tr.insertCell(0);
		
		td0.innerHTML = broc.options[broc.options.selectedIndex].text + "&nbsp;&nbsp;&nbsp;" + "<img src=\"images/bt_excluirM.gif\" height=\"12\" alt=\"Excluir Brochure\" OnClick=\"javascript:ExcluiLinha('TbBrochures',this.parentNode.parentNode.rowIndex);\">";;
		document.getElementById('idsBroch').value += "," + document.getElementById('brochures').options[document.getElementById('brochures').options.selectedIndex].value;
		newTask('buscaBrochures',1);
	}else{
		alert("Por favor, selecione uma categoria!");
	}
}

function AdicionaIdiomas() {
	
	var idioma = document.getElementById('idiomas');
	var qtdIdioma = document.getElementById('QtdIdiomas');
	var ids = document.getElementById('idsIdioma');
	
	if(idioma.options[idioma.options.selectedIndex].value != ""){
		ObjTbIdioma = document.getElementById('TbIdiomas');
		var LinhasIdioma = ObjTbIdioma.rows;
		
		Indice = qtdIdioma.value;
		var tr = ObjTbIdioma.insertRow(LinhasIdioma.length);
		
		qtdIdioma.value = parseInt(qtdIdioma.value) + 1;
		var td0 = tr.insertCell(0);
		
		td0.innerHTML = idioma.options[idioma.options.selectedIndex].text + "&nbsp;&nbsp;&nbsp;" + "<input type='file' name='arquivo"+ Indice + "' id='arquivo"+ Indice + ">&nbsp;&nbsp;<img src=\"images/bt_excluirM.gif\" height=\"12\" alt=\"Excluir Idioma\" OnClick=\"javascript:ExcluiLinha('TbIdiomas',this.parentNode.parentNode.rowIndex);\">";;
		
		document.getElementById('idsIdioma').value += "," + document.getElementById('idiomas').options[document.getElementById('idiomas').options.selectedIndex].value;
		newTask('buscaIdiomas',1);
	}else{
		alert("Por favor, selecione um idioma!");
	}
}

function AdicionaSoftwares() {

	var soft = document.getElementById('softwares');
	var qtdSoft = document.getElementById('QtdSoft');
	var ids = document.getElementById('idsSoft');
	
	if(soft.options[soft.options.selectedIndex].value != ""){
		ObjTbSoft = document.getElementById('TbSoftwares');
		var LinhasSoft = ObjTbSoft.rows;
		
		Indice = qtdSoft.value;
		var tr = ObjTbSoft.insertRow(LinhasSoft.length);
		
		qtdSoft.value = parseInt(qtdSoft.value) + 1;
		var td0 = tr.insertCell(0);
		
		td0.innerHTML = soft.options[soft.options.selectedIndex].text + "&nbsp;&nbsp;&nbsp;" + "<img src=\"images/bt_excluirM.gif\" height=\"12\" alt=\"Excluir Software\" OnClick=\"javascript:ExcluiLinha('TbSoftwares',this.parentNode.parentNode.rowIndex);\">";;
		document.getElementById('idsSoft').value += "," + document.getElementById('softwares').options[document.getElementById('softwares').options.selectedIndex].value;
		newTask('buscaSoftwares',1);
	}else{
		alert("Por favor, selecione um software!");
	}
}

function AdicionaManuais() {

	var man = document.getElementById('manuais');
	var qtdMan = document.getElementById('QtdMan');
	var ids = document.getElementById('idsMan');
	
	if(man.options[man.options.selectedIndex].value != ""){
		ObjTbMan = document.getElementById('TbManuais');
		var LinhasMan = ObjTbMan.rows;
		
		Indice = qtdMan.value;
		var tr = ObjTbMan.insertRow(LinhasMan.length);
		
		qtdMan.value = parseInt(qtdMan.value) + 1;
		var td0 = tr.insertCell(0);
		
		td0.innerHTML = man.options[man.options.selectedIndex].text + "&nbsp;&nbsp;&nbsp;" + "<img src=\"images/bt_excluirM.gif\" height=\"12\" alt=\"Excluir Manuais\" OnClick=\"javascript:ExcluiLinha('TbManuais',this.parentNode.parentNode.rowIndex);\">";;
		document.getElementById('idsMan').value += "," + document.getElementById('manuais').options[document.getElementById('manuais').options.selectedIndex].value;
		newTask('buscaManuais',1);
	}else{
		alert("Por favor, selecione um manual!");
	}
}




function ExcluiLinha(obj,i) {
	
	switch(obj){
		case 'TbBrochures':
			var ids = document.getElementById('idsBroch').value;
			vetId = ids.split(",");
			
			vetId[i] = "";
			document.getElementById('idsBroch').value = 0;
	
			for(j=1; j<vetId.length; j++){
				if(vetId[j] != ""){
					document.getElementById('idsBroch').value += ","+vetId[j];
				}
			}
			newTask('buscaBrochures',1);
			break;
			
		case 'TbSoftwares':
			var ids = document.getElementById('idsSoft').value;
			vetId = ids.split(",");
			
			vetId[i] = "";
			document.getElementById('idsSoft').value = 0;
	
			for(j=1; j<vetId.length; j++){
				if(vetId[j] != ""){
					document.getElementById('idsSoft').value += ","+vetId[j];
				}
			}
			newTask('buscaSoftwares',1);
			break;
		
		case 'TbManuais':
			var ids = document.getElementById('idsMan').value;
			vetId = ids.split(",");
			
			vetId[i] = "";
			document.getElementById('idsMan').value = 0;
	
			for(j=1; j<vetId.length; j++){
				if(vetId[j] != ""){

					document.getElementById('idsMan').value += ","+vetId[j];
				}
			}
			newTask('buscaManuais',1);
			break;
			
		case 'TbIdiomas':
			var ids = document.getElementById('idsIdioma').value;
			var cont = 0;
			vetId = ids.split(",");
			
			vetId[i] = "";
			document.getElementById('idsIdioma').value = 0;
			for(j=1; j<vetId.length; j++){
				if(vetId[j] != ""){
					cont++;
					document.getElementById('idsIdioma').value += ","+vetId[j];
				}
			}
			
			document.getElementById('QtdIdiomas').value = cont;
			newTask('buscaIdiomas',1);
			break;
			
		default:
			alert("Problema na exclusão do item!");
	}
	ObjTabela = GetObject(obj);
	ObjTabela.deleteRow(i);	
}

// FUNÇÕES DE MENU COM IMAGENS

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// FIM DE FUNÇÕES DE MENU COM IMAGENS