(function($) {
	var cache = [];
	$.preLoadImages = function() {
	    var args_len = arguments.length;
	    for (var i = args_len; i--;) {
	    	var cacheImage = document.createElement('img');
		    cacheImage.src = arguments[i];
	    	cache.push(cacheImage);
		}
	}
})(jQuery)

function confirmarRemover(item, link) {
	if (confirm("Deseja excluir o item "+item+"?"))
		window.location.href=link;
}
function link(link) {
	window.location.href=link;
}
function linkPai(link) {
	//window.opener.location.href=link;
	
	pai = window.opener;
	//if (pai.closed)
	if (pai==null) {
		window.open(link);
	}	
	else {
		pai.location.href=link;
		pai.focus();
	}
}
function popUp(link,width,height,scroll) {
    
 	var parametro = "top=0,left=0,titlebar=yes,menubar=no,resizable=yes,status=1,width="+width+",height="+height;
	 
    if (scroll==1)	
        parametro += ",scrollbars=yes";
	 	
    var janela = window.open(link,"",parametro);
    janela.focus();
}
function fullPopUp(link,scroll) {
            
	var parametro = "top=0,left=0,titlebar=yes,menubar=no,resizable=yes,status=1";
	 
    if (scroll==1)	
        parametro += ",scrollbars=yes";
	 	
    var janela = window.open(link,"",parametro);
    janela.focus();    
    janela.resizeTo(screen.availWidth,screen.availHeight);
}
function fullHeightPopUp(link,width,scroll) {
            
	var parametro = "top=0,left=0,titlebar=yes,menubar=no,toolbar=no,resizable=yes,status=1";
	 
    if (scroll==1)	
        parametro += ",scrollbars=yes";
	 	
    var janela = window.open(link,"",parametro);
    janela.focus();    
    janela.resizeTo(width,screen.availHeight);
}

function FCKEditor(textarea, toolbar, width, height) {
	var oFCKeditor = new FCKeditor(textarea) ;
	oFCKeditor.ToolbarSet = toolbar;
	oFCKeditor.BasePath = 'conteudo/svn/js/fckeditor/';
	oFCKeditor.Height = height;
	oFCKeditor.Width = width;
	
	oFCKeditor.AutoDetectPasteFromWord = false ;
	oFCKeditor.ForcePasteAsPlainText = true ;
	//oFCKeditor.Config['SkinPath'] = 'conteudo/svn/js/fckeditor/editor/skins/silver/' ;
	
    //oFCKeditor.EditorAreaCSS = ['http://localhost/conteudo/svn/css/noticias.css'];
    //oFCKeditor.EditorAreaCSS = ['http://localhostconteudo/svn/css/fckeditor.css'];
    oFCKeditor.ReplaceTextarea();
}

//--

function desabilitar(botao) {
    botao.value="Aguarde...";
    botao.disabled=true;
    //no ie, ao desabilitar o botao, o formulario nao eh enviado, entao entao envia com um submit
    if (document.all)
        botao.form.submit();
    botao.style.color = "#8B8B8B";
    botao.style.borderColor = "#8B8B8B";
}

function topo() {
    var link = window.location.href;
    if (link.indexOf("#")!=-1)
        link = link.substring(0,link.lastIndexOf("#"));
    window.location.href = link + "#topo";
}


function focusCampo(id, msg) {
	if (id.value==msg)
		id.value="";
}
function blurCampo(id, msg) {
	if (id.value=="")
		id.value=msg;
}

function verificarEnter(e) {
    teclaAtual = e.keyCode;
    
    //enter, enviar formulario
    if (teclaAtual==13) {
        loginAjax();
        
        
        if (typeof(e.preventDefault)=='function'){
        	e.preventDefault();
        } else {
        	e.returnValue = false;
            e.keyCode = 0;
        }
        return false;
    }
    
    //return true;
}   
//--

carregarFlashUpload = function(corFundo, hide, _op, _width, _height, id) {	
    
    var _allowedExt = '*.*';
    var _allowedExtDescr = '.*';
    
	var swf = 'jqUploader.swf';
    		
    	
	if (id==null) {
		id = 'uploadAnexo';
	}
	
	$('#'+id).jqUploader({
		width:_width,
		height:_height,
		background:corFundo,
		barColor:'007a37',
		src: appName+'/conteudo/svn/js/jqUploader/'+swf,
		allowedExt: _allowedExt,
		allowedExtDescr: _allowedExtDescr,
		startMessage: 'Clique em BUSCAR para selecionar um arquivo',
		errorSizeMessage: 'Arquivo maior que o limite',
		validFileMessage: 'OK, Clique em ENVIAR!',
		progressMessage: 'Aguarde, o arquivo está sendo enviado',						
		endMessage: 'OK, arquivo enviado com sucesso',
		hideSubmit: hide,
		params: {op:_op} });
    
}

