function addFlash(_src,_w,_h){
	var novoHtml = '';
 	novoHtml += '  <OBJECT height="'+_h+'" width="'+_w+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
	novoHtml += '  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
	novoHtml += '  wmode="transparent" ALIGN="">';
	novoHtml += '    <PARAM NAME="movie"   VALUE="'+_src+'">';
	novoHtml += '    <PARAM NAME="quality" VALUE="high">';
	novoHtml += '    <PARAM NAME="wmode"   VALUE="transparent">';
	novoHtml += '    <PARAM NAME="bgcolor" VALUE="#FFFFFF">';
	novoHtml += '    <EMBED wmode="transparent" src="'+_src+'" pluginspage="http://www.macromedia.com/go/getflashplayer" height="'+_h+'" width="'+_w+'"></EMBED>';
	novoHtml += '  </OBJECT>';
  document.write(novoHtml);
}

// Setando as variáveis de aumento de fonte

var defaultFontSize = 120;
var maximumFontSize = 400;
var currentFontSize = defaultFontSize;

function resetFontSize() {
	resetSize = defaultFontSize - currentFontSize;
	changeFontSize(resetSize);
}

function changeFontSize(sizeDifference) {
	currentFontSize = currentFontSize + sizeDifference;

	if(currentFontSize > maximumFontSize) { alert('Você já chegou ao tamanho máximo!'); currentFontSize = 300;  }
	else if(currentFontSize < 60) { alert('Você já chegou ao tamanho mínimo!'); currentFontSize = 60;  }

	setFontSize(currentFontSize);
}

function setFontSize(fontSize){ document.getElementById('areaTexto').style.fontSize = fontSize + '%'; }


function areaTexto(x) {
	if (x == "A") { changeFontSize(10); }
	else if (x == "D") { changeFontSize(-10); }
	else { resetFontSize(); }
}

function fncEsconderBanner()
{
  document.getElementById("bannerzao").style.display = 'none';
}

function open_center(url, name, params, Wwidth, Wheight) {
    Swidth = screen.width;
    Sheight = screen.height;

    Wleft = Math.floor((Swidth / 2) - (Wwidth / 2) - 8);
    Wtop = Math.floor((Sheight / 2) - (Wheight / 2) - 20);

    params = params+",left="+Wleft+",top="+Wtop+",width="+Wwidth+",height="+Wheight;

    window.open(url, name, params);
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function URLDecode(txtEncoded) {
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef";
   var plaintext = "";
   var i = 0;
   if (txtEncoded > '') {
     while (i < txtEncoded.length) {
         var ch = txtEncoded.charAt(i);
  	   if (ch == "+") {
  	       plaintext += " ";
  		   i++;
  	   } else if (ch == "%") {
  			if (i < (txtEncoded.length-2)
  					&& HEXCHARS.indexOf(txtEncoded.charAt(i+1)) != -1
  					&& HEXCHARS.indexOf(txtEncoded.charAt(i+2)) != -1 ) {
  				plaintext += unescape( txtEncoded.substr(i,3) );
  				i += 3;
  			} else {
  				alert( 'Bad escape combination near ...' + txtEncoded.substr(i) );
  				plaintext += "%[ERROR]";
  				i++;
  			}
  		} else {
  		   plaintext += ch;
  		   i++;
  		}
  	} // while
  }
  return plaintext;
};

function GetQueryString(strParam) {
  hu = window.location.search.substring(1);

  gy = hu.split("&");

  for (i=0;i<gy.length;i++) {
    ft = gy[i].split("=");
    if (ft[0] == strParam) {
      return ft[1];
    }
  }
}

function addFav(){
    var url      = "http://www.famem.org.br";
    var title    = "FAMEM - Federação dos Municípios do Estado do Maranhão";
    if (window.sidebar) window.sidebar.addPanel(title, url,"");
    else if(window.opera && window.print){
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
    }
    else if(document.all){window.external.AddFavorite(url, title);}
}

window.addEvent('domready',function(){
	var nS1 = new noobSlide({
		box: $('links2slide'),
		mode: 'vertical',
		interval: 10000,
		items: [0,1],
		size: 330,
		autoPlay: true,
		addButtons: {
			previous: $('prev1'),
			next: $('next1')
		}
	});
	
	
	var nS3 = new noobSlide({
		box: $('syslide'),
		items: [0,1],
		size: 725,
		interval: 20000,
		autoPlay: true,
		addButtons: {
			previous: $('prev3'),
			next: $('next3')
		}
	});

});


function getfileextension(inputId) { 
	var fileinput = inputId; 
	if (!fileinput ) { return ""; }
	else {
		if (fileinput.length == 0) { return ""; }
		else {
			var dot = fileinput.lastIndexOf("."); 
			if (dot == -1 ) { return ""; }
			else {
				var extension = fileinput.substr(dot,fileinput.length); 
				return extension; 
			}
		}
	}
}

function renderBanner3(input, link, width, height) {
	if (getfileextension(input) == '.swf') { addFlash(input, width, height); } 
	else { document.write('<a href="'+link+'" target="_blank"><img src="'+input+'" width="'+width+'" height="'+height+'" /></a>'); }
}

function gallerySlicer(order)
{
	var quantidade = $('sysgalleries').getElements('div');
	var paginas = Math.floor(quantidade.length / 28);
	if (paginas < (quantidade.length / 28)) { paginas++; }

	if (order == 'slice')
	{		
		/*for (y = 1; y <= paginas; y++)
		{
			var div = new Element('div', {id: 'pag-'+y });
			div.inject($('sysgalleries'));
		}
		var x = 1;
		var multiplier = 1;
		
		$('sysgalleries').getElements('div').each(function (el){
														  
			if (x <= ('28' * multiplier))
			{
				el.inject($('pag-'+multiplier));
			}
			else
			{
				multiplier++;
				if ($('pag-'+multiplier))
				{
					el.inject($('pag-'+multiplier));
				}
			}
			x++;
		});
				
		
		$('sysgalleries').getElements('div').each(function (el){
			el.style.display = 'none';
		});
		
		$('pag-1').style.display = 'inherit';
		
		
		var finalElement = new Element('div', {id: 'slicer', html: 'P&aacute;ginas: '});
		finalElement.inject($('sysgalleries'));

		for (z = 1; z <= paginas; z++)
		{
			var link = new Element('div', {id: 'pag-'+z, href: 'javascript:void(0)', onclick: "gallerySlicer('"+z+"')", html: z});
			link.inject(finalElement);
		}*/
		
	}
	else
	{
		$('sysgalleries').getElements('div').each(function (el){
			if (el.id != 'slicer')
			{
				el.style.display = 'none';
			}
		});
		
		$('pag-'+order).setStyles({'display' : 'block'});
	}

}
