// JavaScript Document
var randBegin;
var quoteTotal;

$(document).ready(function() {
	// fancyzoom
	setupZoom();
	
	// email setup
	// email linx
	$("a.email").click(function(){
		var targ = $(this).attr("href");
		var email = targ.replace("_at_","@");
		var email = email.replace("_dot_",".");

		window.location = "mailto:"+email;
		
		return false;
	});
	
	$('.inEmail').focus(function() {
		if ($(this).val() == "Get Updates. Give us your email."){
			$(this).val("");
			$(this).addClass("activated");
		}
	});
	
	$('.inEmail').blur(function() {
		if ($(this).val() == ""){
			$(this).val("Get Updates. Give us your email.");
			$(this).removeClass("activated");
		}
	});
	
	if ($("#ownsidequote").children().size()){
		quoteTotal = Math.floor($("#ownsideinsight ul").children().size());
		var randStart = Math.floor(Math.random()*(quoteTotal-1));
		randBegin = randStart;
		
		cycleQuote(randStart);
	}
	

});

function cycleQuote(num){
	var theQuote = $("#ownsideinsight ul li").eq(num).html();
	
	$("#ownsidequote").css("opacity","0.0").html(theQuote).append("<div class='clear'></div>");
	$("#ownsidequote").animate(
		{
    		opacity: 1.00,
	  	}, 
		1000, 
		function() {
		    setTimeout ( nextQuote, 2800 );

	});


}

function nextQuote(){
	var nextQuote = randBegin + 1;
	if (nextQuote > (quoteTotal -1)){
		nextQuote = 0;
	}
	randBegin = nextQuote;
	
	$("#ownsidequote").animate(
		{
    		opacity: 0.00,
	  	}, 
		500, 
		function() {
		    cycleQuote(nextQuote);

	});
}
