var $j = jQuery.noConflict();

// ----------------------------------------------------------------------
//    MENU E SUBMENUS
// ----------------------------------------------------------------------

$j(document).ready(function() {
	try {
		$j('.menu > .widthContainer > ul > li > a').click(function(e) {
			var list = $j(e.target).siblings('ul').eq(0)
			if (list.html() != null) {
				e.preventDefault()
				list.slideDown(200)
			}
		})
	}
	catch(o){}
});





// ----------------------------------------------------------------------
//    DESTAQUES
// ----------------------------------------------------------------------

var curFeature = 0

$j(document).ready(function() {
	try {
		$j('.features .navigation a:eq(0)').click(function(e) {
			e.preventDefault()
			if (curFeature < 0) {
				curFeature += 1
			} else {
				curFeature = -($j('.features .slider img').length)+1
			}
			featuresNav()
		})
		$j('.features .navigation a:eq(1)').click(function(e) {
			e.preventDefault()
			if (curFeature > -($j('.features .slider img').length)+1) {
				curFeature -= 1 
			} else {
				curFeature = 0
			}
			featuresNav()
		})
	}
	catch(o){}
});

function featuresNav() {
	$j('.features .slider').stop()
	$j('.features .slider').animate({
		left: curFeature * $j('.features .slider img').width()
	}, 350)
}





// ----------------------------------------------------------------------
//    NAVEGAÇÃO TESTEMUNHOS
// ----------------------------------------------------------------------

var curTestimonial = 0

$j(document).ready(function() {
	try {
		$j('.testimonials .navigation a:eq(0)').click(function(e) {
			e.preventDefault()
			if (curTestimonial < 0) {
				curTestimonial += 1
			} else {
				curTestimonial = -($j('.testimonials .testimonial').length)+1
			}
			testimonialsNav()
		})
		$j('.testimonials .navigation a:eq(1)').click(function(e) {
			e.preventDefault()
			if (curTestimonial > -($j('.testimonials .testimonial').length)+1) {
				curTestimonial -= 1 
			} else {
				curTestimonial = 0
			}
			testimonialsNav()
		})
	}
	catch(o){}
});

function testimonialsNav() {
	$j('.testimonials .slider').stop()
	$j('.testimonials .slider').animate({
		left: curTestimonial * parseInt($j('.testimonials .container').css('width'))
	}, 350)
}





// ----------------------------------------------------------------------
//    NAVEGAÇÃO MULTIMEDIA
// ----------------------------------------------------------------------

var curGalleryPage = 0

$j(document).ready(function() {
	try {
		$j('.multimedia .navigation a:eq(0)').click(function(e) {
			e.preventDefault()
			if (curGalleryPage < 0) {
				curGalleryPage += 1
			} else {
				curGalleryPage = -($j('.multimedia .mediaElement').length)+2
			}
			galleryNav()
		})
		$j('.multimedia .navigation a:eq(1)').click(function(e) {
			e.preventDefault()
			if (curGalleryPage > -($j('.multimedia .mediaElement').length)+2) {
				curGalleryPage -= 1 
			} else {
				curGalleryPage = 0
			}
			galleryNav()
		})
	}
	catch(o){}
});

function galleryNav() {
	$j('.multimedia .slider').stop()
	$j('.multimedia .slider').animate({
		left: curGalleryPage * (parseInt($j('.multimedia .mediaElement').css('width')) + parseInt($j('.multimedia .mediaElement').css('margin-right')))
	}, 350)
}





// ----------------------------------------------------------------------
//    MENU ESQUERDO
// ----------------------------------------------------------------------

$j(document).ready(function() {
	$j(window).resize(function() {
		ajustaMenuEsquerdo()
	})
	ajustaMenuEsquerdo()
	
	try {
		var activeLM = $j('.leftMenu>ul>li.active').eq(0)
		if (activeLM.children('ul').length > 0) {
			activeLM.removeClass('active')
			activeLM.addClass('blackMenu')
		}
	}
	catch(o){}
});

function ajustaMenuEsquerdo()  {
	try {
		var tw = ($j('body').width()/2) - 252
		if (tw < 230) {
			tw = 230
		}
		
		$j('.leftColumn').css('width',tw)
	}
	catch(o){}
}





// ----------------------------------------------------------------------
//    ACCORDION
// ----------------------------------------------------------------------

$j(document).ready(function() {
	try {
		$j('.accordion>a').click(function(e) {
			e.preventDefault()
			$j(e.target).parent().children('.info').slideUp()
			$j(e.target).next().stop().slideDown()
		})
	}
	catch(o){}
})





// ----------------------------------------------------------------------
//    HORARIO
// ----------------------------------------------------------------------

$j(document).ready(function() {
	try {
	
		$j('.schedule th').each(function(index) {
			if ($j(this).html() != "") {
				$j(this).html("<div>"+$j(this).html() + "</div>")
			} else {
				$j(this).html("<div>&nbsp;</div>")
			}
		});
		
		$j('.schedule td').each(function(index) {
			if ($j(this).html() != "") {
				$j(this).html("<div>"+$j(this).html() + "</div>")
			} else {
				$j(this).html("<div>&nbsp;</div>")
			}
		});
		
		
		
		$j('.schedule th').eq(0).addClass('firstTh')
		
		$j('.schedule tr').filter(function(index) {
			return index > 0 && index < 15;
		}).addClass('line')
		
		$j('.schedule tr').eq(1).addClass('firstLine')
		$j('.schedule tr').last().addClass('lastLine')
		
		$j('.schedule tr').each(function(index) {
			$j(this).children('td').filter(':even').addClass('even').addClass('noBt')
			$j(this).children('td').filter(':odd').addClass('odd').addClass('noBt')
			
			$j(this).children('td').filter(':first').removeClass('even').addClass('hours')
		})
		
	}
	catch(o){}
	
	
		
})
