/*
script desenvolvido por Luis Carlos de Brito - luis@pevermelho.art.br

caso venha adquirir este script por outro meio senao atraves do autor, favor manter o credito do criadore
este script pode ser utilizado, modificado, publicado, utilizado sem restricoes desde que mantido os credidos dos criadores

##########------- tive muito trabalho para fazer este funcionar, respeite meu trabalho e conhecimento -------##########

*/

function showHide(id,param) {
	getElmt(id).style.display=param;
}

function enviarEmail() {
	nome = getElmt('nome').value;
	email = getElmt('email').value;
	fone = getElmt('fone').value;	
	mensagem = getElmt('mensagem').value;
	params = nome+'$@$,'+email+'$@$,'+fone+'$@$,'+mensagem;
	
	buscarConteudo('alert','enviarEmail',params,'');
}
 
function showDvAlert(msg) {
	getElmt('contentDvAlert').innerHTML=msg;
	showHide('dvAlert','block');
	getElmt('dvAlert').style.top=100+document.body.scrollTop;
	
	if(window.navigator.appName=="Microsoft Internet Explorer") {
		getElmt('dvAlert').style.filter='alpha(opacity=10)';
		
		var intervalo = window.setInterval(function() {		
			getElmt('dvAlert').style.filter='alpha(opacity='+(eval(getElmt('dvAlert').style.filter.substr(14,2))+10)+')';
		}, 100);
		window.setTimeout(function() {
		clearInterval(intervalo);
		getElmt('dvAlert').style.filter='alpha(opacity=100)';
		}, 900);
	}
	else {
		getElmt('dvAlert').style.opacity='0.1';
		
		var intervalo = window.setInterval(function() {		
			getElmt('dvAlert').style.opacity=eval(getElmt('dvAlert').style.opacity)+0.1;
		}, 100);
		window.setTimeout(function() {
		clearInterval(intervalo);
		getElmt('dvAlert').style.opacity='1';
		}, 900);
	}
	
	window.setTimeout(function(){alternateDisplay('dvAlert');},3000);
}

function alternateDisplay(id) {
	getElmt(id).style.display=='none' ? getElmt(id).style.display='block' : getElmt(id).style.display='none';
}

function init() {	
	getElmt('macarico').innerHTML=insertSWF('solda.swf',125,250,'');
	if(window.navigator.appVersion.indexOf('MSIE 6.0')!=-1) {
		addTransparency();
	}
	getElmt('dvAlert').style.left=(screen.width-300)/2;
	
	addListener('nome','focus','doEmpty');
	addListener('fone','focus','doEmpty');
	addListener('email','focus','doEmpty');
	addListener('cidade','focus','doEmpty');
	addListener('endereco','focus','doEmpty');
	
	addListener('nome','blur','doLabel');
	addListener('fone','blur','doLabel');
	addListener('email','blur','doLabel');
	addListener('cidade','blur','doLabel');
	addListener('endereco','blur','doLabel');
	
	 hs.addSlideshow({
	 slideshowGroup: 'galeria',
	 interval: 5000,
	 repeat: false,
	 useControls: true,
	 fixedControls: true,
	 outlineType: 'rounded-white',
	 wrapperClassName: 'highslide-white',
	 dimmingOpacity: 0.75,
	 overlayOptions: {
			opacity: .6,
			position: 'top center',
			hideOnMouseOut: true
		}
	});
	hs.transitions = ['expand', 'crossfade'];
}

function addListener(id, event, func) {
	if(window.navigator.appName=="Microsoft Internet Explorer") {
		getElmt(id).attachEvent('on'+event,function(){ window.setTimeout(func+"('"+id+"')",100);});		
	}
	else {
		getElmt(id).addEventListener(event, function(){window.setTimeout(func+"('"+id+"')",100);}, false);		
	}
}

function doEmpty(id) {
	getElmt(id).value='';
}

function doLabel(id) {
	if(getElmt(id).value=='' || getElmt(id).value==' ') {
		getElmt(id).value=id.charAt(0).toUpperCase() + id.substr(1).toLowerCase();
	}
}

function mascaraDataHora(mdata, add, ev) {
	if(window.event && ev.keyCode==8)
		return mdata;
	else {
		if(ev.which==8)
			return mdata;
	}

    if(mdata.length== 2)
        mdata+=add;

    if(mdata.length== 5)
       mdata+=add;

    if(mdata.length==10)
    	mdata=mdata.substr(0,10);
    return mdata;
}

function menuOver(id) {
	getElmt(id).style.backgroundImage='url(imagens/'+id+'_over.jpg)';
}

function menuOut(id) {
	getElmt(id).style.backgroundImage='url(imagens/'+id+'.jpg)';
}

if(window.navigator.appName=="Microsoft Internet Explorer") {
	window.attachEvent('onload', init);
} else {
	window.addEventListener('load', init, false);
}

function registrarNews() {
	buscarURL('alert','','acao=registrarNews&nome='+getElmt('nnome').value+'&email='+getElmt('nemail').value+'&nascimento='+getElmt('nnascimento').value);
}

function enviarSolicitacao() {
	produtos='';
	getElmt('portoes').checked ? produtos+='portões ' : produtos ;
	getElmt('esquadrias').checked ? produtos+='esquadrias ' : produtos ;
	getElmt('obras').checked ? produtos+='obras ' : produtos ;
	getElmt('expositores').checked ? produtos+='expositores ' : produtos ;
	getElmt('grades').checked ? produtos+='grades ' : produtos ;
	getElmt('paineis').checked ? produtos+='painéis ' : produtos ;
	getElmt('coberturas').checked ? produtos+='coberturas ' : produtos ;
	buscarURL('alert','','acao=enviarSolicitacao&nome='+getElmt('nome').value+'&fone='+getElmt('fone').value+'&email='+getElmt('email').value+'&cidade='+getElmt('cidade').value+'&uf='+getElmt('uf').value+'&endereco='+getElmt('endereco').value+'&produto='+produtos);
}

var cache = (new Image()).src='imagens/menu_hover.png';

function insertSWF(file, w, h, params) {
	insert = new Flash(file, '', w, h,'');
	insert.addParameter('wmode', 'transparent'); 
	insert.addParameter('showMenu', 'false'); 
	
	if(params.length>2) {
		tmp=params.split(',');
		for(i in tmp) {
			param_value = tmp[i].split('=');
			insert.addVariable(param_value[0]+'', param_value[1]+'');
		}
	}
	return insert.toString();
}