
// tira o controle do flash
function flash(arqflash,largura,altura) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="' + arqflash + '" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="' + arqflash + '" width="' + largura + '" height="' + altura + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" wmode="transparent"></embed>');
	document.write('</object>');
}

// janela menu
function JanelaMenu(mypage, myname, w, h, scroll, status, menu) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+', status='+status+', menubar='+menu+''
win = window.open(mypage, myname, winprops)
	if(parseInt(navigator.appVersion) >= 4){
		win.window.focus();
	}
}

// FAVORITOS
function favoritos(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}

// NOVA JANELA
function NovaJanela(mypage, myname, w, h, scroll, status) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+', status='+status+''
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus();
}
}


function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
}

var hellotext=" PRINT BRINDES - AV. Franklin D. Roosevelt, 845 - Fone: (0xx) 44 3034-3434 - Maringá / PR "
var thetext=""
var started=false
var step=0
var times=1
function welcometext()
{
	times--
	if (times==0)
	{
	if (started==false)
	{
	  started = true;
	  window.status = hellotext;
	  setTimeout("anim()",1);
	}
	thetext = hellotext;
	}
}

 function showstatustext(txt)
{
	thetext = txt;
	setTimeout("welcometext()",4000)
	times++
}

function anim()
{
	step++
	if (step==7) {step=1}
	if (step==1) {window.status='>==='+thetext+'===<'}
	if (step==2) {window.status='=>=='+thetext+'==<='}
	if (step==3) {window.status='>=>='+thetext+'=<=<'}
	if (step==4) {window.status='=>=>'+thetext+'<=<='}
	if (step==5) {window.status='==>='+thetext+'=<=='}
	if (step==6) {window.status='===>'+thetext+'<==='}
	setTimeout("anim()",200);
}


function atualizarelogio(){
var hoje=new Date()
var hora=hoje.getHours()
var minuto=hoje.getMinutes()
var seconds=hoje.getSeconds()

  if(hora<10){hora="0" + hora}
  if(minuto<10){minuto="0" + minuto}
  if(seconds<10){seconds="0" + seconds}

relog.innerText = hora + ":" + minuto + ":" + seconds

setTimeout("atualizarelogio()",1000)
}


function M_over(src,clrOver) {
 if (!src.contains(event.fromElement)) {
  src.style.cursor = 'default';
  src.bgColor = clrOver;
 }
}
function M_out(src,clrIn) {
 if (!src.contains(event.toElement)) {
  src.style.cursor = 'default';
  src.bgColor = clrIn;
 }
}

// envia o contato
function confirmarContato(){
	nome = document.frmContato.NOME.value;
	empresa = document.frmContato.EMPRESA.value;
	cidade = document.frmContato.CIDADE.value;
	estado = document.frmContato.ESTADO.value;
	assunto = document.frmContato.ASSUNTO.value;
	mensagem = document.frmContato.MENSAGEM.value;
	retorno = document.frmContato.RETORNO.value;
	telefone = document.frmContato.TELEFONE.value;
	email = document.frmContato.EMAIL.value;
	motivo = document.frmContato.MOTIVO.value;
		
		if((nome != "") && (cidade != "") && (assunto != "") && (mensagem != "") && (telefone != "") && (email != "")){
			if(checkMail(email)) {
				document.frmContato.submit();
			} else {
				alert("O email informado não é válido!")
			}
		} else {
			alert("Preencha todos os campos marcados com asterisco (*)!")
		}
}

function MascaraMoeda(objTextBox, SeparadorMilesimo, SeparadorDecimal, e){
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
	var whichCode = (window.Event) ? e.which : e.keyCode;
    if((whichCode == 13) || (whichCode == 0) || (whichCode == 8)) return true;
    key = String.fromCharCode(whichCode); // PRECO para o código da Chave
    if (strCheck.indexOf(key) == -1) return false; // Chave inválida
    len = objTextBox.value.length;
    for(i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for(; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i))!=-1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0'+ SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0'+ SeparadorDecimal + aux;
    if (len > 2) {
        aux2 = '';
        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }
        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
        objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }
    return false;
}

function to2DecWithComma(num){
	
	num="" + Math.floor(num*100.0 + 0.5)/100.0;
	var i=num.indexOf(".");

	if ( i<0 ) num+=",00";
	else {
	num=num.substring(0,i) + "," + num.substring(i + 1);
	var nDec=(num.length - i) - 1;
	if ( nDec==0 ) num+="00";
	else if ( nDec==1 ) num+="0";
	else if ( nDec>2 ) num=num.substring(0,i + 3);
	}

return num;
}

