$(document).ready(function(){

var t;
startSlideshow();
var quotes = new Array;
quotes[0] = "Did you know that the Waltz used to be called the forbidden dance when it came out in Vienna in the 1780's?";
quotes[1] = "We should consider everyday lost in which we don't dance";
quotes[2] = "Ballroom dancing is the best step to avoid alzheimers";
quotes[3] = "To touch, to move, to inspire. This is the true gift of dance";
quotes[4] = "Great dancers are not great because of their technique. They are great because of their passion";
quotes[5] = "It takes an athlete to dance, but an artist to be a dancer";

var maxquote = quotes.length;
var rannum = Math.floor(Math.random()*maxquote);
$('.tip').html(quotes[rannum]);
$.validator.setDefaults({
	submitHandler: function() {var info = $('#messform').serialize();
								 						 $.post(
	  												   'php/message.php', 
														   info, 
														   function(data){
		  											     $('form')[0].reset();
		  											     $("#success").fadeIn(400, function(){
														       $("#success").fadeOut(5000);});
														   });
														   return false;
	 													 }
											 });

$("#messform").validate({
		rules: {
			first: "required",
			last: "required",
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			firstname: "Please enter your firstname",
			lastname: "Please enter your lastname",
			email: "Please enter a valid email address"
		}
	});



$('#submitemail').click(function(){
  var firstn = $("#mailinglistf").val();
	var lastn = $("#mailinglistl").val();
	var emailn = $("#mailingliste").val();
	var curwid = $(window).width();
	curwid = curwid/2-125;
	var curhei = $(window).height();
	var curscroll = $(window).scrollTop();
	curhei = curhei/2-50 +curscroll;
	$("#added").css({'left':curwid,'top':curhei});
	
	if (firstn == ''){$("#added").html("Please enter your first name");}
	else if (lastn == ''){$("#added").html("Please enter your last name");}
	else if (emailn == ''){$("#added").html("Please enter your email");}
	else {$("#added").html("Thanks! You've been added");
      var info = $('#mailinglist').serialize();
	  		$.post('php/message.php',info,function(data){
		  	  $('form')[0].reset();
			  });
        }
  $("#added").fadeIn(400, function(){
	  $("#added").fadeOut(5000);});
	return false;
	
});

//end of onload events
});

//map for locdirections.php
function initialize() { 

var myLatlng = new google.maps.LatLng(28.039259,-82.414284); 
var TampaDancesport = new google.maps.LatLng(28.057179,-82.392932);
var myOptions = { 
  							 zoom: 11, 
  							 center: myLatlng, 
  							 mapTypeId: google.maps.MapTypeId.TERRAIN 
								 };
var map = new google.maps.Map(document.getElementById("halfmap"),myOptions);								 
var image = "img/logoicon112.png";
var marker = new google.maps.Marker({ 
      position: TampaDancesport,  
      map: map,  
			icon: image,
			title: "Tampa Dancesport"
  });  								 
var infowindow = new google.maps.InfoWindow( 
      { content: "Rhapsody Ballroom<br>12101 N. 56th street<br>Tampa, FL 33617", 
        size: new google.maps.Size(30,30) 
      }); 

	 google.maps.event.addListener(marker, 'click', function() { 
    map.setCenter(TampaDancesport);
		map.setZoom(16); 
  }); 
	google.maps.event.addListener(marker, 'mouseover', function() { 
    infowindow.open(map,marker);  
  });
google.maps.event.addListener(marker, 'mouseout', function() { 
    infowindow.close(map,marker);  
  });
 } 
			

function startSlideshow() {
	$(".slide2").fadeIn('50');							 
  $(".slide1").fadeOut('5000');
  $(".slide1").removeClass().addClass("slidelast");	
	$(".slide2").removeClass().addClass("slide1");
	$(".slide3").removeClass().addClass("slide2");
	$(".slidelast").removeClass().addClass("slide3");
  t=setTimeout("startSlideshow()",7000);

}  
