/******************************************************
Arquivo para funções javascript gerais que nao se encadram nos outros arquivos js.

TODO:
  - 
******************************************************/

/**
* Metodo que inclui um elemento html em um formulario.
* @param objeto DOM do tipo formulário.
*/
function incluirCampoForm(form,type,name,id,value){
	if(typeof(name)=='undefined') return;
	if(typeof(type)=='undefined') type ='hidden';
	if(typeof(id)=='undefined') id ='';
	if(typeof(value)=='undefined') value ='';

//	alert('name:'+name+' - '+'type:'+type		);

  var input = document.createElement('input');
  input.setAttribute('type',type);	  
  input.setAttribute('name',name);
  input.setAttribute('name',id);
  input.setAttribute('value',value);		  
  form.appendChild(input);		  
}

/**
* Criar formulário padrao para ser postado.
* 
*/
function createFormNav(nameForm,o){
	try{
		if(typeof(nameForm)=='undefined'){ 
			nameForm='frmSistema';
		}	

		if(typeof(o.act)=='undefined'){ 
			o.act='index.adm.php';
		}			

	  var form = document.createElement('form');
	  form.setAttribute('name',nameForm);	
	  form.setAttribute('id',nameForm);

		incluirCampoForm(form,'hidden','modulo','modulo',o.modulo);
		incluirCampoForm(form,'hidden','submodulo','submodulo',o.submodulo);
	  incluirCampoForm(form,'hidden','acao','acao',o.ac);
	  	
		document.body.appendChild(form);

		form.setAttribute('method',"post");	
		form.setAttribute('action',o.act);	
		return form;
	
	}catch(e) {
	  alert('Erro: '+e.message);
	}  
}

/**
* Método para incluir swf via js e evitar bordar de ativação do IE
*
*/
function flash(file, width, height, trans){
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + width + "' height='" + height + "'>");
    document.write("<param name='movie' value='" + file + "'>");
    document.write("<param name='quality' value='high'>");
    if(trans==true)
			document.write("<PARAM NAME=wmode VALUE=transparent>");
		document.write("<embed src='" + file + "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + width + "' height='" + height + "'></embed>");
    document.write("</object>");
}


