	$('document').ready(function() {
		$('#slider').nivoSlider({
			effect: 'fade',
			animSpeed: 700,
			startSlide:0,
			directionNav:false
		});
		//adiciona uma classe especifica para manipulação de elemento
		$('.nivo-controlNav a').addClass('supermenu');
		
		geraItens();
		//links com sublinks funcionando
		$('.nivo-controlNav a').click(function(){
			$('.nivo-controlNav a').children('div').animate( { left : -243 }, {duration:200, queue : false} );
			$('.nivo-controlNav a .textTitle').removeClass('spanclicked');
			//if( $(this).children('div').css({ left : -242}) ){
				$(this).children('div').animate({ left : 63 }, { duration : 800, queue : false });
				$(this).children('.textTitle').addClass('spanclicked');
			/*}
			else{
				$(this).children('div').animate({ left : -242 }, { duration : 600, queue : false });
			}*/
		});
		
		//console.info( $('.nivo-control .subitem').hide() );
	});
/**
    Da titulos dinamicamente para os itens do menu
*/
var give = {
	links : function( $hrefimagem, $hreflayout, $hrefdetalhes ){
		var links = '<div class="subitem"><a href="'+ $hrefimagem+'">Imagens</a><a href="' +$hreflayout +'">Layout</a><a href="'+$hrefdetalhes+'">Mais detalhes</a></div>';
		return links;
	},
	title : function( $param ){
		var title = '<span class="textTitle">'+ $param +'</span>';
		return title;
	}
};
/**Objeto caminho*/
var paths ={
	/**
		PROPRIEDADES
		@author: AD AGENCY
		@prop site: url absoluta
		@prop ferretti: marca Ferretti
		@prop pershing: marca Pershing
		@prop galeria: caminho da galeria
		@prop layout: caminho de layout
		@prop detalhes: caminho de detalhes
		@prop ext: extensão do arquivo/página
	*/
	site: 'http://ww2.ferrettibrasil.com.br/',
	ferretti : 'Ferretti+',
	pershing : 'Pershing+',
	galeria : '+Galeria',
	layout : '+Layout',
	detalhes : '+Ficha+Tecnica',
	ext : '.aspx',
	/**
		METODOS
		@author: AD AGENCY
		@method fGal: retorna a galeria Ferretti
		@method pGal: retorna a galeria Pershing
		@method fLay: retorna o layout Ferretti
		@method pLay: retorna o layout Pershing
		@method fDet: retorna o detalhe Ferretti
		@method pDet: retorna o detalhe Pershing
	*/
	fGal : function( $param ){ return this.ferretti + $param + this.galeria + this.ext; },
	pGal : function( $param ){ return this.pershing + $param + this.galeria + this.ext; },
	fLay : function( $param ){ return this.ferretti + $param + this.layout + this.ext; },
	pLay : function( $param ){ return this.pershing + $param + this.layout + this.ext; },
	fDet : function( $param ){ return this.ferretti + $param + this.detalhes + this.ext; },
	pDet : function( $param ){ return this.pershing + $param + this.detalhes + this.ext; }
}

var itens={
	/*ns :[ '500', '530', '620', '660', '700', '750', '830', '881', '881RPH', '55', '64', '80' ],
	img : function( $param ){
		while( $param < this.ns.length ){
			$param++;
			return this.ns[$param];
		}
	},*/
	nome : [ '530', '620', '660', '700', '750', '830', '881', '881<sup>RPH</sup>', 'P55', 'P64', 'P80', 'P92' ],
	imagens : [ paths.fGal('530'),
						paths.fGal('620'),
						paths.fGal('660'),
                        paths.fGal('700'),
						paths.fGal('750'),
						paths.fGal('830'),
						paths.fGal('881'),
						paths.fGal('881RPH'),
						paths.pGal('55'),
						paths.pGal('64'),
						paths.pGal('80'),
						paths.pGal('92')
	],
	layouts : [	paths.fLay('530'),
						paths.fLay('620'),
						paths.fLay('660'),
                        paths.fLay('700'),
						paths.fLay('750'),
						paths.fLay('830'),
						paths.fLay('881'),
						paths.fLay('881RPH'),
						paths.pLay('55'),
						paths.pLay('64'),
						paths.pLay('80'),
						paths.pLay('92')
	],
	detalhes : [	paths.fDet('530'),
						paths.fDet('620'),
						paths.fDet('660'),
                        paths.fDet('700'),
						paths.fDet('750'),
						paths.fDet('830'),
						paths.fDet('881'),
						paths.fDet('881RPH'),
						paths.pDet('55'),
						paths.pDet('64'),
						paths.pDet('80'),
						paths.pDet('92')
	]
};

function geraItens(){
	var i = 0;
	for( i; i < $('.nivo-controlNav .supermenu').length; i++ ){
		$($('.nivo-controlNav .supermenu')[i]).html( give.title( itens.nome[i] ) );
		
		$($('.nivo-controlNav .supermenu')[i]).append( give.links( paths.site + itens.imagens[i] , paths.site + itens.layouts[i] ,  paths.site + itens.detalhes[i] ) );
		
		$('.nivo-control .subitem a').click(function(){return true;})
		//console.info( $($('.nivo-controlNav .supermenu')[i]).html() );
		//console.info( itens.nome[i] + " " + itens.href[i] +" "+ itens.detalhe[i] );
		//console.info( itens.imagens[i] )
		//console.info( itens.layouts[i] )
		//console.info( itens.detalhes[i] )
	}
}
