/*******************************
function bannerTopo(src, tipo, width, height){
	if(height == undefined){
		height = "";
	}

	if(tipo == 'flash'){
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"')
		document.write(' width="'+width+'" height="'+height+'" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="'+src+'" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#F7F7F7" />');
		
		document.write('<embed src="'+src+'" quality="high" bgcolor="#F7F7F7" width="'+width+'" height="'+height+'"'); 
		document.write(' align="middle"  allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ');
		document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
	} else if(tipo == 'imagem'){
		document.write('<img src="'+src+'" width="'+width+'" height="'+height+'">');
	}
}

*************/


function bannerTopo(src, tipo, width, height,href,cod){
	if(height == undefined  || height == ''){
		textheight = '  ';
		height = 0;
	} else{
		textheight = ' height="'+height+'" ';
	}

	if(width == undefined  || width == ''){
		textwidth = '  ';
		width = 0;
	} else{
		textwidth = ' width="'+width+'" ';
	}



	if(tipo == 'flash'){
		srcnovo = src.replace('.swf','');

		if(height > 0){ 
			AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',width,'height',height,'title','','src',srcnovo,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie', srcnovo );
		} else{
			AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width',width,'title','','src',srcnovo,'quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie', srcnovo );
		} 
		document.write('<noscript><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
		document.write('codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"')
		document.write(' '+textwidth+' '+textheight+' align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="'+src+'" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="bgcolor" value="#F7F7F7" />');
		
		document.write('<embed src="'+src+'" quality="high" bgcolor="#F7F7F7" '+textwidth+' '+textheight+''); 
		document.write(' align="middle"  allowScriptAccess="sameDomain" type="application/x-shockwave-flash" ');
		document.write('pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object></noscript>');
	} else if(tipo == 'imagem'){
			if(cod == undefined  || cod == ''){
				cod = 0;
			}
			if(href != undefined  && href != ''){
				document.write('<a href="redirectbanner.php?a='+href+'&c='+cod+'" target="_blank" ><img src="'+src+'" '+textwidth+' '+textheight+' border="0"></a>');
			} else{
				document.write('<img src="'+src+'" '+textwidth+' '+textheight+' border="0">');
			}

	}
}


/*********************************
VALIDA EMAIL
*********************************/
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){ 
                    return true; 
                }
    }else{
        return false;
        }
}

function Trim(str){
	return str.replace(/^\s+|\s+$/g,"");
}

/*********************************
PERMITE SOMENTE NUMEROS NO CAMPO
onkeypress="return somenteNumero(event);"
*********************************/
function somenteNumero(e){
	if (!e) e = window.event;
	var tecla;		

	if(e.keyCode)    tecla = e.keyCode;
	else if(e.which) tecla = e.which; //Netscape 4.?	
	if ((tecla > 47 && tecla < 58) || (tecla == 44 && campo.value.indexOf(",") == -1) || (tecla == 8) || (tecla == 9))
		return true;
	else
		return false;
}

/*********************************
FORMATA CAMPO DATA
onkeydown="formataData(this,event)"
*********************************/
function formataData(campo,e){
	if (!e) e = window.event;
	var tecla;		
	if(e.keyCode)    tecla = e.keyCode;
	else if(e.which) tecla = e.which; //Netscape 4.?		
	if(e.target) 
		//Firefox
		objEv = e.target;
	else if(e.srcElement) 
		//IE
		objEv = e. srcElement;			
	vr = objEv.value;
	vr = vr.replace(".","");
	vr = vr.replace("/","");
	vr = vr.replace("/","");
	tam = vr.length + 1;
	if (tecla != 9 && tecla != 8) {
		if (tam > 2 && tam < 5) {
			objEv.value = vr.substr(0,tam - 2) + '/' + vr.substr(tam - 2,tam);
		}
		if (tam >= 5 && tam <= 10) {
			objEv.value = vr.substr(0,2) + '/' + vr.substr(2,2) + '/' + vr.substr(4,3);
		}
	}
}


//nova variavel para jquery
var j = jQuery.noConflict();
function escondercomtimeout(){
	j("#divEsconde").fadeOut();
	j("#divMsg").fadeOut();
}

function setarEsconder(tempo){
	if(tempo == undefined){
		tempo = 3000;	
	}
	setTimeout(escondercomtimeout, tempo);
}
//ajax
j(window).ajaxStart(function(){
	j("#divEsconde").fadeIn();
	j("#divMsg").html('Salvando...');
	j("#divMsg").fadeIn();

});

j(window).ajaxStop(function(){
	//window.status = 'fim';
});

j(window).ajaxError(function(request, settings){
//	window.status = "Error requesting page " + settings.url;
});

//