// POP UP
function popup(theURL, width, height, features) {
	//"location=no,menubar=no,resiable=no,toolbar=no,scroollbars=yes"
	if (window.screen) {
		per_ancho = (width/screen.width)*100;
		per_alto = (height/width)*100;
		win_ancho = (screen.width*per_ancho)/100;
		win_alto = (win_ancho*per_alto)/100;
		x = (screen.width-win_ancho)/2;
		y = (screen.height-win_alto)/2;
	} else {
		x = 0;
		y = 0;
		win_ancho = w;
		win_alto = y;
	}
	winfeatures = ("top="+y+",left="+x+",width="+win_ancho+",height="+win_alto+","+features);
	window.open(theURL, 'popup', winfeatures);
}
function nada() {
	return;
}
//FLASH
function flash(versao, largura, altura, nome, modo, cor) {
	/*
	versao = 8 .................. <- Versão do player
	largura = 200px ............. <- Largura do SWF
	altura = 200px .............. <- Altura do SWF
	id = nome ................... <- ID do arquivo
	nome = arquivo.swf .......... <- Caminho do SWF, essa opção não pode ser vazia
	modo = transparent/opaque ... <- Flash transparente ou opaco / pode ser vazia
	cor = #ffffff ............... <- Cor de fundo
	*/
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="'+versao+',0,0,0" width="'+largura+'" height="'+altura+'">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" >\n');
	document.write('<param name="movie" value="'+nome+'" >\n');
	document.write('<param name="wmode" value="'+modo+'" >\n');
	document.write('<param name="bgcolor" value="'+cor+'" >\n');
	document.write('<embed src="'+nome+'" wmode="'+modo+'" bgcolor="'+cor+'" width="'+largura+'" height="'+altura+'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" >\n');
	document.write('</object>\n');
}
// DATA - ÍNICIO
function data() {
	mdata = new Date();
	mhora = mdata.getHours();
	mminuto = mdata.getMinutes();
	msegundos = mdata.getSeconds();
	mdia = mdata.getDate();
	mdiasemana = mdata.getDay();
	mmes = mdata.getMonth();
	mano = mdata.getFullYear();
	if (mdiasemana == 0) {
		document.write("'Domingo, ");
	} else if (mdiasemana == 1) {
		document.write("Segunda-feira, ");
	} else if (mdiasemana == 2) {
		document.write("Ter&ccedil;a-feira, ");
	} else if (mdiasemana == 3) {
		document.write("Quarta-feira, ");
	} else if (mdiasemana == 4) {
		document.write("Quinta-feira, ");
	} else if (mdiasemana == 5) {
		document.write("Sexta-feira, ");
	} else if (mdiasemana == 6) {
		document.write("S&aacute;bado, ");
	}
	document.write(+mdia+' de ');
	if (mmes == 0) {
		document.write("janeiro de ");
	} else if (mmes == 1) {
		document.write("fevereiro de ");
	} else if (mmes == 2) {
		document.write("mar&ccedil;o de ");
	} else if (mmes == 3) {
		document.write("abril de ");
	} else if (mmes == 4) {
		document.write("maio de ");
	} else if (mmes == 5) {
		document.write("junho de ");
	} else if (mmes == 6) {
		document.write("julho de ");
	} else if (mmes == 7) {
		document.write("agosto de ");
	} else if (mmes == 8) {
		document.write("setembro de ");
	} else if (mmes == 9) {
		document.write("outubro de ");
	} else if (mmes == 10) {
		document.write("novembro de ");
	} else if (mmes == 11) {
		document.write("dezembro de ");
	}
	document.write(mano);
}
// DATA - FIM


// IS NUMERIC
//onKeyPress="return(IsNumeric(this,event))"
function IsNumeric(fld, e) {
	var strCheck = '0123456789';
	var whichCode = (window.Event) ? e.which : e.keyCode;
	key = String.fromCharCode(whichCode);
	if (strCheck.indexOf(key) == -1) {
		return false;
	}
}


