// fun&ccedil;&otilde;es para facilitar a vida
function $obj(obj){ return document.getElementById(obj.id); }
function $id(id){ return document.getElementById(id); }
function $tag(id){ return document.getElementsByTagName(id); }

// centraliza o pop-up na tela
function meds(w,h){
	wi = w;
	he = h;
	cim = (screen.height-he)/2;
	dir = (screen.width-wi)/2;
}

// abrir pop-up
function nome_da_funcao(valorvariavel){
	meds(300,266);//chama fun&ccedil;&atilde;o meds com parâmetros
	window.open("pagina.asp?nomedavariavel=" + valorvariavel,"nomedopopup","width="+wi+", height="+he+", top="+cim+", left="+dir)
}

//
function frames_abrir_pagina_com_variaveis(valorvariavel){
// elemento da &aacute;rvore - noeme de elemento filho - propriedade
frames.exe.location = "nomedapagina.asp?variavel=" + valorvariavel;
}


/*  envio de emails  */
function form_envio(){

nom = document.getElementById("nome").value;
	if (nom == ""){
		alert("por favor digite o seu nome")
		return false;
	}

cemail = document.getElementById("email").value
	if (cemail == "" ){
		alert("por favor digite o seu email")
		return false;
	}

strMail = cemail;
var re = new RegExp;
re = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
var arr = re.exec(strMail);
	if (arr == null){
		alert("por favor digite o seu email corretamente")	
		return false;
	}

cemail = document.getElementById("mensagem").value
	if (cemail == "" ){
		alert("por favor digite o sua mensagem")
		return false;
	}

return true;
}


function classe_nome_alterar(){

	alvo = $id("botao");
	alvo.className = "nome_da_classe";

}

// ---------------------------------------------------------------------------------------------------------------------------------------------------

function somemte_algumas_teclas(e){
if (document.all) // Internet Explorer
 var tecla = event.keyCode;
 else if(document.layers) // Nestcape
 var tecla = e.which;
//alert(tecla)
  if ((tecla > 47 && tecla < 58) || (tecla == 13) || (tecla == 32) || (tecla == 40) || (tecla == 41)|| (tecla == 45) ) // numeros de 0 a 9
   return true;
  else
  {

   if (tecla != 8) // backspace
    event.keyCode = 0;

	//return false;
   else
    return true;
  }
 }

 
// --------------------------------------------------------------------------------------------------------------------------------------------------- 

function condicional_ifelse(){

	var cor;
		if ( vars=="" ){
			cor = "666666";
		}
		else
		{
			cor = "0066CC";
		}

}

// ---------------------------------------------------------------------------------------------------------------------------------------------------

function condicional_switch(variavel){

	switch (variavel){
		
		case "valor1":
			alert("resposta-1");
		break;
		
		case "valor2":
			alert("resposta-2");
		break;
		
		default:
			alert("resposta-padrao");
	}

}


// ---------------------------------------------------------------------------------------------------------------------------------------------------

// agrupando condi&ccedil;&otilde;es
function condicional_switch(){

letra = "e"

	switch (letra) {
		case "a":
		case "e":
		case "i":
		case "o":
		case "u":
			alert("Vogal")
		default:
			alert("Outro caracter")
	}

}



function condicional_while(){
numero = 0

while (numero < 10)
{
	numero++
}

alert(numero)

}
// ---------------------------------------------------------------------------------------------------------------------------------------------------


