var t = '';

if (document.images) {
    img1 = new Image();
    img1.src = "/images/logos/belle-air-music-logo_roll.jpg";
    img2 = new Image();
    img2.src = "/images/logos/belle-air-music-logo-bottom_roll.jpg";
}

$(document).ready(function() {
	
	if ($('#rotator ul li').size() > 1) {
		t = setTimeout ( "rotateNormal()", 5000 );
		$rotate = false;
	}
	
	//Activate PNG Fix
	if (jQuery.fn.pngFix) $(document).pngFix();
});

//Hover Effects
$("#logo, #logo-bottom").hover(
	function(){
		var iconName = $(this).find("img").attr("src");
		var original = iconName.split(".")[0];
		$(this).find("img").attr({src: "" + original + "_roll.jpg"});
	}, 
	
	function(){
		var iconName = $(this).find("img").attr("src");
		var original = iconName.split("_roll.")[0];
		$(this).find("img").attr({src: "" + original + ".jpg"});
	});

//Navigation
$('#nav ul li a').click(function(){
		if($(this).parent().children('ul').length > 0){
			$('#nav ul li ul').slideUp();
			$(this).parent().children('ul').slideDown();
			return false;
		}
	});

/*
$('#nav ul ul li a').ready(function(){
									alert('ready');
		if($(this).attr('href') == window.location) {
			$(this).parent().parent().slideDown();
		}						   
	});*/



//alert(window.location);

//Expand Phone Number
var old = '';

$("abbr").hover(
	function(){
		old = $(this).text();
		$(this).text($(this).attr('title'));
	},
	
	function(){
		$(this).text(old);
	});

//Rotator
$('#slides a').hide();
$('#slides a:first').show();
$disable = false;
$disable2 = true;

function rotator($next) {
	$disable = true;	
	$('#slides a:visible').fadeOut(2000,
		function() {
			t = setTimeout ( "rotateNormal()", 5000 );
			$disable = false;
		});
	
	$next.fadeIn(2000);
	
	$('.sidebar li.current').removeClass('current');
	
	$count = $next.prevAll('a').size();
	$sidebar = $('.sidebar li:eq('+$count+')');
	$pos = $sidebar.offset().top - $('.sidebar').offset().top;
	
	$('#pointer').stop().animate({ 
		top: $pos+"px"
	  }, 2000, function(){
		$sidebar.addClass('current');  
		  
	  });
	
}

function rotateNormal() {
	
	if($('#slides a:visible').next().length > 0) {
		$next = $('#slides a:visible').next();
	
	}else{
		$next = $('#slides a:first');
	}
	
	rotator($next);
}

$('.sidebar a').click(function(){
		if($disable == false) {
			clearTimeout (t);
			
			$count = $(this).parent().prevAll('li').size();
			$next = $('#slides a:eq('+$count+')');
			
			rotator($next);
		}
		return false;
	});

$('#slides a').hover(
	function(){
		if($disable == false) {
			clearTimeout(t);
			$disable2 = false;
		}
	},
	
	function(){
		if($disable2 == false) {
			if($rotate != false) {
				t = setTimeout ( "rotateNormal()", 2000 );
			}
			$disable2 = true;
		}
	});

Cufon.replace('#bam h1', {
		color: '-linear-gradient(#84cafa, #5fb1f7 #1c89e8)'
	});

Cufon.replace('#lgs h1', {
		color: '-linear-gradient(#7d2903, #762603 #5a1803)'
	});

Cufon.replace('h3');
		
Cufon.now();	