//LAYER
function MM_findObj(n, d) {
	//v4.01
	var p, i, x;
	if (!d) {
		d = document;
	}
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0, p);
	}
	if (!(x=d[n]) && d.all) {
		x = d.all[n];
	}
	for (i=0; !x && i<d.forms.length; i++) {
		x = d.forms[i][n];
	}
	for (i=0; !x && d.layers && i<d.layers.length; i++) {
		x = MM_findObj(n, d.layers[i].document);
	}
	if (!x && d.getElementById) {
		x = d.getElementById(n);
	}
	return x;
}
function MM_showHideLayers() {
	//v6.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i += 3) {
		if ((obj=MM_findObj(args[i])) != null) {
			v = args[i+2];
			if (obj.style) {
				obj = obj.style;
				v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v;
			}
			if (obj.visibility == 'hidden') {
				obj.visibility = 'visible';
			} else {
				obj.visibility = 'hidden';
			}
		}
	}
}
//STATUS BAR
function hidestatus() {
	window.status = 'Interelo - Sistemas LTDA';
	return true;
}
if (document.layers) {
	document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
}
document.onmouseover = hidestatus;
document.onmouseout = hidestatus;

//VALIDA FORMULÁRIO
function validaCampos(){
	frm = document.form1;
	
	if (frm.nome.value.length==0){
		alert('Preencha o campo Nome !!');
		frm.nome.focus();
		frm.nome.select();
		return false;
	}
	if (frm.email.value.length==0){
		alert('Preencha o campo E-Mail !!');
		frm.email.focus();
		frm.email.select();
		return false;
	}
	if (frm.ddd.value.length==0){
		alert('Preencha o campo DDD !!');
		frm.ddd.focus();
		frm.ddd.select();
		return false;
	}
	if (frm.telefone.value.length==0){
		alert('Preencha o campo Telefone !!');
		frm.telefone.focus();
		frm.telefone.select();
		return false;
	}
	if (frm.comentarios.value.length==0){
		alert('Preencha o campo Comentários !!');
		frm.comentarios.focus();
		frm.comentarios.select();
		return false;
	}
}


// THUMBS
var w = 1;
var h = 1;
if (document.getElementById || document.all) {
	document.write('<div id="thumbsImage"><img id="ttimg" src="../_images/spacer.gif" ></div>');
}
function gettrailobj() {
	if (document.getElementById) {
		return document.getElementById("thumbsImage").style;
	} else if (document.all) {
		return document.all.trailimagid.style;
	}
}
function truebody() {
	return (!window.opera && document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
}
function hideImage() {
	document.onmousemove = "";
	document.getElementById('ttimg').src = '../_images/spacer.gif';
	gettrailobj().visibility = "hidden";
	gettrailobj().left = -1000;
	gettrailobj().top = 0;
}
function showImage(width, height, file) {
	if (navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1) {
		w = width;
		h = height;
		// followmouse()
		gettrailobj().visibility = "visible";
		document.getElementById('thumbsImage').style.height = h;
		document.getElementById('thumbsImage').style.width = w;
		document.getElementById('ttimg').src = file;
		document.onmousemove = followmouse;
	}
}
function followmouse(e) {
	if (navigator.userAgent.toLowerCase().indexOf('opera') == -1 && navigator.userAgent.toLowerCase().indexOf('safari') == -1) {
		var xcoord = 20;
		var ycoord = 20;
		if (typeof e != "undefined") {
			xcoord += e.pageX;
			ycoord += e.pageY;
		} else if (typeof window.event != "undefined") {
			xcoord += truebody().scrollLeft+event.clientX;
			ycoord += truebody().scrollTop+event.clientY;
		}
		var docwidth = document.all ? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
		var docheight = document.all ? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);
		if (xcoord+w+3>docwidth) {
			xcoord = xcoord-w-(20*2);
		}
		if (ycoord-truebody().scrollTop+h>truebody().clientHeight) {
			ycoord = ycoord-h-20;
		}
		gettrailobj().left = xcoord+"px";
		gettrailobj().top = ycoord+"px";
	}
}

//POPUP 
function popupHide(){
	document.getElementById('popup').style.display = "none";
}
