// JavaScript Document
function AjaxFS(classe,funcao, idmenu, data_add){
	xajax_AjaxFS(classe,funcao, idmenu, data_add);
}
function limpaForm(quem){
	f = FIND(quem);
				for (i=0; i<f.length; i++) {
					if (f.elements[i].type == "checkbox") {
						f.elements[i].checked = false;
					}else if (f.elements[i].type == "radio") {
						f.elements[i].checked = false;					
					}else if (f.elements[i].type == "text" || f.elements[i].type == "password" || f.elements[i].type == "hidden" || f.elements[i].type == "textarea"){
						f.elements[i].value = '';
					}else if (f.elements[i].type == "select-one"){
						f.elements[i].value = '';
					}
				}
}


function process(v){
	if (v == 0){
		FIND('processando').style.display = 'none';
	}else{
		FIND('processando').style.display = 'block';
	}
	
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function FIND(item) {
	if( window.mmIsOpera ) return(document.getElementById(item));
	if (document.all) return(document.all[item]);
	if (document.getElementById) return(document.getElementById(item));
	return(false);
}

function PopUp(theURL,winName,features,pw,ph) { //v2.0

   w = screen.availWidth;
   h = screen.availHeight;

	
	var popW = pw, popH = ph;
	
	var leftPos = (w-popW)/2, topPos = (h-popH)/2;
	
	opcoes = (features ? features+',' : '')+'width='+pw+',height='+ph+',left='+leftPos+',top='+topPos;
	
	  window.open(theURL,winName,opcoes);
}

// history back
function initialize() {
            dhtmlHistory.initialize();
            dhtmlHistory.addListener(historyChange);
			//if (dhtmlHistory.isFirstLoad()) {
				//dhtmlHistory.add('home','coisa(\'inc\')');
			//}
}
function historico() {
	//alert('certim');
	var ancora;
	var f;
	var funcao;
	var funcao_arguments=''; 
	
	a= historico.arguments;
	for(i=0;i<a.length;i++){
		if(i==0){
			ancora=a[i];
			
		}else if(i==1){
			f=a[i];
		}else{
			funcao_arguments += '\''+a[i]+'\'';
			if(i<a.length){
				funcao_arguments += ',';
			}
		}
	}
	funcao_arguments = funcao_arguments.substring(0,funcao_arguments.length-1);
	funcao = f+'('+funcao_arguments+')';
	dhtmlHistory.add(ancora,funcao);
	//alert (funcao);
}
         
function historyChange(newLocation, historyData) {
	process(1);
	eval(historyData);
}
