var rotator = 0;

$(document).ready(function(){
	setTimeout('rotateTeaser()', 6000);
	
	// cut off no content links - quick fix
	$("#Top a").click(function(){
		if ($(this).attr("href") == "#") {
			alert('Coming soon...')
			return false;
		}
		
		return true;
	});
	
	// searchbox behavior
	$("#SearchBox input").focus(function(){
		if ($(this).val() == 'SEARCH' || $(this).val().search('SQUEDA') !== -1) {
			$(this).val("");
		}
	});
	
	// fading items, such as links fade from gray to colored
	$(".fader").hover(
		function(){
			$(".fader .hover").fadeIn();
		},
		function(){
			$(".fader .hover").hide();			
		}
	);
	
	// questions behavior
	$(".slide-question a.question").click(function(){
		$("p", $(this).parent()).slideDown();
		return false;
	});
	
	$(".slide-question a.close").click(function(){
		$(this).parent().hide();
		return false;
	});
	
	// contact form
	$("#ContactForm input[name='name']").focus(function(){
		if ($(this).val() == 'Name') {
			$(this).val("");
		}
	});

	$("#ContactForm input[name='name']").focus(function(){
		if ($(this).val() == 'Name') {
			$(this).val("");
		}
	});

	$("#ContactForm input[name='email']").focus(function(){
		if ($(this).val() == 'Email') {
			$(this).val("");
		}
	});
	
	$("#ContactForm textarea[name='comment']").focus(function(){
		if ($(this).val() == 'Questions / Comments') {
			$(this).val("");
		}
	});
});


function rotateTeaser(){
	if (++rotator > 2) {
		rotator = 0;
	}

	var n = 0;
	var newImage = '';
	
	$("#TeaserRotation img").each(function(){
		if (n++ == rotator) {
			newImage = $(this).attr('src');
		}
	});

	$("#TeaserRotation").css("backgroundImage", "url("+newImage+")");
	$("#TeaserRotation div").fadeOut(function(){
        $("#TeaserRotation div").css("backgroundImage", "url("+newImage+")");
        $("#TeaserRotation div").show();
    });
	
	setTimeout('rotateTeaser()', 6000);
}
