function SF(){this.loadingMsg="Aguarde...";this.tinyMCEClass="editor";this.arrayFromForm=function(form,camposNomeArray){var dataArray={};formId=$(form).attr("id");for(var i=0;i<camposNomeArray.length;i++){try{if($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').is("[type='radio']")){if($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]:checked').val()!=undefined){dataArray[camposNomeArray[i]]=$('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]:checked').val();}}
else{nomeIsArray=camposNomeArray[i].substr(-2,2);var isArray=false;if(nomeIsArray=="[]"){isArray=true;}
if($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').is("[type='checkbox']")){var items=[];$('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]:checked').each(function(){items.push($(this).val());});dataArray[camposNomeArray[i]]=items;}
else{if($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').is("."+this.tinyMCEClass)){dataArray[camposNomeArray[i]]=tinyMCE.get(($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').attr("id"))).getContent();;}
else{if($('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').val()!=undefined){if(isArray){var items=[];$('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').each(function(){items.push($(this).val());});dataArray[camposNomeArray[i]]=items.reverse();}
else{dataArray[camposNomeArray[i]]=$('#'+formId+" "+'[name="'+camposNomeArray[i]+'"]').val();}}}}}}
catch(ex){}}
return dataArray;}
this.saveForm=function(url,form,camposNomeArray,resultElementId){dataArray=this.arrayFromForm(form,camposNomeArray);$("#"+resultElementId).html(this.loadingMsg);$.post(url,dataArray,function(msg){$("#"+resultElementId).html(msg);});}
this.ajaxLoad=function(url,resultElementId,dataArray){$("#"+resultElementId).html(this.loadingMsg);$.post(url,dataArray,function(result){$("#"+resultElementId).html(result);});}
this.post=function(url,dataArray,callBack){$.post(url,dataArray,function(result){if(typeof(callBack)=="function"){callBack.call(this,result);}});}
this.ajaxAppend=function(url,resultElementId,dataArray){$.post(url,dataArray,function(result){$("#"+resultElementId).append(result);});}
this.callControllerMethodFromAnchor=function(url,resultElementId){$.post(url,{},function(result){if(resultElementId!=''&&resultElementId!=undefined){$("#"+resultElementId).html(result);}});}
this.callController=function(functionsName,resultElement,dataArray){var resultElementId="";resultElementId=resultElement;$("#"+resultElementId).html(this.loadingMsg);$.post(document.URL+"."+functionsName+".exit",dataArray,function(result){$("#"+resultElementId).html(result);});}}
sf=new SF();sf.loadingMsg="Processando...";$(document).ready(function(){var functionPrefix="::";$('a').click(function(e){var href=$(this).attr('href');if(href==undefined){href=$(this).attr('name');}
if(href.substring(0,functionPrefix.length)==functionPrefix){href=href.substring(2);var pArray=href.split(",");if(pArray[1]==undefined){var _resultId='';}
else{var _resultId=pArray[1];}
eval('sf.callControllerMethodFromAnchor'+"('"+document.URL+"."+href+".exit' , '"+_resultId+"'  )");return false;}
return true;});});
