// rollover buttons
$(function() {
	// OPACITY OF BUTTON SET TO 0%
	$(".over_img").css("opacity","0");
	
	// ON MOUSE OVER
	$(".over_img").hover(function () {
	
	// SET OPACITY TO 100%
	$(this).stop().animate({
	opacity: 1.0
	}, 300);
	},
	
	// ON MOUSE OUT
	function () {
	
		// SET OPACITY BACK TO 50%
		$(this).stop().animate({
		opacity: 0
		}, 300);
	});
});

// bio switchers photos
$(function() {
	$("#tim").css("display","none");
	$("#brad").css("display","none");
	$("#matt").css("display","none");
	$("#bandBio").css("display","none");
	$("#timText").css("display","none");
	$("#bradText").css("display","none");
	$("#mattText").css("display","none");
	
	$('#bandBio').click(function() {
	  $('#band').fadeIn('slow', function() {	  });
	  $('#bioText').fadeIn('slow', function() {	  });
	  $('#tim').fadeOut('slow', function() {	  });
	  $('#timText').fadeOut('slow', function() {	  });
	  $('#brad').fadeOut('slow', function() {	  });
	  $('#bradText').fadeOut('slow', function() {	  });
	  $('#matt').fadeOut('slow', function() {	  });
	  $('#mattText').fadeOut('slow', function() {	  });
	  $('#bandBio').fadeOut('slow', function() {	  });
	});
	$('#timphoto').click(function() {
	  $('#band').fadeOut('slow', function() {	  });
	  $('#bioText').fadeOut('slow', function() {	  });
	  $('#tim').fadeIn('slow', function() {	  });
	  $('#timText').fadeIn('slow', function() {	  });
	  $('#brad').fadeOut('slow', function() {	  });
	  $('#bradText').fadeOut('slow', function() {	  });
	  $('#matt').fadeOut('slow', function() {	  });
	  $('#mattText').fadeOut('slow', function() {	  });
	  $('#bandBio').fadeIn('slow', function() {	  });
	});
	$('#bradphoto').click(function() {
	  $('#band').fadeOut('slow', function() {	  });
	  $('#bioText').fadeOut('slow', function() {	  });
	  $('#tim').fadeOut('slow', function() {	  });
	  $('#timText').fadeOut('slow', function() {	  });
	  $('#brad').fadeIn('slow', function() {	  });
	  $('#bradText').fadeIn('slow', function() {	  });
	  $('#matt').fadeOut('slow', function() {	  });
	  $('#mattText').fadeOut('slow', function() {	  });
	  $('#bandBio').fadeIn('slow', function() {	  });
	});
	$('#mattphoto').click(function() {
	  $('#band').fadeOut('slow', function() {	  });
	  $('#bioText').fadeOut('slow', function() {	  });
	  $('#tim').fadeOut('slow', function() {	  });
	  $('#timText').fadeOut('slow', function() {	  });
	  $('#brad').fadeOut('slow', function() {	  });
	  $('#bradText').fadeOut('slow', function() {	  });
	  $('#matt').fadeIn('slow', function() {	  });
	  $('#mattText').fadeIn('slow', function() {	  });
	  $('#bandBio').fadeIn('slow', function() {	  });
	});
});

function goVid(vid) {
	document.getElementById('vid').innerHTML = '<object width="550" height="300"><param name="movie" value="http://www.youtube.com/v/'+vid+'?fs=1&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'+vid+'?fs=1&amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="550" height="300"></embed></object>';
}

function changeGallery(id) {
	window.location='/photos/'+id;
}
function changeMap(id) {
	window.location='/map.php?id='+id;
}



// rotator
function theRotator() {
	//Set the opacity of all images to 0
	$('div#rotator ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div#rotator ul li:first').css({opacity: 1.0});
	
	var len = $('div#rotator ul li').length;
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	if (len > 1) {
		setInterval('rotate()',8000);
	}
	
}

function rotate() {	
	//Get the first image
	var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 2000)
	.removeClass('show');
	
};

$(document).ready(function() {		
	//Load the slideshow
	theRotator();
});

function doOptionSubmit() {
	value = document.formOptions.option.options[document.formOptions.option.selectedIndex].value;
	window.location='/cart.php?action=add&id='+value;
}
function boxOn(box,src,frame) {
	document.getElementById(box).style.display='block';
	document.getElementById('fade').style.display='block';
	document.getElementById(frame).setAttribute('src',src);
}
function boxOff(box) {
	document.getElementById(box).style.display='none';
	document.getElementById('fade').style.display='noneå';
}
function switchPage(menuform) {
	var baseurl = "/" ;
    selecteditem = menuform.toPage.selectedIndex ;
    newurl = menuform.toPage.options[ selecteditem ].value ;
    if (newurl.length != 0) {
      location.href = baseurl + newurl ;
    }
	
}

function show(id) {
	document.getElementById(id).style.display='block';
}

function hide(id) {
	document.getElementById(id).style.display='none';
}

function confirmSubmit() {
	var agree=confirm("Are you sure you wish to continue?");
	if (agree)
		return true ;
	else
		return false ;
}

