/* customizacao do lightbox */
var opacity = '8'; 							/* valor da opacidade da mascara. Utilizar numeros de 0 a 10 */
var mask = 'mask';							/* define a classe da mascara */

var cBox = 'Fechar';						/* texto do botao fechar do lightbox */
var cCss = 'fechar';						/* define a classe do botão fechar */

var num = 27;								/* tecla para fechar o lightbox. 27 é o numero do ESC, caso nao queira nenhuma utilizar o valor null */

var exCss = 'external-content';				/* define a classe que o .load irá buscar no arquivo externo para carregar no lightbox */
var imgLoading = 'http://'+window.location.hostname+'/wp-content/themes/reclame-novo/img/ajax-loader2.gif' 		/*caminho para a imagem de loading */
var cClose = true							/* ativa o fechamento da tela no clique da mascara. Valores true ou false */

/******************************************************************************************************************************************/

function loading(){
	createMask();
	$('div.lightbox').ajaxStart(function(){
		$(this).fadeIn();
		$('div.lightbox .lightbox-content').hide();
		$(this).append('<img src="'+imgLoading+'" style="position:absolute;left:50%;top:50%;margin-left:-110px">');
	});
	$('div.lightbox').ajaxSuccess(function(){
		$(this).children('img').remove();
		$('div.lightbox .lightbox-content').fadeIn();
	});
};

