function changeDeliveryForm(obj) {
	var objStore = document.getElementById('trStore');
	if(objStore) {
		var selectStore = document.getElementById('selectStore');
		if(selectStore) selectStore.selectedIndex = 0;
		if(obj.selectedIndex) {
			if(obj[obj.selectedIndex].value == 2) {
				// Mostra select
				objStore.style.display='';
			} else {
				// Esconde Select
				objStore.style.display='none';
			}
		} else {
			objStore.style.display='none';
		}
	}
}

function loadTo(u) {
	dn(u, dn100); 
}
function dn100(s) {
document.getElementById('NOT').innerHTML = s;
}


function glTTA(f,id) {
   f.action=id;
}

campos=new Array();
function fc(campo,ivalue){
	var v1=campos[campo.form.name];
	if(v1 && v1.length)for(i=0;i<v1.length;i++)if((v1[i][0]==campo.name)&&(campo.value==v1[i][1]))campo.value="";
}

function lfc(campo){
 	var v1=campos[campo.form.name];
 	if(v1 && v1.length)for(i=0;i<v1.length;i++)if((v1[i][0]==campo.name)&&(campo.value==""))campo.value=v1[i][1];
}

function initField(form,campo,inicial,obrigatorio,texto) {
	if(!campos[form])campos[form]=new Array();
	campos[form][campos[form].length]=new Array(campo,inicial,obrigatorio,texto);
	if(document.forms[form].elements[campo].value=="")document.forms[form].elements[campo].value=inicial;
}

function tstForm(f){
	var form = f.name; 
 	var v1=campos[form];
 	if(v1 && v1.length)for(i=0;i<v1.length;i++){
  		c=v1[i];
  		if(c[2] && (document.forms[form].elements[c[0]].value=="") || (document.forms[form].elements[c[0]].value==c[1]))return e(c[3],document.forms[form].elements[c[0]]);
 	}
 	return 1;
}

function submitenter(myfield,e) {
 	var keycode;
 	if(window.event)keyCode=window.event.keyCode;
 	else if(e)keyCode=e.which;
 	else return true;
 	if(keyCode == 13){
  		if(tstForm(myfield.form))myfield.form.submit();
  		return false;
 	} else return true;
}

function validadata(data){
	if(data.value.length != 10) return false;
	if(!(res = data.value.split(/-/)) || res.length!=3) return false;
	
	var dia = data.value.substring(0,2);
	var mes = data.value.substring(3,5);
	var ano = data.value.substring(6,10);

	var hoje = new Date();
	var anoh = hoje.getYear();
	
	if (ano > anoh || ano < 1900) return false;
	
	if(mes == '01' || mes == '03' || mes == '05' || mes == '07' || mes == '08' || mes == '10' || mes == '12'){
		if (dia > 31) return false;
	}
	else if( mes == '04' || mes == '06' || mes == '09' || mes == '11'){
		if(dia > 30) return false;
	}
	else if((ano % 4) != 0 && mes == '02' && dia > 28)
		return false;
	else if((ano % 4) == 0 && mes == '02' && dia > 29)
		return false;
	return true;
}

function lmp() {document.fnews.email.value = ''}
function goEm() {if(tstNews(document.fnews))document.fnews.submit()}
function tstEmail(email) {
	if(!email.value.match(/.*?@.*?\.[a-zA-Z][a-zA-Z]/) || email.value.match(/www/)) return false;
	return true;
}
function voltaTopo(id){
	var objDiv = document.getElementById(id);
	objDiv.scrollTop = "0px";
}
function e(mess, obj) {
	alert(mess);
	if(obj) obj.focus();
	return false;
}
/*function tstNum() {
	var tc = event.keyCode;
	if(event.ctrlKey || event.altKey) return;
	if(tc == 38 || tc == 35 || tc == 37 || tc == 36 || tc == 39 || tc==40 || tc==41 || tc==43 || tc==45 || tc==46 || tc==127 || tc <= 31 || (tc >= 48 && tc <= 57) || (tc>=96 && tc<=105)) return;
	event.returnValue=false;
}*/

