var appVer = navigator.appVersion.toLowerCase();
var iePos  = appVer.indexOf('msie');
var ieVer = 0;
var podefscommand = "nao";
var iebug = false;

if (iePos !=-1) {
	ieVer = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
	if(ieVer < 7) iebug = true;
	if(ieVer > 5.5) podefscommand = "sim";
}


if(podefscommand) document.write('<scr' + 'ipt for="menu_flash" event="FSCommand(funcao)">eval(funcao);</sc' + 'ript>');

function $(id){
	return document.all? document.all[id] : document.getElementById(id);
}

var tags = { "select":iebug, "applet":true };
var apagou = [];


function vai(x){
	temppg = pgatual + x;
	
	if(temppg<=0 || temppg > pgtotal[pasta]) location = "../ra/index.htm";
	else location = z(temppg) + ".htm";
}

function z(numero){
	return numero<10? ("0"+numero) : numero;
}

function abremenu(){
	document.getElementById("div_menu").style.clip = "rect(0 750px 600px 0)";
	for(tag in tags){
		if(tags[tag]){
			items = document.getElementsByTagName(tag);
			for(x = 0; x < items.length; x++){
				if(items[x].style.visibility==""){
					apagou[tag+"-"+x] = true;
					items[x].style.visibility = "hidden";
				}
			}
		}
	}
}

function fechamenu(){
	document.getElementById("div_menu").style.clip = "rect(0 210px 600px 0px)";
	for(tag in tags){
		if(tags[tag]){
			items = document.getElementsByTagName(tag);
			for(x = 0; x < items.length; x++){
				if(apagou[tag+"-"+x]) items[x].style.visibility = "";
			}
		}
	}
}

function addEvent(obj, evType, fn, useCapture){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  }
}


function abrir(url){
	window.open(url, "_blank");
}

function janela(url, w, h){
	try {
		jan = open(url, "", "width=" + w + ",height=" + h + ",left=" + ((screen.availWidth-w)/2) + ",top=" + ((screen.availHeight-h)/2));
		jan.focus();
	}
	catch(e){
		alert(idioma=="port"? "Por favor desabilite seu anti-popup." : "Please disable your anti-popup.");
	}
}

String.prototype.trim = function() { 
	return this.replace(/^\s+|\s+$/, ''); 
};

function flash(movie, flashvars, width, height, retorna){
	swfid = movie.split("/");
	swfid = swfid[swfid.length-1].replace(".swf", "");
	strSWF= '<object id="' + swfid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + width + '" height="' + height + '">'+
			'<param name="movie" value="' + movie + '">'+
			'<param name="quality" value="high">'+
			'<param name="wmode" value="transparent">'+
			'<param name="FlashVars" value="' + flashvars + '">'+
			'<embed name="' + swfid + '" src="' + movie + '" width="' + width + '" height="' + height + '" flashvars="' + flashvars + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed>'+
			'</object>';
	if(!retorna) this.document.write(strSWF);
	else return(strSWF);
}

function TheFlash(moviename) {
    if(document.all) return document.all[moviename];
	else return document.embeds[moviename];
}




function apagaValor(q){
			if(document.getElementById(q).value==0){
			document.getElementById(q).value="";
			}
}


function adiciona(qV,cat,subcat){
	d = document.form;
	var tempNB = false;
	for(i=1;i<qV;i++){
		valor = document.getElementById("qtd"+i).value;
		if(valor == ""){
			 document.getElementById("qtd"+i).value = "0";
		}
		if(valor != 0){
			tempNB = true;
		}
		
	}
	
	d.quantia.value = qV;
	d.action = "orcamento.asp?acao=adicionar&cat=" + cat + "&subcat=" + subcat;
	if (tempNB){
		d.submit();
	} else {
		alert("Por favor, informe as quantidades de produto que deseja.");	
	}
	
	
}



function enviaOrcamento(){
	
		d = document.form;
		
		
		if(d.nome.value == ""){ 
			alert("Por favor, preencha o seu nome.");
			d.nome.focus();
			return;
		}	
		
		
			
		d.email.value = d.email.value.toLowerCase();
		email = d.email.value;
	
		if(email == ""){ 
			alert("Por favor, informe seu e-mail."); 
			d.email.focus(); 
			return; 
		}
		else if((email.search(/[A-Za-z0-9_]+@[A-Za-z0-9_]{2,}\.[A-Za-z]{2,}/) == -1) || (email.indexOf("@") != email.lastIndexOf("@"))){ 
			alert("Endereço de e-mail inválido!"); 
			d.email.focus(); 
			return; 
		}

		
		if(d.ddd.value == ""){ 
			alert("Por favor, informe o código de área de seu número de telefone.");
			d.ddd.focus();
			return;
		}	
		
		if(d.telefone.value == ""){ 
			alert("Por favor, informe o número de seu telefone.");
			d.telefone.focus();
			return;
		}	
		
		
		
		n = 0;
		for(x = 0; x < d.opcao.length; x++){
				if(d.opcao[x].checked){
						n++;
				}
				
		}
		
		if(n<1){
			 alert("Por favor, selecione uma maneira para enviarmos o orçamento.")
			 return;
		} else {
			d.submit();	
		}		
		

	
	}

    




