/*
 * Created on 18/01/2007
 *
 * Author: Rodrigo Bedin Pereira / rodrigo@profissionalsi.com.br
 * Este código pertence ao arquivo scrips.js
 * Todos os Direitos Reservados (c) 2007. 
 */
	
function mostra_foto () {

}
	
function enable(id) {
	document.getElementById(id).disabled = 'false';
}

function jump(url){
  parent.mainFrame.location = url;
}

function goto(url){
  document.location.href = url;
}

function active (id){
	if (document.getElementById(id).style.visibility == 'visible'){
	document.getElementById(id).style.visibility = 'hidden';
	document.getElementById(id).style.position = 'absolute';
	}
	else {
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).style.position = 'absolute';
	}
}

function active_2 (id){
	if (document.getElementById(id).style.visibility == 'visible'){
	document.getElementById(id).style.visibility = 'hidden';
	document.getElementById(id).style.position = 'absolute';
	}
	else {
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).style.position = 'relative';
	}
}

function hide (id) {
	document.getElementById(id).style.visibility = 'hidden';
}
function hide2 (id) {
	document.getElementById(id).style.visibility = 'hidden';
	document.getElementById(id).style.position = 'absolute';
}
function show (id) {
	document.getElementById(id).style.visibility = 'visible';
}
function show2 (id) {
	document.getElementById(id).style.visibility = 'visible';
	document.getElementById(id).style.position = 'relative';
}

function submeter(id)
	{
	document.getElementById(id).submit();
	}

function troca(id1,id2){
	document.getElementById(id1).disabled = true;
	document.getElementById(id2).disabled = false;
}


function jogaValor(valor) {
	document.getElementById('valor').value =  valor;
}

function jogaInner(id,texto) {
	document.getElementById(id).innerHTML =  texto;
}

function setValue(valor,id) {
	document.getElementById(id).value =  valor;
}

function refreshOpener() {
		//atualiza sem repostar qualquer form.
		//usar onunload="refreshOpener();"
		//data 02/07/2007
	if (window.opener && !window.opener.closed) {
		window.opener.location.href = window.opener.location.href;
	}
}
function ativa_banner() {
	var t = setTimeout("troca_banner()",3000);
}
function troca_banner(){
	var id = document.getElementById('bnr');
	var b1 = 'http://ns1.profissionalsi.com.br/~eletrica/jpeg/banner_luminarias.jpg';
	var b2 = 'http://ns1.profissionalsi.com.br/~eletrica/jpeg/banner_interruptores.jpg';
	var b3 = 'http://ns1.profissionalsi.com.br/~eletrica/jpeg/banner_lampadas.jpg';
	//var b1 = 'http://localhost/eletricarocha.com.br/public_html/jpeg/banner_luminarias.jpg';
	//var b2 = 'http://localhost/eletricarocha.com.br/public_html/jpeg/banner_interruptores.jpg';
	//var b3 = 'http://localhost/eletricarocha.com.br/public_html/jpeg/banner_lampadas.jpg';
	var img = id.src;
	if(img==b1){
		id.src = b2;
	} else {
		if(img==b2) {
			id.src = b3;
		} else {
			if(img==b3) {
				id.src = b1;
			} else {
				id.src = id.src;
			}
		}
	}
	//alert(img + '\n' + id.src);
	ativa_banner();
}

function editaTarefa(codigo) {
	window.open(
		'tarefa_add.php?c=' + codigo,
		'_blank', 
		'toolbar=no, location=no, directories=no, status=yes, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=no, dependent=yes, width=400, height=300'
		);
}

function noScrollIE(){
      document.body.scroll = 'no';
}

function acessa_menu(menu) {
      window.location.href = "?menu=" + menu;
      document.getElementById('quadro').innerHTML = 
      "<br><img src='../img/carregando.gif'> ";
}
function acessa_menu_texto(texto) {
      window.frame.location.href = "load.php?texto=" + texto;
      document.getElementById('quadro').innerHTML = 
      " <img src='../img/carregando.gif'> ";
}
function volta_menu() {
	hide('main');
	load_frame('bem_vindo.php','main');
	hide('main');
	hide('mini');
	hide('m1');hide('m2');hide('m3');
	hide('m4');hide('m5');hide('m6');
	show('menu');
	show('logout');
	document.body.style.background = "url('img/fundo.jpg') left top no-repeat;";
}
function carrega(pagina) {
	//jogaInner('main',pagina);
    window.main.location = page;
}

function load(page,id){
	url = "./lib/ajax.load.php?page=" + page + "&id=" + id;
  	//document.getElementById(\'recebe\').innerHTML = url;
    window.frame.location = url;
}

function load_frame(page,frame){
    window.frame.location = page;
}


function mostra_foto(url,txt,w,h){
	//Author: Rodrigo Bedin Pereira / rodrigo@profissionalsi.com.br
	//mostra foto
	document.getElementById('fotodiv').style.visibility = 'visible';
	document.getElementById('fototbl').style.visibility = 'visible';
	document.getElementById('fotoimg').style.visibility = 'visible';
	document.getElementById('fotoimg').src = url;
	document.getElementById('fotoimg').width = w;
	document.getElementById('fotoimg').height = h;
	document.getElementById('fototxt').innerHTML = txt;
	document.body.style.overflow = 'hidden';
}

function mostra_foto_frame(url,txt,w,h){
	//Author: Rodrigo Bedin Pereira / rodrigo@profissionalsi.com.br
	//mostra foto
	parent.document.getElementById('fotodiv').style.visibility = 'visible';
	parent.document.getElementById('fotodiv').style.visibility = 'visible';
	parent.document.getElementById('fototbl').style.visibility = 'visible';
	parent.document.getElementById('fotoimg').style.visibility = 'visible';
	parent.document.getElementById('fotoimg').src = url;
	parent.document.getElementById('fotoimg').width = w;
	parent.document.getElementById('fotoimg').height = h;
	parent.document.getElementById('fototxt').innerHTML = txt;
	parent.document.body.style.overflow = 'hidden';
}

function esconde_foto(){
	//Author: Rodrigo Bedin Pereira / rodrigo@profissionalsi.com.br
	//mostra foto
	document.getElementById('fotodiv').style.visibility = 'hidden';
	document.getElementById('fototbl').style.visibility = 'hidden';
	document.getElementById('fotoimg').style.visibility = 'hidden';
	document.getElementById('fotoimg').src = '../img/fundo.png';
	document.getElementById('fotoimg').width = '';
	document.getElementById('fotoimg').height = '';
	document.getElementById('fototxt').innerHTML = '';
}

function esconde_foto_frame(){
	//Author: Rodrigo Bedin Pereira / rodrigo@profissionalsi.com.br
	//mostra foto
	document.parent.getElementById('fotodiv').style.visibility = 'hidden';
	document.parent.getElementById('fototbl').style.visibility = 'hidden';
	document.parent.getElementById('fotoimg').style.visibility = 'hidden';
	document.parent.getElementById('fotoimg').src = '../img/fundo.png';
	document.parent.getElementById('fotoimg').width = '';
	document.parent.getElementById('fotoimg').height = '';
	document.parent.getElementById('fototxt').innerHTML = '';
}
