	var idCache = new Array();
	

function antiCacheRand(aurl){                
	var dt = new Date();                
	if(aurl.indexOf("?")>=0){
		return aurl + "&" + encodeURI(Math.random() + "_" + dt.getTime());
	}else{ 
		return aurl + "?" + encodeURI(Math.random() + "_" + dt.getTime());
	}
}


function update(ident, div, div2) {
if(ident != false) {
       $(div).submit(function() {
        
           $(div).ajaxStart(function() {
		   	
               $(div2).html("").show();
           });
         
           var options = {
               target: div2, 
               url: "modules/cmd.php",
               type: "post", 
               success: function(contain) {
               $(div2).html(contain).show();
               }
           }
           
           $(div).ajaxForm(options);
		   
       });
	   ident = false;
   }
}

function formMethod(ident, form, div2, url) {
if(ident != false) {
       $(form).submit(function() {
        
           $(form).ajaxStart(function() {
		   	
           $(div2).html("").show();
           });
         
           var options = {
               target: div2, 
               url: url,
               type: "post",
               success: function(contain) {
               $(div2).html(contain).show();
               }
           }
           
           $(form).ajaxForm(options);
		   
       });
	   ident = false;
   }
}



function detail(aurl, detail, user, id, type, controler) {
	if(detail != "remove") {
	URL = antiCacheRand(aurl);
	$.get(URL,{ user: user, id: id, type: type, detail: detail },function(data){ $(controler).html(data); });
	$(controler).fadeIn("slow");
	} else {
	$(controler).hide();
	}
}

function urLoader(aurl, controler, module) {
$(function() {	URL = antiCacheRand(aurl);
	$(controler).html("<div style='width:100%; height:100%; vertical-align:middle; display:table-cell; margin-top:240px; position: absolute;' align='center'><div align='center' style='position: relative; width:270px; top:-5%;'><span class='draw1'></span><span class='draw2'></span><span class='draw3'></span><span class='draw4'></span><div class='backgroundWhite' style='width:256px; height:40px; align:center; vertical-align:middle;' align='center'><img src='imagens/loading.gif' align='center' style='vertical-align:middle; margin-top:12px;'></div><span class='draw5'></span><span class='draw6'></span><span class='draw7'></span><span class='draw8'></span></div></div>");
	$.get(URL,{ module : module },function(data){ $(controler).html(data); });
});
}




function createDialog(id, divID, width, height, titule) {
		if(!$(divID).dialog('isOpen')) {
			$(divID).dialog({
				bigframe: true,
			    height: height,
				maxHeight: height,
				minHeight: height,
				width: width,
				maxWidth: width,
				minWidth: width,
				id: id,
				modal: false,
                autoOpen: false,
				resizable: false,
				backgroundColor: '#ffffff',
				title: titule
							
			});
		}

}


function ativarDialog(id, divID, aurl, user, temp, width, height, title) {
	if(idCache[id] == null) {
			$(divID).html("");
			$(divID).html("<div style='width:100%; height:100%; vertical-align:middle; display:table-cell; top: 50%; position: absolute;' align='center'><div align='center' style='position: relative; width:270px; top:-5%;'><span class='draw1'></span><span class='draw2'></span><span class='draw3'></span><span class='draw4'></span><div class='backgroundWhite' style='width:256px; height:40px; align:center; vertical-align:middle;' align='center'><img src='imagens/loading.gif' align='center' style='vertical-align:middle; margin-top:12px;'></div><span class='draw5'></span><span class='draw6'></span><span class='draw7'></span><span class='draw8'></span></div></div>");
			URL = antiCacheRand(aurl);
			$.get(URL,{ id: id, user: user, temp: temp, url: URL, divID: divID },function(data){ $(divID).html(data); });
			createDialog(id, divID, width, height, title);
			idCache[id] = true;
			$(divID).dialog('open');
			}

}

