// usada para marcar os checks que tem nos arquivos lst
function checkAll( n, fldName ) {
  if (!fldName) {
     fldName = 'cb';
  }
	var f = document.adminForm;
	var c = f.toggle.checked;
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = eval( 'f.' + fldName + '' + i );
		if (cb) {
			cb.checked = c;
			n2++;
		}
	}
	if (c) {
		document.adminForm.boxchecked.value = n2;
	} else {
		document.adminForm.boxchecked.value = 0;
	}
}


function hideMainMenu()
{
	document.adminForm.hidemainmenu.value=1;
}

function isChecked(isitchecked){
	if (isitchecked == true){
		document.adminForm.boxchecked.value++;
	}
	else {
		document.adminForm.boxchecked.value--;
	}
}

/**
* Default function.  Usually would be overriden by the component
*/
function submitbutton(pressbutton) {
	submitform(pressbutton);
}

/**
* Submit the admin form
*/
function submitform(pressbutton){
	document.adminForm.acao.value=pressbutton;
	try {
		document.adminForm.onsubmit();
		}
	catch(e){}
	document.adminForm.submit();
}

/**
* Submit the control panel admin form
*/
function submitcpform(sectionid, id){
	document.adminForm.sectionid.value=sectionid;
	document.adminForm.id.value=id;
	submitbutton("edit");
}

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; }
    obj.visibility=v; }
}

function hidechat()
{
	MM_showHideLayers('Layer1','','hide');
	MM_showHideLayers('Layer2','','show');
	MM_showHideLayers('Layer3','','hide');
	document.getElementById('tab_esquerda').style.width='5px';
	document.getElementById('layer1').style.width='1px';
	document.getElementById('layer1').style.height='1px';
}

function showchat()
{
	MM_showHideLayers('Layer1','','show');
	MM_showHideLayers('Layer2','','show');
	MM_showHideLayers('Layer3','','show');
	document.getElementById('tab_esquerda').style.width='150px';
}

function isNum( caractere ) 
  
{ 
  
var strValidos = "0123456789" 
  
if ( strValidos.indexOf( caractere ) == -1 ) 
  
return false; 
  
return true; 
  
} 
  
function validaTecla(campo, event) 
  
{ 
  
var BACKSPACE= 8; 
  
var key; 
  
var tecla; 
  
  
  
CheckTAB=true; 
  
if(navigator.appName.indexOf("Netscape")!= -1) 
  
tecla= event.which; 
  
else 
  
tecla= event.keyCode; 
  
  
  
key = String.fromCharCode( tecla); 
  
//alert( 'key: ' + tecla + ' -> campo: ' + campo.value); 
  
  
  
if ( tecla == 13 ) 
  
return false; 
  
if ( tecla == BACKSPACE ) 
  
return true; 
  
return ( isNum(key)); 
  
} 
function procura_produto()
{
    window.open("includes/pprodutos.php",
   "dataitem", "location=no,menubar=no,scrollbars=yes,status=yes, width=500, height=400");
}
function procura_cliente(id)
{
	if(id == 1)
		cam = "includes/pclientes.php?id=1";
	else
		cam = "includes/pclientes.php";
	
    window.open(cam,
   "dataitem", "location=no,menubar=no,scrollbars=yes,status=yes, width=500, height=400");
}
	