// JavaScript Document
function Jornais(){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="180" height="80">');
	document.write('<param name="movie" value="/admgeral/img/jornais.swf" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="flashvars" value="jornal=otempobetim">');
	document.write('<embed src="/admgeral/img/jornais.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="180" height="80" flashvars="jornal=otempobetim" wmode="transparent"></embed>');
	document.write('</object>');
}

function Flash(imagem,largura,altura,wmode,flashvars){
	wmode = wmode || 'transparent';
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="'+largura+'" height="'+altura+'">');
	document.write('<param name="movie" value="'+imagem+'">');
	document.write('<param name="quality" value="high">');
	document.write('<param name="wmode" value="'+wmode+'">');
	if(flashvars!="") document.write('<param name="flashvars" value="'+flashvars+'">');
	document.write('<embed src="'+imagem+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+largura+'" height="'+altura+'" wmode="'+wmode+'" flashvars="'+flashvars+'"></embed>');
	document.write('</object>');
}

function Promocao(IdPromocao){
	var largura_pagina = window.screen.width;
	var left = eval((largura_pagina/2)-370);
	var top = 30;		
	window.open("/promocoes/?IdPromocao="+IdPromocao,"","width=750,height=550,scrollbars=no,status=yes,top="+top+",left="+left);	
}

function AjaxLib(){
	
	var req = null;
    if (window.XMLHttpRequest) { // Mozilla/Firefox/Safari
        req = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
	if (req) {
		this.processa=function(arquivo,op,valores,tiporetorno,funcao,metodo){
		
			metodo      = metodo || 'GET';
			tiporetorno = tiporetorno || 'TEXT';
			valores     = valores || '';
			funcao      = funcao || ProcessaRetorno;
			var resultado = '';
			
			if(arquivo.indexOf("?op=")>-1){
				op = arquivo.substr(eval(arquivo.indexOf("?op=")+4),arquivo.length) || op;
				var arquivo = arquivo.substr(0,arquivo.indexOf("?op="));			
			}
						
			var variaveis = 'op='+encodeURI(op)+'&'+valores;
			for(xx=0;xx<variaveis.indexOf('&&');xx++){variaveis = variaveis.replace('&&','&');}
						
			req.onreadystatechange = function(){
				if (req.readyState == 4) {
			        if (req.status == 200 || req.status == 0) {	
						if (tiporetorno=='XML'){ resultado=req.responseXML; }else{ resultado=req.responseText; }
						if (req.responseText == '') return false; // nao tem retorno
						if (funcao) funcao(op,resultado);
	    			} else {
            			switch(req.status){
                                case 204: { MsgAlerta("Erro Ajax: O servidor n&atilde;o respondeu ao chamado."); break }
                                case 400: { MsgAlerta("Erro Ajax: Endere&ccedil;o inv&aacute;lido."); break }
                                case 403: { MsgAlerta("Erro Ajax: Voc&ecirc; n&atilde;o possui permiss&atilde;o para acessar esse arquivo."); break }
                                case 404: { MsgAlerta("Erro Ajax: Arquivo n&atilde;o encontrado."); break }
                                case 500: { MsgAlerta("Erro Ajax: Erro interno do servidor."); break }
                                case 502: { MsgAlerta("Erro Ajax: Servidor ocupado."); break }
                                case 503: { MsgAlerta("Erro Ajax: O servidor n&atilde;o respondeu no tempo limite."); break }
                                 default: { MsgAlerta("Erro Ajax: Algum erro ocorreu ao carregar este conte&uacute;do."); break }
                        }
        			}
    			}				
			}
			variaveis=this.antiCache(variaveis);
			
			if(metodo.toUpperCase()=='POST'){ var arquivofinal = arquivo; } else { var arquivofinal = arquivo+'?'+variaveis; var variaveis=null; }
			
			req.open(metodo, arquivofinal, true);
			req.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=iso-8859-1");
			req.send(variaveis);
			
		}
		this.antiCache = function(aurl){
    		var dt = new Date();
       		return aurl + "&" + encodeURI(Math.random() + "_" + dt.getTime());
	    } 
	}

}