var i = 1;
var max;
$(document).ready(function(){
	
	
	max = $(".quotes > p").size();
	setInterval(next_quote, 8000);
	$("#grayfill").css("opacity", "0.8");
	$("#contact-form input").mouseenter(function() {
		$(this).css('borderColor', 'steelblue');
	});
	$("#contact-form input").mouseleave(function() {
		$(this).css('borderColor', '#c0c0c0');
	});
	$("#contact-form textarea").mouseenter(function() {
		$(this).css('borderColor', 'steelblue');
	});
	$("#contact-form textarea").mouseleave(function() {
		$(this).css('borderColor', '#c0c0c0');
	});

	$("#button").mouseenter(function () {
    	$("#comingsoon").fadeIn("slow");
    });
    
    $("#button").mouseleave(function () {
    	$("#comingsoon").fadeOut("slow");
    });

	$("#flags img").bind("mouseenter",function(){
		$(this).animate({ 
			width: "25px",
			marginBottom: "-5px"
			}, 150 );				
	});
	
	$("#flags img").bind("mouseleave",function(){
		$(this).animate({ 
		width: "20px",
		marginBottom: "0px"
		
		}, 150 );
	});
	
	emailProtect();

});

function emailProtect() {
	$('span.mail').each(function() {
		var spt = $(this);
		var at = / at /;
		var dot = / dot /g;
		var addr = $(spt).text().replace(at,"@").replace(dot,".");
		$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
		.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
		$(spt).remove();
	});
}

function eventDetails(id) {
	$("#grayfill").fadeIn("fast");
	$.post("/include/ajax.php", { action: "itemDetails", id: id}, function(data){
		$("#window .inner").html(data);
		emailProtect();
		$("#window").center().fadeIn("fast");
	});
}

function closeWindow() {
	$("#window").hide().find(".inner").html("");
	$("#grayfill").hide();
}

function show_window() {
	$("#window").hide();
	$("#grayfill").fadeIn("fast");	
	$("#inquire_window").fadeIn("fast");
	
}

function close_window() {
	$("#grayfill").fadeOut("fast");
	$("#inquire_window").hide();
}
function submit_form() {
	$("#frm").submit();
}
function check2() {
		if (document.getElementById('First_Name').value=="") { alert ("First Name required"); return(false); }
		if (document.getElementById('Last_Name').value=="") { alert ("Last Name required"); return (false); }
		if (document.getElementById('Email').value=="") { alert ("Email required");  return (false); }		
}
function next_quote() {
	if (i==max) i=0;
	$(".quotes").fadeOut("slow", function() {		
		$(".quotes p").hide();
		$(".quote-" + i).show();
		$(".quotes").fadeIn("slow");
		i++;
	});
	
}
