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 renderBanner(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 triggerFancybox(term)
{
	var count = 0;
	$(term).unbind('click.fb');
	$(term).fancybox({'overlayColor':'#000'});
	$(term).each(function()
	{
		if (count < 1)
		{
			$(this).trigger('click');
		}
		count++;
	});
}


$(document).ready(function () {
	
	$('#slides').slides({
		preload: true,
		//preloadImage: 'http://slidesjs.com/img/loading.gif',
		generatePagination: false,
		effect: 'fade',
		play: 8000,
		pause: 2500,
		hoverPause: true
	});
	
	/*$('div.category-title h1').click(function() {
		
		$('#port-list div.accordion div.accordion-category').each(function()
		{
			if ($(this).attr('rel') == 'over')
			{
				$(this).attr('rel', '');
				$(this).attr('class', 'accordion-category')
				$(this).slideUp();
			}
		});
		
		var accordion = $(this).parent().parent().find('div.accordion-category');
		
		if (accordion.attr('rel') == 'over')
		{
			accordion.attr('rel', '');
			accordion.attr('class', 'accordion-category')
			accordion.slideUp();
		}
		else
		{
			accordion.attr('rel', 'over');
			accordion.attr('class', 'accordion-category over')
			accordion.slideDown();
		}
	});*/
	
	
	
	$('.port-item').each(function()
	{
		$(this).mouseenter(function()
		{
			$(this).find('a.zoom').fadeIn();
		});
		
		$(this).mouseleave(function()
		{
			$(this).find('a.zoom').fadeOut();
		});
	});
	
	
	$("#content .gallery a").each(function() {
		$(this).attr('rel', 'fancybox');
		$(this).attr('title', '');
	});
	
	$("#content .gallery a").fancybox({'overlayColor':'#000'});
	
	$('#btn-info').click(function ()
	{
		if ($(this).attr('class') == 'over')
		{ 
			$('#more-info').slideUp();
			$(this).attr('class','');
		}
		else
		{
			$('#more-info').slideDown();
			$(this).attr('class','over');
		}
	});
	
});
