//***COPIA O ENDEREÇO DE COBRANÇA P/ ENTREGA******************************************
//Obs: Os campos devem seguir a mesma nomenclatura
function CopiaEndereco(){
    
    document.all["txtEndereco_e"].value = document.all["txtEndereco_c"].value;
    document.all["txtCidade_e"].value = document.all["txtCidade_c"].value;
    document.all["cboUF_e"].selectedIndex = document.all["cboUF_c"].selectedIndex;
    document.all["txtCEP_e"].value = document.all["txtCEP_c"].value;
}

//NUMÉRICOS
//Uso: onKeyPress="return apenasnumericos(event);"
function apenasnumericos(caracter) {
 if(document.all) { // Internet Explorer
  var tecla = event.keyCode;
 }
 else {
  if(document.layers) { // Nestcape
   var tecla = caracter.which;
  }
 }

 if(tecla > 47 && tecla < 58) { // numeros de 0 a 9
  return true;
 }
 else {
  if (tecla != 8) { // backspace
   return false;
  }
  else {
   return true;
  }
 }
}

//Verifica se string é numérica
function isNum( param ) 
{ 
	var sPermitidas = "0123456789";
	var s;
	var i;
	for(x=0; x < param.toString().length; x++)
	{
		s = param.toString().substr(x,1);
		i = sPermitidas.toString().indexOf(s);
		if(i < 0)
		{
			return false;
		}
	}
	return true;
} 

function imagemProdutoFalhou(idImg, tipoImg)
{
	switch(tipoImg)
	{
		case "produto":
			document.images[idImg].src = '/site/images/ico_img_nao_disponivel.gif';
			break;
		
		case "modelo":
			document.images[idImg].src = '/site/images/ico_img_mod_nao_disponivel.gif';
			break;
	}
}

function ImageZoom(fileUrl)
{
	var linkImageZoom = '/site/Library/ImageZoom.htm';
	showModalDialog(linkImageZoom, fileUrl,'help:no;status:no;scroll:auto;edge:raised;dialogWidth:300px; dialogHeight:400px;center:yes');
}


////////////////////////////////////////////
// Layer "Aguarde" (centralizada)
////////////////////////////////////////////

document.write("<div ID='aguarde' name='aguarde' style='z-index: 99999; position:absolute; display:block; width:200; height: 50px; top: 0px; left: 0px; visibility:hidden; filter:shadow(color=#999999,direction=120,enabled=5)'><table cellspacing='0' cellpadding='0' border='0' bgcolor='#FF9900' style='border: 1px solid black;padding:7px;' class='fonteNormal'>");
document.write("<tr><td><img src='/site/images/circulo_loading.gif' width='27' height='27' border='0' align='left' vspace='2'>&nbsp;&nbsp;&nbsp;<font color='white'><b>Por favor, aguarde.</font><br>&nbsp;&nbsp;&nbsp;Processando...</b></td></tr></table></div>");

function fixar(vLeft, vTop) 
{
{
  document.all['aguarde'].style.position = 'absolute';
  document.all['aguarde'].style.posLeft = document.body.scrollLeft + vLeft;
  document.all['aguarde'].style.posTop = document.body.scrollTop + vTop;
}
  //setTimeout('fixar()',100);
}

function showAguarde()
{
    with(document.getElementById('aguarde').style){
        
        var vLeft = ((document.body.clientWidth - parseInt(width)) / 2);
        var vTop = ((document.body.clientHeight- parseInt(height)) / 2);
        left = vLeft;
        top = vTop;
        visibility = 'visible';
        fixar(vLeft, vTop);
    }
}