function pro_cor(obj,v){
li = $(obj)
alvo = li.getElementsByTagName("a")[0];// nome do produto

alvo = li.getElementsByTagName("a")[2];//link do produto
alvo.className = "prod_link"+v;
//alvo.className == "prod_link" ? alvo.className = "prod_linkb" : alvo.className = "prod_link";
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// executa fun&ccedil;ao assim que a página carregar


function link_externo(){
	
if(document.getElementsByTagName("a"))
{
    if(document.getElementsByTagName)
	{
        var anchors = document.getElementsByTagName('a');
        	
			for(var i=0; i<anchors.length; i++)
			{
            	var anchor = anchors[i];
            		if(anchor.getAttribute("href") && anchor.getAttribute('rel')=='externo')
					{ // <-- É necessário inserir rel="externo" no link
                	anchor.target = '_blank';
                	var title = anchor.title + ' (este link abre uma nova janela)'; // <-- Insere este texto no final do Title do link
                	anchor.title = title;
            		}
        	}
    }

}
}

// ---------------------------------------------------------------------------------------------------------------------------------------------------
// exemplo para corrigir falhas ao suporte do css no IE
// verifica comportamento para executar alterações visuais no IE   


function contato_cores_trocar(){


if($id("produtos")){

ul = $id("produtos");
lis = ul.getElementsByTagName("li");
	for(i=0;i<lis.length;i++){
		

		lis[i].onmouseover = function(){ pro_cor(this,"b"); }
		lis[i].onmouseout = function(){ pro_cor(this,""); }
		/*
		lis[i].onfocus = function(){ pro_cor(this,"b"); }
		lis[i].onblur = function(){ pro_cor(this,""); }
*/

	}

	}

	// || document.getElementById("maisvendidos")
	if(document.getElementById("maisprocurados")){
	tooltip.init ();	
	}
	
	

/*
	var busca_url = location.href;
		if(document.getElementById("produtos") && busca_url.lastIndexOf("busca=")!=-1){
			links_pro = document.getElementById("produtos").getElementsByTagName("a");
			for(i=0;i<links_pro.length;i++){
						var muda_url = new String(links_pro[i]);
						muda_url.lastIndexOf("view.asp")!=-1 ? curl = "&busca=s" : curl = "?busca=s";
					links_pro[i].href += curl;
			}
		}
*/
	
	
	if(document.all){
	if(document.getElementById("cadastro")){

	ipts = document.getElementById("cadastro").getElementsByTagName("input");

	for(i=0;i<ipts.length;i++)
	{
		if(!/reset/.test(ipts[i].type) && !/submit/.test(ipts[i].type) && !/hidden/.test(ipts[i].type)){
			ipts[i].onfocus = function(){ this.className="border_red"; }
			ipts[i].onblur = function(){ this.className=""; }
		}
	}

	}
	
}
	
	
	}


	
// ---------------------------------------------------------------------------------------------------------------------------------------------------	
// escrever iframe via js para validar o xhtml
function fontDiv(){
	document.write("<div id=\"font\"><span id=\"a1\" onclick=\"font(11,this)\">a</span><span id=\"a2\" onclick=\"font(12,this)\">a</span><span id=\"a3\" onclick=\"font(15,this)\">a</span></div>");
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------	
// escrever iframe via js para validar o xhtml
function iframe_box(){
	document.write("<iframe name=\"box\" id=\"box\" height=\"0\" width=\"0\" frameborder=\"0\"></iframe>");
}
// ---------------------------------------------------------------------------------------------------------------------------------------------------	
// é preciso incluir o arquivo tools-font.htm. 
// somente os elementos com a class font serão afetados
function font(size,span){
		
		area = document.getElementById("content").getElementsByTagName("div");

	for(i=0;i<area.length;i++)
	{
	
	
		if(/font/.test(area[i].className)){
		
				
				p = area[i].getElementsByTagName("p");
				for(e=0;e<p.length;e++)
				{
				p[e].style.fontSize = size + "px"; 
				}
			
			
				li = area[i].getElementsByTagName("li");
				for(e=0;e<li.length;e++)
				{
				li[e].style.fontSize = size + "px"; 
				}
			
				a = area[i].getElementsByTagName("a");
				for(e=0;e<a.length;e++)
				{
				a[e].style.fontSize = size + "px"; 
				}
			
			
			
			
			
			
			}
	}
		
	document.getElementById("a1").style.textDecoration = "none";
	document.getElementById("a2").style.textDecoration = "none";
	document.getElementById("a3").style.textDecoration = "none";
	span.style.textDecoration = "underline";
	
	}

	
	
	
	
	
	
	
	
// JavaScript Document JavaScript Flash detection and deployment  (c)2004 Adrian Rowbotham   www.ajrdesign.net
/* -- 1. Player Version detection -- */

//set player version here
var MM_contentVersion = 6;

//set sub version here
var release = "6,0,67,0";


//check for flash player
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}




function writeFlash(swf,flashVarString,w,h,bgcolor,menu,mode,q,id){
if ( MM_FlashCanPlay ) {
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
+'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+release+'" '
+'width="'+w+'" height="'+h+'" id="'+id+'" align="" tabindex="-1">'
+'<param name="movie" value="'+swf+'">'
+'<param name="menu" value="'+menu+'"> '
+'<param name="quality" value="'+q+'"> '
+'<param name="wmode" value="'+mode+'"> '
+'<param name="bgcolor" value="'+bgcolor+'"> '
+'<param name="flashvars" value="'+flashVarString+'"> '
+'<embed id="'+id+'f" src="'+swf+'" flashvars="'+flashVarString+'" menu="'+menu+'" quality="'+q+'" wmode="'+mode+'" '
+' bgcolor="'+bgcolor+'" width="'+w+'" height="'+h+'" name="'+swf+'" '
+' align="" type="application/x-shockwave-flash" '
+' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object> ');
} else {
//behaviour for if there is no flash player
document.write('Você precisa do Flash Player '+MM_contentVersion+' ou outro superior para ver esse site.');
document.write('<em><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank">');
document.write('Clique aqui para instalar.</a></em>');
//this can be replaced by anything you want
//e.g. document.location.replace("text.html");

}
}

//	pra chamar
//var flashvars = "";
//writeFlash('library/swf/a.swf',flashvars,132,350,'',false,'window','high','nome');




	
	