///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Funcao Adiciona a Favoritos
function fnAdicionaFavoritos(){
	str_titulo = ":: Gráfica Easy ::";
	str_url = "http://www.graficaeasy.com.br";
	if(window.sidebar){ window.sidebar.addPanel(str_titulo, str_url,""); }
	else if(window.external){ window.external.AddFavorite( str_url, str_titulo); }
	else if(window.opera && window.print){ return true; }
}

////////////////////////////////////////////////////////////////////////////////////////////
//Validacao do Indique Amigo
function ValidaForm_IndiqueAmigo(form,evento){
	if ( form.nome.value == '' ){
		alert('Atenção!\nO campo SEU NOME deve ser preenchido.') ;
		form.nome.focus();
		return false ;
	}
	if (form.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nO campo SEU E-MAIL deve ser preenchido.");
		form.email.focus();
		return false;
	}
	if (form.emailamigo.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1){
		alert("Atenção!\nO campo E-MAIL DO AMIGO deve ser preenchido.");
		form.emailamigo.focus();
		return false;
	}
	if (form.mensagem.value == ''){
		alert('Atenção!\nO campo MENSAGEM deve ser preenchido.') ;
		form.mensagem.focus();
		return false ;
	}
}



//////////////////////////////////////////////////////////////////////////////////////////////
//Funcao de popup
function MM_openBrWindow(theURL,winName,features) 
{
	var myWin =  window.open(theURL,winName,features);
	myWin.focus();
}

//////////////////////////////////////////////////////////////////////////////////////////////
//Funcao para o flash
function fnFlash(str_url, int_largura, int_altura){
	document.writeln('<object type="application/x-shockwave-flash" data="' + str_url + '" width="' + int_largura + '" height="' + int_altura + '">');
	document.writeln('<param name="movie" value="' + str_url + '">');
	document.writeln('<param name="quality" value="high">');
	document.writeln('<param name="wmode" value="transparent">');
	document.writeln('</object>');
}

/////////////////////////////////////////////////////////////////////////////////////////////////
//valida formulario Contato
function verificaContato(form){
	if(form.nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
	if(form.telefone.value.length<=1){
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
	if(form.cidade.value.length<=1){
		alert("O campo Cidade deve estar preenchido corretamente.");
		form.cidade.focus();
		return false;
	}
	if(form.estado.value.length<=1){
		alert("O campo Estado deve estar selecionado corretamente.");
		form.estado.focus();
		return false;
	}
	if(form.mensagem.value.length<=1){
		alert("O campo Mensagem deve estar preenchido corretamente.");
		form.mensagem.focus();
		return false;
	}
	if(form.cod.value.length<=1){
		alert("O campo Código de Segurança deve estar preenchido corretamente.");
		form.cod.focus();
		return false;
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////
//valida formulario Contato
function ValidaForm_Orcamento(form){
	if(form.nome.value.length<=1){
		alert("O campo Nome deve estar preenchido corretamente.");
		form.nome.focus();
		return false;
	}
	var str_email = form.email.value ;
    if (( str_email.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1 ) || ( str_email == 'Email:' )){
    	alert("O campo E-mail deve ser preenchido corretamente");
    	form.email.focus();
    	return false;
	}
	if(form.telefone.value.length<=1){
		alert("O campo Telefone deve estar preenchido corretamente.");
		form.telefone.focus();
		return false;
	}
	if(form.descricao.value.length<=1){
		alert("O campo Descricao deve estar preenchido corretamente.");
		form.descricao.focus();
		return false;
	}
	if(form.quantidade.value.length<=0){
		alert("O campo Quantidade deve estar preenchido corretamente.");
		form.quantidade.focus();
		return false;
	}
	if(form.tamanho.value.length<=1){
		alert("O campo Tamanho deve estar selecionado corretamente.");
		form.tamanho.focus();
		return false;
	}	
	if(form.gramatura.value.length<=1){
		alert("O campo Gramatura deve estar selecionado corretamente.");
		form.gramatura.focus();
		return false;
	}
	if(form.tipo.value.length<=1){
		alert("O campo Tipo deve estar selecionado corretamente.");
		form.tipo.focus();
		return false;
	}	
}


/////////////////////////////////////////////////////////////////////////////////////////////////////
//função para o (mostrar e ocultar)
function onOff(id){
	esconder = (document.getElementById(id).style.display == 'block');
	divs = document.getElementsByTagName('DIV');
	for(d=0; d<divs.length; d++){
		_div = divs[d];
		if (_div.className == 'titulo'){
			id_link = 'titulo_'+(_div.id);
			_link = document.getElementById(id_link);
			if(_div.id != id){ _div.style.display = 'none'; }
			else{ _div.style.display = esconder ? 'none' : 'block'; }
		}
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Funcao da Mascara
function fnMascara(objeto,evt,mask){ 
	var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
	var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
	var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';	
	var Numeros = '0123456789';
	var Fixos  = '().-:/ ';
	var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";
	evt = (evt) ? evt : (window.event) ? window.event : "";
	var value = objeto.value;
	if(evt){
		var ntecla = (evt.which) ? evt.which : evt.keyCode;
		tecla = Charset.substr(ntecla - 32, 1);
		if(ntecla < 32) return true;
		var tamanho = value.length;
		if(tamanho >= mask.length) return false;
		var pos = mask.substr(tamanho,1);
		while(Fixos.indexOf(pos) != -1){
 	 		value += pos;
 	 		tamanho = value.length;
 	 		if(tamanho >= mask.length) return false;
 	 		pos = mask.substr(tamanho,1);
		}
		switch(pos){
   			case '#': if(Numeros.indexOf(tecla) == -1) return false; break;
   			case 'A': if(LetrasU.indexOf(tecla) == -1) return false; break;
   			case 'a': if(LetrasL.indexOf(tecla) == -1) return false; break;
   			case 'Z': if(Letras.indexOf(tecla) == -1) return false; break;
   			case '*': objeto.value = value; return true; break;
   			default: return false; break;
 		}
	}
	objeto.value = value;
	return true;
}

