function goToURL(valor) {
	window.location = valor;
}

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 centro(x) {
	if (x == "A") { changeFontSize(10); }
	else if (x == "D") { changeFontSize(-10); }
	else { resetFontSize(); }
}

function areaTexto(x) {
	if (x == "A") { changeFontSize(10); }
	else if (x == "D") { changeFontSize(-10); }
	else { resetFontSize(); }
}

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 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);
}

function renderBanner2(input) {
	if (getfileextension(input) == '.swf') { addFlash(input, '615', '215'); } 
	else { document.write('<img src="'+input+'" />'); }
}

function sexyLightBox()
{
	SexyLightbox = new SexyLightBox({
	color:'white',
	dir: '/new/css/sexyimages',
	OverlayStyles:{
		'background-color':'#CFE6FF',
		'opacity': 0.6
	}
	});
}


function gallerySlicer(order)
{
	var quantidade = $('sysgalleries').getElements('a');
	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('a').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('a', {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).style.display = 'inherit';
	}

}

var gallery = {
	options: {
		delay: 5000,
		howmany: 3,
		wrapper: 'highlights',
		childclass: 'show-items'
	},
	
	start: function () {
		var id = 1;
		var countchild = 0;
		$$('.'+gallery.options.childclass).each(function () {
			countchild++;
		});
		
		gallery.options.howmany = countchild;
		
		if (countchild > 0)
		{
			var periodTime = function () { gallery.nextItem(); }
			var periodicalFunctionVar = periodTime.periodical(gallery.options.delay);
			
			var ul = new Element('ul', {			 
				'events' : {
					'mouseenter': function() { $clear(periodicalFunctionVar); },
					'mouseleave': function() { periodicalFunctionVar = periodTime.periodical(gallery.options.delay); }
				}
				
			});
			
			
			
			for (z = 1; z < Math.floor(gallery.options.howmany + 1); z++)
			{
				new Element('a',{
					'href': 'javascript:void(0)',
					'html': z,
					'id': 'select-'+z,
					'class' : 'not-selected',
					'events' : {
						'click': function () {
							$clear(periodicalFunctionVar);
							var targetid = this.id;
							gallery.changeTo(targetid.replace('select-',''));
						}
					}
				}).inject(new Element('li').inject(ul));
			}
			
			new Element('a', {
				'class' : 'arrow-left',
				'href' : 'javascript:void(0)',
				'html' : '&nbsp;',
				'events' : {
					'mouseenter': function() { $clear(periodicalFunctionVar); },
					'mouseleave': function() { periodicalFunctionVar = periodTime.periodical(gallery.options.delay); },
					'click': function () {
							$clear(periodicalFunctionVar);
							gallery.previousItem();
					}
				}
			}).inject($(gallery.options.wrapper));
			
			new Element('a', {
				'class' : 'arrow-right',
				'href' : 'javascript:void(0)',
				'html' : '&nbsp;',
				'events' : {
					'mouseenter': function() { $clear(periodicalFunctionVar); },
					'mouseleave': function() { periodicalFunctionVar = periodTime.periodical(gallery.options.delay); },
					'click': function () {
							$clear(periodicalFunctionVar);
							gallery.nextItem();
					}
				}
			}).inject($(gallery.options.wrapper));
			
			ul.inject($(gallery.options.wrapper));
			
			$('select-1').className = 'selected';
			
			$$('.'+gallery.options.childclass).each(function (el) { 			
				if (id == 1) {
					el.set({
						'id' : id,
						'rel' : 'active'
					});
					el.setStyles({ 'opacity':'1' });
					
					el.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});
				}
				else {
					el.set({
						'id' : id
					});
					el.setStyles({ 'opacity':'0' });
				}
				
				id++;			
			});
		}
	},
	
	changeTo: function (target) {
		$$('.'+gallery.options.childclass).each(function (el) {

			el.setStyles({ 'opacity':'0' });
			el.erase('rel');
			
			if (el.get('id') == target)
			{
				el.set({
					'rel' : 'active'
				});	
				
				for (z = 1; z <= gallery.options.howmany; z++)
				{
					$('select-'+z).set('class', 'not-selected');
				}
				
				$('select-'+target).set('class', 'selected');
				
				el.setStyles({ 'opacity':'1' });
				var htmlflash = el.get('html');
				el.empty();
				el.set('html',htmlflash);
				
				el.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});

			}
		});
	},
	
	nextItem: function () {
		$$('.'+gallery.options.childclass+'[rel=active]').each(function (el) {
			
			el.erase('rel');
			
			var theid = parseFloat(el.get('id'));
			var nextid = Math.floor(theid + 1);
						
			if (nextid == Math.floor(gallery.options.howmany + 1)) {
				$$('.'+gallery.options.childclass+'[id=1]').each(function (firstid) {
					firstid.set({
						'rel' : 'active'
					});
					
					el.setStyles({ 'opacity':'0' });
					firstid.setStyles({ 'opacity':'1' });
					
					var htmlflash = firstid.get('html');
					firstid.empty();
					firstid.set('html',htmlflash);
					
					firstid.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});
					
				});
				
				for (z = 1; z <= gallery.options.howmany; z++)
				{
					$('select-'+z).set('class', 'not-selected');
				}
				
				$('select-1').set('class', 'selected');
				
			}
			else {
				$$('.'+gallery.options.childclass+'[id='+nextid+']').each(function (nextelement) {
					nextelement.set({
						'rel' : 'active'
					});
					
					el.setStyles({ 'opacity':'0' });
					nextelement.setStyles({ 'opacity':'1' });
					var htmlflash = nextelement.get('html');
					nextelement.empty();
					nextelement.set('html',htmlflash);
					
					nextelement.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});
					
				});	
				
				for (z = 1; z <= gallery.options.howmany; z++)
				{
					$('select-'+z).set('class', 'not-selected');
				}

				
				$('select-'+nextid).set('class', 'selected');
				

				
			}
			
		});
	},
	previousItem: function () {
		$$('.'+gallery.options.childclass+'[rel=active]').each(function (el) {
			el.erase('rel');
			var theid = parseFloat(el.get('id'));
			var nextid = Math.floor(theid - 1);			
			if (nextid == 0) {
				$$('.'+gallery.options.childclass+'[id='+gallery.options.howmany+']').each(function (firstid) {
					firstid.set({
						'rel' : 'active'
					});
					
					el.setStyles({ 'opacity':'0' });
					firstid.setStyles({ 'opacity':'1' });
					var htmlflash = firstid.get('html');
					firstid.empty();
					firstid.set('html',htmlflash);
					
					firstid.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});
					
					for (z = 1; z <= gallery.options.howmany; z++)
				{
					$('select-'+z).set('class', 'not-selected');
				}

				
				$('select-'+nextid).set('class', 'selected');
				});
			}
			else {
				$$('.'+gallery.options.childclass+'[id='+nextid+']').each(function (nextelement) {
					nextelement.set({
						'rel' : 'active'
					});
					
					el.setStyles({ 'opacity':'0' });
					nextelement.setStyles({ 'opacity':'1' });
					var htmlflash = nextelement.get('html');
					nextelement.empty();
					nextelement.set('html',htmlflash);
					
					nextelement.getElements('span').each(function (span){
						$('mainhightlighttitle').set('html', span.get('html'));
					});
					
					for (z = 1; z <= gallery.options.howmany; z++)
				{
					$('select-'+z).set('class', 'not-selected');
				}

				
				$('select-'+nextid).set('class', 'selected');
				});				
			}
		});
	}
}

window.addEvent('domready', function() {
	sexyLightBox();
});