function tstNum(evt)
{
 var charCode = (evt.which) ? evt.which : evt.keyCode
 if (charCode > 31 && (charCode < 48 || charCode > 57))
 return false;
 return true;
}

function tstNum2(evt)
{
 var charCode = (evt.which) ? evt.which : evt.keyCode
 if (charCode > 31 && ((charCode < 48 && charCode!=45)|| charCode > 57))
	return false;
 return true;
}

function tstMoney(campo) {
	var tc = event.keyCode;
	if(event.ctrlKey || event.altKey) return;
	if(tc == 110) tc = 188;
	if(tc == 188 && campo.value.lastIndexOf(',')!=-1) {
		event.returnValue=false;
		return;
	}
	if(tc == 109 || tc == 189 || tc==188 || tc==45 || tc==127 || tc <= 31 || tc==144 || (tc >= 35 && tc <= 40) || (tc >= 46 && tc <= 57) || (tc>=96 && tc<=105)) return;
	event.returnValue=false;
}
function ow(url, w, h) {
	var wd = window.open(url, "IMG", "width="+w+",height="+(h+30)+",location=no,menubar=no,personalbar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no");
	if(wd) wd.focus();
}

function tstDataFinal(data) {
	var res = null;
	if(!(res = data.value.split(/-/)) || res.length!=3) return e("Data Inv�lida", data);
	var dia = parseInt(res[0], 10);
	var mes = parseInt(res[1], 10);
	var ano = parseInt(res[2], 10);
	if(dia > 31) return 1; //Indique correctamente o dia da data
	if(mes > 12) return 2; //Indique correctamente o mês da data
	if(ano < 1900) return 3; //Indique correctamente o ano da data
	return true;
}

function tstsnd(f,rd) {
	if (rd.checked) return true;
	else for (x = 0; x < rd.length; x++) if (rd[x].checked) return true;
	return e("Por favor, selecione uma resposta");
}
function tstCB(rd) {
	if(rd.checked) return true;
	else for (x = 0; x < rd.length; x++) if (rd[x].checked) return true;
	return false;
}
function dn(url, func) {
	if(!func) func = dn1;
	var xd = null;
	try {
		xd = (vv_browser == 2?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest());
		if(xd) {
			xd.open("GET",url,true);
			xd.onreadystatechange=function() {if(xd.readyState == 4 && xd.status == 200) func(xd.responseText);};
    		xd.send(null);
  	 	}
    } catch(e) {}
}

var vv_browser = 0;
var vv_version = 0;
var vv_cookies = 0;
getVersion();

function getVersion() {
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	var is_nav = is_ie = 0;
	var res = null;
	if((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		&& (agt.indexOf('webtv')==-1)) {
		vv_browser = 1;
		if(is_major == 2) vv_version = 2;
		else if(is_major == 3) vv_servion = 3;
		else if(is_major == 4) vv_servion = 4;
		else if(is_major == 5) vv_version = 5;
		else if(is_major >= 5) vv_version = 6;
  	} else if(res = agt.match(/msie (\d+)\.(\d+)/)) {
		vv_browser = 2;
		if(is_major < 4) vv_version = 6;
		else if(res[1] == 5 && res[2] == 0) vv_version = 7;
		else if(res[1] == 5 && res[2]) vv_version = 8;
		else if(res[1] == 6 && !res[2]) vv_version = 9;
		else if(res[1] == 6 && res[2]) vv_version = 10;
	} else if(agt.indexOf("aol") != -1) {
		vv_browser = 4;
		if(is_major < 4) vv_version = 11;
		else if(is_major == 4 && agt.indexOf("msie 5.0")==-1) vv_version = 12;
	} else if(agt.indexOf("opera") != -1) vv_browser = 5;
	else if(agt.indexOf("webtv") != -1) vv_browser = 3;
	vv_cookies = (window.navigator.cookieEnabled?1:0);
}

function tstDataErro(data) {
	var res = null;
	if(!(res = data.value.split(/-/)) || res.length!=3) return false;
	var dia = parseInt(res[0], 10);
	var mes = parseInt(res[1], 10);
	var ano = parseInt(res[2], 10);
	if(dia > 31) return false;
	if(mes > 12) return false;
	if(ano < 1900) return false;
	return true;
}

