// Função Popup: <a href="arquivo.ext" onclick="popup(this.href,'360','535','1'); return false;"></a>
function popup(url,w,h,s) {
	var oW=window.open(url,'popup','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.availWidth-w)/2)+-10)+',top='+(((screen.height-h)/2)+-10));
}

//Função para impressão
function imprimir(){
	popimpressao = window.open('', '_blank', 'width=751,height=450,left=0,top=0,scrollbars=yes,resizable=no,menubar=no,toolbar=no');

	with (popimpressao.document) {
		write('<html><head><title></title></head>');
		write('<link rel="stylesheet" href="../../css/default.css" type="text/css">');
		write('<link rel="stylesheet" href="../../css/print.css" type="text/css">');
		write('<body>');
		write(document.getElementById("impressao").innerHTML);
		write('</body></html>');
		close();
		}
        popimpressao.print();
}

/* ############# Função Over em Imagens ###############*/
function onoff(imgName,state) {
	if(document.images[imgName].src.indexOf("_atv") == -1 ) {
		document.images[imgName].src = eval(imgName+state+".src");
	}
}
//##################### função do select #################*/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


function soNumeros(e){

	 var key;
	 var keychar;

	 if (window.event) {
		key = window.event.keyCode;
	 } else if (e) {
		key = e.which;
	 } else {
		return true;
	 }

	 keychar = String.fromCharCode(key);

	 // teclas de controle
	 if ((key==null) || (key==0) || (key==8) ||
		  (key==9) || (key==13) || (key==27) ) {
		return true;
	 } else if ((("0123456789").indexOf(keychar) > -1)) {
		return true;     
	 } else {
		return false;
	 }
}

	function carregaComboAjax(link, destino, pvazio, strCabecalho ) 
	{
		AjaxRequest.get(
			{	'url': link
				,'onError': function (req){	alert ( req.responseText );	}
				,'onSuccess':function(req) { 

					var itens = new String ( req.responseText );

					if (itens == 'vazio')
					{
						while(destino.options.length > 0) 
							destino.options[0]=null;
						destino.options[destino.options.length] = new Option( strCabecalho , '' )
						return;
					}

					//divide em vírgula
					var vet = itens.split( ',' );

					//Limpa Combo
					while(destino.options.length > 0) 
						destino.options[0]=null;

					//Verifica se o array possui itens

					if (vet.length > 0)
					{

						if(pvazio != 0)
							destino.options[destino.options.length] = new Option( strCabecalho , '' )

						for ( i = 0 ; i < vet.length ; i++ )
						{
							var strId = vet[i].split( '|' );
							if (strId[1] != '' && strId[0] != '')
							{
								destino.options[destino.options.length] = new Option( strId[1] , strId[0] )
							}
						}
					}				
				}
			}
		);
	}


String.prototype.trim = function(){
	return this.replace(/(\s*)|(\s*$)/g, "");
}