function closeBox() {
    $('div.'+mask+'').fadeOut('fast');
    $('div.lightbox').fadeOut('fast');
    if (jQuery.browser.msie) { 
      if(parseInt(jQuery.browser.version) == 6) {
          $('select').each(function(){$(this).show()});
      }
    }
    $('div.lightbox > div').remove();
    $('div.lightbox > iframe').remove();
	$('div.lightbox >img ').remove();
	$('.'+cCss+'').each(function(){$(this).remove()});
};
document.onkeydown = function(e) {
    if (e == null) {
        keycode = event.keyCode;
    } else {
        keycode = e.which;
    } if (keycode == num) {
        closeBox()
    }
};
function createLightbox(width, height) {
	var bodyHeight = document.documentElement.clientHeight;
	var bodyWidth = document.documentElement.clientWidth;
	if (jQuery.browser.safari) {
		var docScroll = document.body.scrollTop;
	} else {
		var docScroll = document.documentElement.scrollTop;
	}
	var docScroll = parseInt(docScroll);
	var bodyHeight = parseInt(bodyHeight);
	var height = parseInt(height);
	
	if (bodyHeight < height ) { 
		var top = (15 + docScroll );
		$('div.lightbox').css('position','absolute');
	} else {
		if (jQuery.browser.msie) {
			if(parseInt(jQuery.browser.version) == 6) { 
			  var top = (((bodyHeight /2) - (height /2)) + docScroll );
			  $('div.lightbox').css('position','absolute');
		  } else {
			var top = ((bodyHeight /2) - (height /2));
			$('div.lightbox').css('position','fixed');
		  }
		} else {
			var top = ((bodyHeight /2) - (height /2));
			$('div.lightbox').css('position','fixed');
		}
	}
	var top = parseInt(top);
	
	if (bodyWidth < width ) {
		var left = (width /2)+ 10 +'px';
	} else {
		var left = '48%';
	}
	$('div.lightbox').css({
		'left': left,
		'top': top + "px",
		'width': width + 'px',
		'height': height + 'px',
		'margin-left': -width / 2
	});
	$('div.lightbox').append('<a href="javascript:closeBox()" class="'+cCss+'">'+ cBox +'</a>');
};
function createMask() {
	var bodyHeight = document.documentElement.clientHeight;
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) { 
          var docScroll = document.documentElement.scrollTop;
		  $('select').each(function(){$(this).hide()});
		  var hb = bodyHeight;
      } else {
	  	var docScroll = '0';
		var hb = '100%';
	  }
	} else {
		var docScroll = '0';
		var hb = '100%';
	}
	$('div.'+mask+'').css({
		'top':docScroll+ "px",
		'filter': 'alpha(opacity='+opacity*10+')',
		'-moz-opacity': opacity/10,
		'-khtml-opacity': opacity/10,
		'opacity': opacity/10,
		'height':hb
	});
	$('div.'+mask+'').show();
	if (jQuery.browser.msie) {
		if(parseInt(jQuery.browser.version) == 6) { 
			$(window).scroll(function () {
				var docScroll = document.documentElement.scrollTop;
				$('div.'+mask+'').css('top',docScroll+'px');
				var leftScroll = document.documentElement.scrollLeft;
				$('div.'+mask+'').css('left',leftScroll+'px');
			});
		}
	} 
};
function create(n,size,htmlTitle,pathFile,pathUrl,divHtml,htmlElem,x){
	if ( x == '1' ){
		loading();
	} else {
		createMask();
	}
	
	if (n == 'i') {
		// iframe
		createLightbox(size[1], size[2]);
		$('div.lightbox').append(''+htmlTitle+'<iframe src="'+pathUrl+'" width="'+size[1]+'" height="'+size[2]+'" frameborder="0" allowtransparency="true">');
	} else if (n == 's') {
		// swf
		createLightbox(size[0], size[1]);
		$('div.lightbox').append(''+htmlTitle+'<div><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+size[0]+'" height="'+size[1]+'"><param name="movie" value="'+pathUrl+'"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="disable"><param name="loop" value="true"><EMBED src="' + pathUrl + '" quality="high" wmode="transparent" menu="disable" width="'+size[0]+'" height="'+size[1]+'" loop="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></div>');
	} else if (n == 'yt') {
		// youtube
		createLightbox(size[0], size[1]);
		//if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { 
		//	$('div.lightbox').append(''+htmlTitle+'<div><video style="width:'+size[0]+'; height:'+size[1]+'" src="http://m.youtube.com/watch?v=-' + pathUrl + '" autoplay="autoplay" controls="controls"></video></div>');
		//} else {
			$('div.lightbox').append(''+htmlTitle+'<div><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+size[0]+'" height="'+size[1]+'"><param name="movie" value="http://www.youtube.com/v/'+pathUrl+'"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="disable"><param name="loop" value="true"><EMBED src="http://www.youtube.com/v/' + pathUrl + '" quality="high" wmode="transparent" menu="disable" width="'+size[0]+'" height="'+size[1]+'" loop="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></div>');
		//}
	} else if (n == 'vm') {
		// vimeo
		createLightbox(size[0], size[1]);
		if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { 
			$('div.lightbox').append(''+htmlTitle+'<div><video style="width:'+size[0]+'; height:'+size[1]+'" src="http://www.vimeo.com/play_redirect?quality=mobile&clip_id=' + pathUrl + '" autoplay="autoplay" controls="controls"></video></div>');
		} else {
			$('div.lightbox').append(''+htmlTitle+'<div><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+size[0]+'" height="'+size[1]+'"><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+pathUrl+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1"><param name="quality" value="high"><param name="wmode" value="transparent"><param name="menu" value="disable"><param name="loop" value="true"><EMBED src="http://vimeo.com/moogaloop.swf?clip_id='+pathUrl+'&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" quality="high" wmode="transparent" menu="disable" width="'+size[0]+'" height="'+size[1]+'" loop="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></OBJECT></div>');
		}
	} else if (n == 'g') {
		// imagem
		createLightbox(size[0], size[1]);
		if ( size[0] > size[1]){
			$('div.lightbox').append(''+htmlTitle+'<div><img src="'+pathUrl+'" class="png_bg horizontal" /></div>');
		} else {
			$('div.lightbox').append(''+htmlTitle+'<div><img src="'+pathUrl+'" class="png_bg vertical" /></div>');
		}
	} else if (n == 'd') {
		// id
		createLightbox(size[0], size[1]);
		$('div.lightbox').append(''+htmlTitle+'<div style="width:'+size[0]+'px; height:'+size[1]+'px; ">'+divHtml+''+htmlElem.html()+'</div></div>');
	} else if (n == 'e') {
		// conteudo externo
		createLightbox(size[0], size[1]);
		$('div.lightbox').append('' + htmlTitle + '<div class="lightbox-content"></div>');
		$('div.lightbox-content').load(pathUrl + ' .'+ exCss +'');
	}
	
	if ( x != '1' ){
		$('div.lightbox').fadeIn();
	}
}
var pathUrl = null;
function lightbox(vS, vF) {
	if (vS != null) {
		var pathFile = vF.split('.');
		var size = vS.split('.');
		var pathUrl = vF;
			if (size[0] == 'iframe') {
				create('i', size, '', pathFile, pathUrl);
			}
			else if (pathFile[1] == 'youtube' || pathFile[0].substring(7, 14) == 'youtube' || pathFile[0].substring(11, 18) == 'youtube'){
				pathUrl = vF.split('=');
				pathUrl = pathUrl[1].split('&');
				create('yt', size, '', pathFile, pathUrl[0]);
				return false;
			}
			else if (pathFile[1] == 'vimeo' || pathFile[0].substring(7, 12) == 'vimeo'){
				pathUrl = vF.split('/');
				if (pathUrl[1] == 'undefined' || pathUrl[1] == '' || pathUrl[1] == 'null') {
					pathUrl = pathUrl[3];
				} else {
					pathUrl = pathUrl[1];
				}
				create('vm', size, '', pathFile, pathUrl);
				return false;
			}
			else if (pathFile[1] == 'swf') {
				create('s', size, '', pathFile, pathUrl);
				return false;
			}
			else if (pathUrl.indexOf(".jpg") != -1 || pathUrl.indexOf(".gif") != -1 || pathUrl.indexOf(".png") != -1 ) {
				create('g', size, '', pathFile, pathUrl);
			}
			else if (pathFile[0].substring(0, 1) == '#') {
				var thisElem = $(this).attr('href');
				var htmlElem = $(thisElem);
				var idElem = $(thisElem).attr('id');
				var divHtml = '<div id="' + idElem + '">'
				$(thisElem).remove();
				create('d', size, '', pathFile, pathUrl, divHtml, htmlElem);
			}
			else {
				create('e', size, '', pathFile, pathUrl, divHtml, htmlElem, '1');
			}
			
			if (cClose == true) {
				$('div.' + mask + '').click(function() { closeBox() });
			}
	} else {
		$('.lightbox a').each(function() {
			var pathFile = $(this).attr('href').split('.');
			var size = $(this).attr('rel').split('.');
			var pathUrl = $(this).attr('href');
			var htmlTitle = '';

			if (size[0] == 'iframe') {
				$(this).live('click', function() {
					create('i', size, htmlTitle, pathFile, pathUrl);
					return false;
				});
			}
			else if (pathFile[1] == 'youtube' || pathFile[0].substring(7, 14) == 'youtube' || pathFile[0].substring(11, 18) == 'youtube'){
				$(this).live('click', function() {
					pathUrl = $(this).attr('href').split('=');
					pathUrl = pathUrl[1].split('&');
					create('yt', size, htmlTitle, pathFile, pathUrl[0]);
					return false;
				});
			}
			else if (pathFile[1] == 'vimeo' || pathFile[0].substring(7, 12) == 'vimeo'){
				$(this).live('click', function() {
					pathUrl = $(this).attr('href').split('/');
					if (pathUrl[1] == 'undefined' || pathUrl[1] == '' || pathUrl[1] == 'null') {
						pathUrl = pathUrl[3];
					} else {
						pathUrl = pathUrl[1];
					}
					create('vm', size, htmlTitle, pathFile, pathUrl);
					return false;
				});
			}
			else if (pathFile[1] == 'swf') {
				$(this).live('click', function() {
					create('s', size, htmlTitle, pathFile, pathUrl);
					return false;
				});
			}
			else if (pathUrl.indexOf(".jpg") != -1 || pathUrl.indexOf(".gif") != -1 || pathUrl.indexOf(".png") != -1 ) {
				$(this).live('click', function() {
					create('g', size, htmlTitle, pathFile, pathUrl);
					return false;
				});
			}
			else if (pathFile[0].substring(0, 1) == '#') {
				var thisElem = $(this).attr('href');
				var htmlElem = $(thisElem);
				var idElem = $(thisElem).attr('id');
				var divHtml = '<div id="' + idElem + '">'
				$(thisElem).remove();
				$(this).live('click', function() {
					create('d', size, htmlTitle, pathFile, pathUrl, divHtml, htmlElem);
					return false;
				});
			}
			else {
				$(this).click(function() {
					create('e', size, htmlTitle, pathFile, pathUrl, divHtml, htmlElem, '1');
					return false;
				});
			}
	
			if (cClose == true) {
				$('div.' + mask + '').live('click', function() { closeBox() });
			}
		});
	}
};
var y = 0;
function open_ad(a){
	if(a=='sbe') {
		/*$('.adv-superbanner .adv-slot').css({
			height: '300px'
		});
		
		if ($.browser.msie) {*/
			$('.adv-superbanner').append('<iframe class="adv-frame" frameborder="0" style="background:none !important"></iframe>')
		/*} else{ };*/
		
	} else if(a=='sbl') {
		$('.adv-superbanner .adv-slot').css({
			height: '525px'
		});
		/*
		if ($.browser.msie) {
			$('.adv-superbanner').append('<iframe class="adv-frame adv-layer"></iframe>')
		} else{ };
		*/
	} else if(a=='hbe') {
		$('.adv-halfbanner .adv-slot').css({
			width: '730px',
			height: '250px'
		});
		/*
		if ($.browser.msie) {
			$('.adv-halfbanner').append('<iframe class="adv-frame"></iframe>')
		} else{ };
		*/
	} else if(a=='are') {
		$('.adv-arroba .adv-slot').css({
			width: '730px',
			height: '350px'
		});
		/*
		if ($.browser.msie) {
			$('.adv-arroba').append('<iframe class="adv-frame"></iframe>')
		} else{ };
		*/
	} else if(a=='fbe') {
		$('.adv-fullbanner .adv-slot').css({
			height: '300px'
		});
		/*
		if ($.browser.msie) {
			$('.adv-fullbanner').append('<iframe class="adv-frame"></iframe>')
		} else{ };
		*/
	};
};

function close_ad(b){
	if(b=='sbe') {
		$('.adv-superbanner .adv-slot').css({
			height: '90px',
			overflow: 'hidden'
		});
	} else if(b=='sbl') {
		$('.adv-superbanner .adv-slot').css({
			height: '90px',
			overflow: 'hidden'
		});
	} else if(b=='hbe') {
		$('.adv-halfbanner .adv-slot').css({
			width: '300px',
			height: '125px',
			overflow: 'hidden'
		});
	} else if(b=='are') {
		$('.adv-arroba .adv-slot').css({
			width: '300px',
			height: '250px',
			overflow: 'hidden'
		});
	} else if(b=='fbe') {
		$('.adv-fullbanner .adv-slot').css({
			height: '60px',
			overflow: 'hidden'
		});
	};
	/*
	if ($.browser.msie) {
		$('.adv-frame').remove();
	} else{ };
	*/
};
function loadTweet(){
	var usuarios = new Array("mug9","dandad","peralta_","DedeLaurentino","joaobinda","marcoversolato","marciosalem","miguelbemfica","atilafrancucci","Luiz_Lara","Fernandezrenato","adlatina_com","Branquinho","aprobr","ClaudiaPenteado","Cannes_Lions","afadiga","atendilento","marciosantoro","ContagiousPaul","contagiousmag","jvoliva","carlosscappini","superserpa","andruchaw","RynaldoLGondim","cmerigo","crisdias","kenfujioka","marcelotas","cavallini","gabrieljacob","lent","CCSPoficial","jarbas_agnelli","wired","jciaco","jotaerreduran","LFMUSA","julio_hungria","scottfrog","adage","Moacyr","marcelotripoli","fernandezrenato","anselmoramos","fernandezbeto","marcuskawa","fefaromano","w_olivetto","AlmapBBDO","marcoversolato","ecomoliterno","hugorodriguess","oliveiraMarcio","Neto","Marcello_Serpa","SuApelbaum","adage","updaters_","peralta","comercialecia","bogusky","DM9DDB","LewLaraTBWA","fefaromano","mug9","ricardochester","zeluizmartins");
	var i = parseInt(Math.random()*(usuarios.length-1));
	var e = new Array(usuarios[i]);
	$('.tweet .tweet_list').remove();
	$('p.loading').remove();
	$(".tweet").tweet({
		avatar_size: 74,
		count: 1,
		username: e,
		loading_text: "Carregando tweets..."
	});
};
$(function(){
	// jquery tweet
	
	loadTweet();
	setInterval('loadTweet()','60000');
	
	$("#twitter-reclame").tweet({
		avatar_size: 45,
		count: 5,
		username: ["programareclame"],
		loading_text: "Carregando tweets..."
	});
	
	
	// advs
	
	/*
	$('.adv-slot').mouseover(function(){
		open_ad('sbe');
	});
	$('.adv-slot').mouseout(function(){
		close_ad('sbe');
	});
	*/
	
	// some com o label do buscar
	
	if ($('#searchform #s').attr('value') != '') {
		$('#searchform label').hide();
	}
	
	$('#searchform #s').focus(function(){
		if ($(this).attr('value') == '') {
			$('#searchform label').hide();
		}
	});
	$('#searchform #s').blur(function(){
		if ($(this).attr('value') == '') {
			$('#searchform label').show();
		}
	});
	
	// adiciona classe rounded a elementos dinamicos
	
	$('.relacionados ul li, .idc-comments .idc-c').addClass('rounded');
	
	// formata os relacionados
	
	$('.relacionados ul li a:last-child').addClass('link');
	$('.relacionados ul li a.link').wrap('<span class="bg"></span>');
	
	// animacao titulo relacionados
	$('ul.navegacao-principal li a.over').animate({backgroundPosition: '-465px -470px'})
	
	$('.relacionados ul li').mouseover(function(){
		$(this).children('.bg').animate({'bottom':'0'});
	});
	$('.relacionados ul li').mouseleave(function(){ 
		$(this).children('.bg').animate({'bottom':'-'+ $(this).children('.bg').outerHeight()});
	});
	
	
	// bordas arredondadas
	
	//$('li.categories ul').append('<span class="borda-menu"></span>')
	
	$('.widget_categories ul, .widget_tag_cloud div').wrap('<div class="rounded"></div>');
	$('.widget_fbw_likebox h2').wrap('<div class="tit"></div>');
	$('.colunista').append('<span class="borda-inferior-colunista">&nbsp;</span><span class="borda-superior-colunista">&nbsp;</span>')
	$('.widget_fbw_likebox').append('<span class="bottom-sidebar">&nbsp;</span>');
	//$('.categories ul').addClass('.sub-menu')
	$('.rounded').append('<span class="rt">&nbsp;</span><span class="rb">&nbsp;</span><span class="lb">&nbsp;</span><span class="lt">&nbsp;</span>');
	$('.titulo-post').append('<span class="dt">&nbsp;</span><span class="db">&nbsp;</span><span class="et">&nbsp;</span></span><span class="eb">&nbsp;</span>');
	$('.box-rounded').append('<span class="bottom-sidebar">&nbsp;</span>');
	$('head').append('<style type="text/css">.rounded {position:relative;z-index:1}.rt, .rb, .lt, .lb {position:absolute;display:block;z-index:10}.rt {right:0;top:0 }.rb {right:0;bottom:0}.lt {left:0;top:0}.lb {left:0;bottom:0}</style>');
	$('.post-completo').append('<span class="topo-post">&nbsp;</span><span class="bottom-post">&nbsp;</span>');
	$('#idc-container-parent').append('<span class="bottom-post">&nbsp;</span>');
	// destaque home
	$('#destaque-home img').each(function(){
		$(this).parent('div').append('<span class="descricao">'+$(this).attr('alt')+'</span>');
		$('span.descricao').css({
			'filter':'alpha(opacity=80)',
			'-moz-opacity':'0.8',
			'-khtml-opacity':'0.8',
			'opacity':'0.8'
		});
	});
	// sub categorias cabecalho	
	$('#header li.categories').hover( function (){
		$(this).children('ul').stop(true, true).slideDown();
	}, function() {
		$(this).children('ul').stop(true, true).hide();
	});
	$('#header li.categories ul li').mouseenter( function (){
		$(this).children('.children').show();
	});
	$('#header .children li').hover( function (){
		$(this).css({'background-color': '#902600', 'color':'#ef9e65'});
	}, function() {
		$(this).css({'background-color': '#e96c26', 'color':'#902600'});
	});
	$('#header li.categories ul li').mouseleave( function (){
		$(this).children('.children').hide();		
	});
	$('#header li.categories ul li').each(function(){
		if($(this).children('ul').hasClass('children')){
			$(this).addClass('sub');
		};
	});
	$('#header li.categories ul li:last-child').css({'border-bottom': 'none'});
	
	$('#header li.categories ul li.sub').hover( function (){
		$(this).css({'background-position':'-414px -284px', 'background-color': '#e96c26'});
	}, function() {
		$(this).css({'background-position':'-414px -324px', 'background-color': '#c14417'});
	});
	
	
	$('#destaque-home div:first-child').addClass('ativo');
	$('#destaque-home div:first-child img').fadeIn();
	$('#destaque-home div:first-child .descricao').fadeIn();
	
	$('#destaque-home .destaque h4, #destaque-home .destaque p').click(function(){
		var z = $(this).parent('div').attr('class');
		z = z.split(' ');
		if ($(this).parent('div').hasClass('ativo')){
			
		} else{
			$('#destaque-home div').removeClass('ativo');
			$('#destaque-home div img').fadeOut();
			$('#destaque-home div .descricao').fadeOut();
			$('.ico-seta').remove();
			$('#destaque-home').append('<span class="ico-seta '+z[1]+'">&nbsp;</span>');
			$(this).parent('div').addClass('ativo');
			$(this).parent('div').children('img').fadeIn();
			$(this).parent('div').children('.descricao').fadeIn();
		}
	});
	
	// adiciona a classe last ao ultimo item da sidebar
	
	$('#content #sidebar ul li:last-child').addClass('last');
	
	// carrossel 
	
	$('.carrossel').each(function(){
		var html = $('.carrossel');
		var a = $('.carrossel').attr('class').split(' ');
		var b = $('.carrossel').parent('div').attr('class').split(' ');
		$('div.'+b[0]).append(' <a href="#" class="anterior '+a[1]+' '+a[2]+'" title="Anteriores">Anteriores</a> \
				<div class="window"> \
					<ul class="slider ' + a[1] + '"> \
						' + html.html() + '\
					</ul> \
				</div> \
			 <a href="#" class="proxima '+a[1]+' '+a[2]+'" title="Proximas">Proximas</a> ');
		$('.carrossel.'+a[1]).remove();
		$('ul.'+a[1]).prepend('<li></li>');
		var s = $('ul.'+a[1]+' li').length;
		var w = $('ul.'+a[1]+' li').outerWidth();
		$('ul.'+a[1]+' li:nth-child(1)').addClass('prev');
		$('ul.'+a[1]+' li:nth-child(3)').addClass('next');
		$('ul.'+a[1]+' li:nth-child(2)').addClass('ativo');
		$('ul.'+a[1]).css('width',s*w);
		$('ul.'+a[1]+' li').each(function(){
			if($(this).children('a').children('img').width() > $(this).children('a').children('img').height()){
				var l = $(this).children('a').attr('href');
				$(this).children('a').attr('href','javascript:lightbox("640.426","'+l+'");')
			} else {
				var l = $(this).children('a').attr('href');
				$(this).children('a').attr('href','javascript:lightbox("426.640","'+l+'");')
			};
		});
		//if(s*w <= $('ul.'+a[1]).parent('.window').width() ||  s*w <= $('ul.'+a[1]).parent('.window').height() || s == 1){
		//	$('ul.'+a[1]).parent().prev('.anterior').remove();
		//	$('ul.'+a[1]).parent().next('.proxima').remove();
		//};
	});
	var c = true;
	$('.anterior').live('click', function(){
		var a = $(this).attr('class').split(' ');
		var s = $('ul.'+a[1]+' li').length;
		var w = $('ul.'+a[1]+' li').outerWidth();
		var p = $('ul.'+a[1]).position().left;
		var wS = $('ul.'+a[1]).parent('.window').width();
		if (p != 0){
			if(c == true) {
				c = false;
				$('ul.'+a[1]).animate({'left':p+196},'normal', function(){c = true;});
				
				$('ul.'+a[1]+' li.next').animate({'margin':'15px 0 0'},'fast');
				$('ul.'+a[1]+' li.prev').prev('li').animate({'margin':'15px -84px 0 0'},'fast');
				$('ul.'+a[1]+' li.ativo').animate({
					'width':'196px',
					'height':'196px',
					'overflow':'hidden',
					'margin':'15px 0 0 -84px',
					'-moz-opacity':'.50',
					'filter':'alpha(opacity=50)',
					'opacity':'.50',
					'z-index':'1'
				});
				$('ul.'+a[1]+' li.ativo img').animate({'width':'300px'},'fast');
				$('ul.'+a[1]+' li.prev').animate({
					'width':'218px',
					'height':'218px',
					'margin':'0',
					'-moz-opacity':'1',
					'filter':'alpha(opacity=100)',
					'opacity':'1',
					'z-index':'2'
					},'fast');
				$('ul.'+a[1]+' li.prev img').animate({'width':'335px'},'fast');
				
				$('ul.'+a[1]+' li.next').removeClass();
				$('ul.'+a[1]+' li.ativo').attr('class','next');
				$('ul.'+a[1]+' li.prev').attr('class','ativo');
				$('ul.'+a[1]+' li.ativo').prev('li').addClass('prev');
			};
		};
		return false;
	});
	$('.proxima').live('click', function(){
		var a = $(this).attr('class').split(' ');
		var s = $('ul.'+a[1]+' li').length;
		var w = $('ul.'+a[1]+' li').outerWidth();
		var p = $('ul.'+a[1]).position().left;
		var wS = $('ul.'+a[1]).parent('.window').width();
		var m = wS/w;
		m = Math.round(m);
		if ((w*m) - p != w*s){
			if(c == true) {
				c = false;
				$('ul.'+a[1]).animate({'left':p-196},'normal', function(){c = true;});
				$('ul.'+a[1]+' li.prev').animate({'margin':'15px 0 0'});
				$('ul.'+a[1]+' li.next').next('li').animate({'margin':'15px 0 0 -84px'},'fast');
				$('ul.'+a[1]+' li.ativo').animate({
					'width':'196px',
					'height':'196px',
					'overflow':'hidden',
					'margin':'15px -84px 0 0',
					'-moz-opacity':'.50',
					'filter':'alpha(opacity=50)',
					'opacity':'.50',
					'z-index':'1'
				});
				$('ul.'+a[1]+' li.ativo img').animate({'width':'300px'},'fast');
				$('ul.'+a[1]+' li.next').animate({
					'width':'218px',
					'height':'218px',
					'margin':'0',
					'-moz-opacity':'1',
					'filter':'alpha(opacity=100)',
					'opacity':'1',
					'z-index':'2'
					},'fast');
				$('ul.'+a[1]+' li.next img').animate({'width':'335px'},'fast');
				
				$('ul.'+a[1]+' li.prev').removeClass();
				$('ul.'+a[1]+' li.ativo').attr('class','prev');
				$('ul.'+a[1]+' li.next').attr('class','ativo');
				$('ul.'+a[1]+' li.ativo').next('li').addClass('next');
			};
		};
		return false;
	});
	$('.entry p object, .making-off object').each(function(){
		$(this).append('<param name="wmode" value="transparent"></param>');
	});
	$('.entry p embed, .making-off embed').each(function(){
		$(this).attr('wmode','transparent');
	});
	$('.entry p object,.entry p  embed, .making-off embed, .making-off object').hide();
	$('.entry p object,.entry p  embed, .making-off embed, .making-off object').show();
	
	if ( y == 0 ) {
        $('body').append('<div class="'+mask+'" /><div class="lightbox"></div>');
        y = y + 1;
    }
    lightbox();
	/*
	var flashArray = ['banner1','banner2'];
	var obj =  $("#flashSrc").val()
	//var objVal  = obj.split('banners/')
	//flashArray.push(objVal[1]);
	
	var numPosibilidades = (flashArray.length -1) - 0
	var aleat = Math.random() * numPosibilidades
	var resultado  =  Math.round(parseInt(0) + aleat) 
	
	//alert(flashArray[resultado]);
	$("."+flashArray[resultado]).show();
	
	//alert(objVal[0]);
	//alert(objVal[1]);
	*/
	
});
