﻿/* 
 * Controles de JavaScript
 * Site F&oacute;rmula P 2010
 * 
 * @autor: Fabiano Chiaretto Fernandes
 * @ultimaAlteracao 09:47 08/09/2010
 * 
 */

//Inicializa��o do js
$(document).ready(function(){
	//$("[title]").easyTooltip();
	
	$("#content #left .content a:has('img')").lightBox({
		imageLoading: 'http://www.formulap.com.br/2010/wp-content/themes/FormulaP2010/img/lightbox-ico-loading.gif',
		imageBtnClose: 'http://www.formulap.com.br/2010/wp-content/themes/FormulaP2010/img/lightbox-btn-close.gif',
		imageBtnPrev: 'http://www.formulap.com.br/2010/wp-content/themes/FormulaP2010/img/lightbox-btn-prev.gif',
		imageBtnNext: 'http://www.formulap.com.br/2010/wp-content/themes/FormulaP2010/img/lightbox-btn-next.gif',
		txtImage: 'Imagem',
		txtOf: 'de'
	});

	
});


$(function(){
	
	/* Exibe op��es do item */
	$(".boxNormal").mouseenter(function(){
		$(".imagemPost",this).stop();
		$(".imagemPost",this).animate({marginLeft: '-285px'},800,"easeOutCubic");
	}).mouseleave(function(){
		$(".imagemPost",this).stop();
		$(".imagemPost",this).animate({marginLeft: '0px'},800,"easeOutCubic");
	});
	
	// Neve Natal
	//$().jSnow({flakes:40,fallingSpeedMax:1,swingMin:10, swingMax:50, interval:20});
	
	//$().jSnow({flakes:40,fallingSpeedMax:1,swingMin:10, swingMax:50, interval:20});
	
	/*
	$().jSnow({
		flakes:10, // numero de flocos na tela;
		flakeMaxSize:15, //tamanho maximo dos flocos de neve
		flakeMinSize:5, // Tamanho minimo dos flocos de neve
		flakeCode:["•"],  // elementoo a ser colocado, pode colocar fotos tambem
		flakeColor:["#fff"], // cor do elemento
		interval:100, // intervalo de tempo na reproducao dos flocos
		fallingSpeedMin:5, // velocidade minima de de queda de neve
		fallingSpeedMax:15, //velocidade maxima de de queda de neve
		swingMin:100, //movimento minimo
		swingMax:500 //movimento maximo
	});
	*/
	
});




var FP = {
	init: function() {
		$.each($('.imagebox'),FP.initImageBox);
	},
	initImageBox: function(i,v) {
		if (!FP.imageBoxPos) {
			FP.imageBoxPos = [];
			FP.imageBoxTotal = [];
		}
		var o = $('#'+v.id);
		var n = parseInt(v.id.split("-").pop());
		FP.imageBoxPos[n] = 0;
		FP.imageBoxTotal[n] = $('#'+v.id+" a").get().length;
		$('#'+v.id+" a").click(FP.imageBoxNext);
		FP.imageBoxSwitch(n);
	},
	imageBoxNext: function (e) {
		var n = parseInt(e.currentTarget.parentNode.id.split("-").pop()),
			v = FP.imageBoxPos[n];
			t = FP.imageBoxTotal[n];
		v++;
		if (v >= t) v -= t;
		FP.imageBoxPos[n] = v;
		FP.imageBoxSwitch(n);
	},
	imageBoxSwitch: function(n) {
		var i = FP.imageBoxPos[n],
			t = $('#imagebox-'+n+" a").get().length;
		$('#imagebox-'+n+" a").removeClass('cur');
		$('#imagebox-'+n+" a").eq(i).addClass('cur');
		$('#imagebox-'+n+" .caption").html('('+(i+1)+'/'+t+') '+$('#imagebox-'+n+" a span").eq(i).html());
	}
}
$('document').ready(FP.init);


function fecharfloating(){
	$('#floating').remove();
}

