/*
JAVA ABRE JANELA CENTRO
*/	

function abreJanelaNormal(url,nome,largura,altura,scroll){
    lTela = window.screen.width;
   aTela = window.screen.height;
   esqu = (lTela - largura) / 2; 
   topo = (aTela - altura) / 2;
   window.open(url,nome,"width=" + largura + ",height=" + altura +
",scrollbars=" + scroll + ",top=" + topo + ",left=" + esqu);
}

function LimpaBusca(obj){
	if (obj.value == 'BUSCA'){
		obj.value = '';	
	}
}
function FechaBusca(obj){
	if (obj.value == ''){
		obj.value = 'BUSCA';	
	}
}


function GerarSWF(arquivo,altura,largura,id){
    document.writeln('    <object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + largura + '" height="' + altura + '" id="' + id + '" name="' + id + '">');
    document.writeln('        <param name="movie" value="' + arquivo + '" />');
    document.writeln('        <param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
    document.writeln('        <param name="bgcolor" value="#ffffff" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="salign" value="tl" />');
    document.writeln('        <param name="scale" value="noscale" />');
    document.writeln('        <param name="wmode" value="transparent" />');
    document.writeln('        <embed id="globalnav-embed" src="' + arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" bgcolor="#ffffff" menu="false" quality="high" salign="tl" scale="noscale" id="' + id + '" width="' + largura + '" height="' + altura + '"></embed>');
    document.writeln('    </object>');
}


function GerarSWF_home(arquivo,altura,largura,id){
document.writeln('<object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + largura + '" height="' + altura + '" id="' + id + '" name="' + id + '">');
document.writeln('<param name="movie" value="' + arquivo + '&&hl=en&rel=0&color1=0x3a3a3a&color2=0x999999&border=0"></param>');
document.writeln('<embed src="../../../www.equipo.com.br/br/_include/' + arquivo + '&hl=en&rel=0&color1=0x3a3a3a&color2=0x999999&border=0" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
document.writeln('</object>');
}


function geraAjax(){
var ajax;
try {
ajax = new XMLHttpRequest();
} catch(ee) {
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch(E) {
ajax = false;
}
}
}
return ajax;
}

function pegaMarcasTop(){
	if(document.getElementById('marcasContent').innerHTML == ''){
		document.getElementById('marcasContent').innerHTML = '<img src="/br/img/loadMarcas.gif" style="margin-top:130px;">';
		pegMarcasTopAjax();
	}else{
		document.getElementById('marcasContent').innerHTML == '';
	}
}

function pegMarcasTopAjax(){
var ajax = geraAjax();
if (document.getElementById && ajax) {
ajax.open("POST", "produtos/listaMarcas.html", true);
ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
ajax.send('');

ajax.onreadystatechange = function() {
if (ajax.readyState == 4) {
if(ajax.status == 200) {
var resultado = ajax.responseText;
resultado = resultado.replace(/\+/g," ");
resultado = unescape(resultado);
document.getElementById('marcasContent').innerHTML = resultado;
} else {
document.getElementById('marcasContent').innerHTML = "Ocorreu um erro!";
}}}}}


    if (document.images){
	
      preload_image_object = new Image();
      image_url = new Array();
      image_url[0] = "img/loadMarcas.html";
       var i = 0;
       for(i=0; i<=3; i++){
         preload_image_object.src = image_url[i];
		}
    }


//home destaque video/musica
function mudar_destaque(obj){
if (obj.className == 'bt_home_musica'){
	var htm;
	htm = document.getElementById('fundo_destaque_home').innerHTML;
	obj.className = 'bt_home_musica_over';
	document.getElementById('bt_video').className = 'bt_home_video';
	document.getElementById('fundo_destaque_home').innerHTML = document.getElementById('listagem_videos').innerHTML;
	document.getElementById('listagem_videos').innerHTML = htm;
}
if (obj.className == 'bt_home_video'){
	var htm;
	htm = document.getElementById('fundo_destaque_home').innerHTML;	
	obj.className = 'bt_home_video_over';
	document.getElementById('bt_musica').className = 'bt_home_musica';
	document.getElementById('fundo_destaque_home').innerHTML = document.getElementById('listagem_videos').innerHTML;
	document.getElementById('listagem_videos').innerHTML = htm;	
}
}
function abreVideo(str){
	var vd = '    <object id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="240" height="200" id="destaque_1" name="destaque_1">';
    vd = vd + '        <param name="movie" value="' + str + '" />';
    vd = vd + '        <param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />';
    vd = vd + '        <param name="bgcolor" value="#ffffff" />';
    vd = vd + '        <param name="menu" value="false" />';
    vd = vd + '        <param name="quality" value="high" />';
    vd = vd + '        <param name="salign" value="tl" />';
    vd = vd + '        <param name="scale" value="noscale" />';
    vd = vd + '        <param name="wmode" value="transparent" />';
    vd = vd + '        <embed id="globalnav-embed" src="' + str + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" bgcolor="#ffffff" menu="false" quality="high" salign="tl" scale="noscale" id="destaque_1" width="240" height="200"></embed>';
    vd = vd + '    </object>';
	
	document.getElementById('bt_video').className = 'bt_home_video_over';
	document.getElementById('bt_musica').className = 'bt_home_musica';	


	var htm;
	htm = document.getElementById('fundo_destaque_home').innerHTML;	
	
	document.getElementById('fundo_destaque_home').innerHTML = '<div style="*margin-left:9px;">' + vd + '</div>';
	document.getElementById('listagem_videos').innerHTML = htm;		
}



	
/*noticia||||||||||||||||||||||||||||||||||||||\*/

function navegador(){
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);

if(browser == "Netscape"){
        alert("Confira as imagens");
	
	}

}



	function AbreImgGrandeNot(str){
		document.getElementById('imgProdGrandeImg').style.width = 1;
		document.getElementById('imgProdGrandeImg').style.height = 1;		
		document.getElementById('imgProdGrandeImg').src = str;
		document.getElementById('ProdImgGrandeNot').style.visibility = 'visible';

	}		
	function carregouImgNot(){
		document.getElementById('imgProdGrandeImg').style.width = '600px';
		document.getElementById('imgProdGrandeImg').style.height = '400px';	
		document.getElementById('ajaxLoad').style.visibility = 'hidden';
		document.getElementById('ajaxLoad').style.width = '1px';
		document.getElementById('ajaxLoad').style.height = '1px';
		document.getElementById('ajaxLoad').style.marginTop = '0px';
	}

	function fecharNoticia(){
		document.getElementById('ProdImgGrandeNot').style.visibility = 'hidden';				
	}




/*noticia||||||||||||||||||||||||||||||||||||||\*/



//produtos
	function carregouImg(){
		document.getElementById('imgProdGrandeImg').style.width = '700px';
		document.getElementById('imgProdGrandeImg').style.height = '400px';	
		document.getElementById('ajaxLoad').style.visibility = 'hidden';
		document.getElementById('ajaxLoad').style.width = '1px';
		document.getElementById('ajaxLoad').style.height = '1px';
		document.getElementById('ajaxLoad').style.marginTop = '0px';
	}



function fecharProduto(){
		document.getElementById('ProdImgGrande').style.visibility = 'hidden';				
	}
	

	
	function fecharEmail(){
		document.getElementById('EnviarEmail').style.visibility='hidden';
		document.getElementById('EnviarEmailForm').style.visibility='hidden';		
		document.getElementById('fecharPemail').style.visibility='hidden';		
	}
	
	function abreEnviarEmail(){
		document.getElementById('EnviarEmail').style.visibility = 'visible';
		document.getElementById('EnviarEmailForm').style.visibility = 'visible';		
		document.getElementById('fecharPemail').style.visibility = 'visible';

		fecharProduto();
	}
	
	function enviarEmail(t_nome,t_email,t_nome2,t_email2,idd,ttitulo,marca){

		var ajax = geraAjax();
		if (document.getElementById && ajax) {
		ajax.open("POST", "email.html", true);
		ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
		ajax.send('nome='+t_nome+'&email='+t_email+'&nome2='+t_nome2+'&email2='+t_email2+'&id='+idd+'&titulo='+ttitulo+'&pasta='+marca);
		
		ajax.onreadystatechange = function() {
		if (ajax.readyState == 4) {
		if(ajax.status == 200) {
			var resultado = ajax.responseText;
			resultado = resultado.replace(/\+/g," ");
			resultado = unescape(resultado);
			fecharEmail()	
		} else {

		}}}}
		
	}
	function redimenImg(){
		var obj = document.getElementById('ProdImgGrande');	
		var larguraImg = 700;	
		var larguraImg2 = 400;		
			
		var largura = window.document.body.clientWidth;
		var rest = largura - larguraImg;
		if (rest > 2){
			obj.style.left = ((rest / 2)-22) + 'px';
		}	
		
		
		var obj = document.getElementById('EnviarEmail');			
		var largura = window.document.body.clientWidth;
		var rest = largura - larguraImg2;
		if (rest > 2){
			obj.style.left = (rest / 2) + 'px';
		}	

		var obj = document.getElementById('EnviarEmailForm');			
		var largura = window.document.body.clientWidth;
		var rest = largura - larguraImg2;
		if (rest > 2){
			obj.style.left = (rest / 2) + 'px';
		}
		
		var obj = document.getElementById('fecharPemail');			
		var largura = window.document.body.clientWidth;
		var rest = largura - 25;
		if (rest > 2){
			obj.style.left = ((rest / 2)+227) + 'px';
		}			
		
			
	}	 
	function AbreImgGrande(str){
		document.getElementById('imgProdGrandeImg').style.width = 1;
		document.getElementById('imgProdGrandeImg').style.height = 1;		
		document.getElementById('imgProdGrandeImg').src = str;
		document.getElementById('ProdImgGrande').style.visibility = 'visible';
		fecharEmail();
	}		
	
function ProdClica(param){
var i


			
for (i=1;i<=6;i++) {
	if (param != '0'+i){
		if (document.getElementById('bt0'+i)) {
			window.setTimeout("document.getElementById('bt0" + i + "').src = '../_img/prod_0"+i+"_a.gif'",10 * i);
		}
	}else{
			window.setTimeout("document.getElementById('bt0" + i + "').src = '../_img/prod_0"+i+"_b.gif'",10 * i);
		}
}	

		var bd;
		bd = document.getElementById('tb'+param).innerHTML;
		document.getElementById('content_produto').innerHTML = bd;
		
		if (param == '03'){
			box = new MultiBox('link_img_gal', { useOverlay: true });
		}
}


//Cadastro
function fc_cep(v){
    v=v.replace(/D/g,"")
    v=v.replace(/^(\d{5})(\d)/,"$1-$2")
    return v
}
function fc_data(v){
    v=v.replace(/\D/g,"")
    v=v.replace(/(\d{2})/,"$1/")
    v=v.replace(/(\/{1}\d{2})/,"$1/")
    return v
}
function soNumeros(v){
    return v.replace(/\D/g,"")
}

function fc_telefone(v){
    v=v.replace(/\D/g,"")
    v=v.replace(/(\d{4})(\d)/,"$1-$2")
    return v
}
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}
function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function validarData(str) {
    var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
    if ((str.match(expReg)) && (str!='')) {
        return true;
    } else {
		return false;
    }
}

function valida(){
	var erros = '';

	if (o('produto')){
	if (o('produto').value.length < 1 || o('produto').value.length > 200){
		erros += '\nNome de produto - de 1 até 200 caracteres';
		o('produto').focus();
	}}
	
	if (o('serial')){
	if (o('serial').value.length < 1 || o('serial').value.length > 200){
		erros += '\nNúmero Serial inválido - de 1 até 200 caracteres';
		o('serial').focus();
	}}
	
	if (o('nome')){
	if (o('nome').value.length < 1 || o('nome').value.length > 150){
		erros += '\nNome inválido - de 1 até 150 caracteres';
		o('nome').focus();
	}}
	
	if (o('rg')){
	if (o('rg').value.length < 5 || o('rg').value.length > 13){
		erros += '\nRG inválido - de 5 até 13 caracteres';
		o('rg').focus();
	}}

	if (o('email')){
	if (o('email').value.length < 1 || o('email').value.length > 250 || o('email').value.indexOf('@') < 1 || o('email').value.indexOf('.') < 1){
		erros += '\nEmail inválido - de 1 até 250 caracteres, no formato nome@dominio.com';
		o('email').focus();
	}}
	
	if (o('endereco')){
	if (o('endereco').value.length < 1 || o('endereco').value.length > 250){
		erros += '\nEndereço inválido - de 1 até 250 caracteres';
		o('endereco').focus();
	}}

	if (o('bairro')){
	if (o('bairro').value.length < 1 || o('bairro').value.length > 150){
		erros += '\nBairro inválido - de 1 até 150 caracteres';
		o('bairro').focus();
	}}
	
	if (o('cidade')){
	if (o('cidade').value.length < 1 || o('cidade').value.length > 150){
		erros += '\nCidade inválida - de 1 até 150 caracteres';
		o('cidade').focus();
	}}
	
	if (o('cep')){
	if (o('cep').value.length != 9){
		erros += '\nCEP Inválido - 9 Caracteres';
		o('cep').focus();
	}}
	
	if (o('nascimento')){
	if (validarData(o('nascimento').value) == false){
		erros += '\nData de nascimento inválida - formato dd/mm/aaaa';
		o('nascimento').focus();
	}}
	
	if (o('senha')){
	if (o('senha').value != o('senha2').value){
		erros += '\nAs senhas que você digitou nao coincidem';
		o('senha').focus();
	}}	
	
	if (o('senha')){
	if (o('senha').value.length < 4 || o('senha').value.length > 20){
		erros += '\nSenha inválida - de 4 até 20 caracteres';
		o('senha').focus();
	}}		
		
	if (o('profissao')){
	if (o('profissao').value.length < 1 || o('profissao').value.length > 250){
		erros += '\nProfissão inválida - de 1 até 150 caracteres';
		o('profissao').focus();
	}}	
	
	if (o('estilo')){
	if (o('estilo').value.length < 1 || o('estilo').value.length > 250){
		erros += '\nEstilo Preferido inválido - de 1 até 150 caracteres';
		o('estilo').focus();
	}}	
	
	if (o('instrumento')){
	if (o('instrumento').value.length < 1 || o('instrumento').value.length > 250){
		erros += '\nInstrumento que toca inválido - de 1 até 150 caracteres';
		o('instrumento').focus();
	}}		

	if (erros.length > 0){
		erros = 'Foram encontrados os seguinte erros de preenchimento no formulário:\n' + erros + '\n\nVefique e tente novamente, Obrigado.'
		alert(erros);
		return false
	}else{
		return true;
	}
}
function o(str){
	return document.getElementById(str);
}


//marcas roll
//		window.addEvent('domready', function(){
//			prapara_toggle();
//		}); 
 $(document).ready(function() {
   prapara_toggle();
 });


	function prapara_toggle(){

			//$("#marcas-cont").hide();
			
			
			
			$("#togglemap").click(function(){
				if (o('marcas-nav-bt').className == 'marcas-nav-bt-a'){
					o('marcas-nav-bt').className = 'marcas-nav-bt-b';
					$("#marcas-cont").slideDown(1000);
				}else{
					o('marcas-nav-bt').className = 'marcas-nav-bt-a';
					$("#marcas-cont").slideUp(1000);
				}				
			 });
			
//			$('togglemap').addEvent('click', function(e){
//				e = new Event(e);
//				mySlide.toggle();
//				if ($('marcas-nav-bt').className == 'marcas-nav-bt-a'){
//					$('marcas-nav-bt').className = 'marcas-nav-bt-b';
//				}else{
//					$('marcas-nav-bt').className = 'marcas-nav-bt-a';					
//				}
//				e.stop();
//			});
		}		
