// <![CDATA[
$(document).ready(function() {
	
	//Hide sIFR titles ASAP
	$('.sIFR-active .content h2').css('visibility', 'hidden');
	
	$('.quick-calendar li a').click(function(event){
		event.preventDefault();
		$("#pageoverlay").fadeIn("slow");

		//set the href of the clicked item as the iFrame source
		$("#pageoverlay-content iframe").attr("src", $(this).attr("href"))

		//clicking away from the modal window closes the modal window
		$('#pageoverlay-bg').click(function(event){
			$("#pageoverlay-content iframe").attr("src", "");
			$("#pageoverlay").fadeOut("fast");
			});
	});

	//close the modal window
	$('#pageoverlay-close').click(function(event){
		$("#pageoverlay-content iframe").attr("src", "");
		$("#pageoverlay").fadeOut("fast");
		return false;
	});
	
	//IE6 lockout function
	if (window.attachEvent && typeof document.documentElement.style.maxHeight == "undefined"){
		//alert('You are on IE6');
	}
	else {

		//Image Lightboxes
		$("a.location-pic-thumb, a.event-pic-thumb, div.tab-gallery a").click(function(event){
			event.preventDefault();
		
			//Take the image in the "a" and use it for the lightbox
			var theDesc = $(this).attr("title");
			var theBigImage = $(this).attr("href");
			$("#pageoverlay-content").append('\
				<img src="' + theBigImage + '" /> \
					<div>' + theDesc + '</div> \
					<div id="photo-overlay-close"><a href="#">close</a></div>');
		
			//Lets do this thing
			$("#pageoverlay").fadeIn("slow");
			// $("#pageoverlay-content img").fadeIn(3000);
		
			//var theBigImageWidth = $("#pageoverlay-content").width();
			//$("#pageoverlay-content div:first").css("width", (theBigImageWidth - 270) + "px");
			//$("#pageoverlay-content").width(theBigImageWidth - 270);
		
		
			//Close button
			$("#photo-overlay-close a").click(function(event){
				$("#pageoverlay-content").html("");
				$("#pageoverlay").fadeOut("fast");
				return false;
			});
		
			//Clicking away from the modal window closes the modal window
			$('#pageoverlay-bg').click(function(event){
				$("#pageoverlay-content").html("");
				$("#pageoverlay").fadeOut("fast");
			});
	
		}); //ENDS Image Lightboxes function

	} //ENDS IE6 Lockout function
	
	//Contact Form
	var typeCurrentValLoad = $("#contactform #type").val();
	if (typeCurrentValLoad == "Renting the Depot for My Event") {
		$("#event-module").show();
	}
	
	$("#contactform #type").change(function() {
		var typeCurrentVal = $("#contactform #type").val();
		if (typeCurrentVal == "Renting the Depot for My Event") {
			//$("#event-module").fadeIn();
			$("#event-module").slideDown();
		}
		else {
			//$("#event-module").fadeOut();
			$("#event-module").slideUp();
		}
	});
	
	//get rid of widows in the quotes
	var widowText = '';
	$('blockquote.page-quote p:first').each(function() {
		var widowArray = $(this).text().split(' '),
		widowLast = widowArray.pop();
		widowText = widowArray.join(' ') + '&nbsp;' + widowLast;
		$(this).html(widowText);
	}); 

});

// $(window).load(function () {
// 		$('#front-slideshow').show()
// });
	
function validateform() {
	 var okSoFar=true;
	 with (document.contactform) {
		
		//added for renting selection
		var typeCurrentValLoad = $("#contactform #type").val();
		if (typeCurrentValLoad == "Renting the Depot for My Event") {
			if (event_type.value== "" && okSoFar) {
				okSoFar=false;
				$('#error_event_type').html("Birthday Party? Business Meeting? Oh come on, you can tell us! ");
				event_type.focus();
			}
			else {
				$('#error_event_type').html("");
			}
			if (event_people.value== "" && okSoFar) {
				okSoFar=false;
				$('#error_event_people').html("Give us some idea. About 10? 50?");
				event_people.focus();
			}
			else {
				$('#error_event_people').html("");
			}
			if (event_date.value== "" && okSoFar) {
				okSoFar=false;
				$('#error_event_date').html("If you don\'t know the exact date, how about the month?");
				event_date.focus();
			}
			else {
				$('#error_event_date').html("");
			}
			if (event_time.value== "" && okSoFar) {
				okSoFar=false;
				$('#error_event_time').html("Oops! This one is required.");
				event_time.focus();
			}
			else {
				$('#error_event_time').html("");
			}
			if (event_hear.value== "" && okSoFar) {
				okSoFar=false;
				$('#error_event_hear').html("Oops! This one is required.");
				event_hear.focus();
			}
			else {
				$('#error_event_hear').html("");
			}
		}
		
	 	if (sender.value== "" && okSoFar) {
			okSoFar=false;
			//alert("Please enter your name.");
			$('#error_sender').html("Gah! Who are you?");
			sender.focus();
		}
		else {
			$('#error_sender').html("");
		}
		if (phone.value=="" && okSoFar) {
			okSoFar=false;
			//alert("Please enter a phone number.");
			$('#error_phone').html("Uh oh. This field is required.");
			phone.focus();
		}
		else {
			$('#error_phone').html("");
		}
		var foundAt = email.value.indexOf("@",0);
		if (foundAt < 1 && okSoFar) {
			okSoFar = false;
			//alert ("Please enter a valid email address.");
			$('#error_email').html("Please enter a valid email.");
			email.focus();
		}
		else {
			$('#error_email').html("");
		}
		if (message.value=="" && okSoFar) {
		    okSoFar=false;
		    //alert("Please enter a message.");
			$('#error_message').html("Uh oh! You forgot to enter an inquiry.");
		    message.focus();
		}
		else {
			$('#error_message').html("");
		}
		if (security_code.value=="" && okSoFar) {
		    okSoFar=false;
		    //alert("Please enter the security code in the image at the bottom of this contact form.");
			$('#error_security_code').html("Are you a robot? Prove it.");
		    security_code.focus();
		}
		else {
			$('#error_security_code').html("");
		}
		if (okSoFar==true) submit();
	}

};

// ======== SIFR SIFR SIFR SIFR ========
// var cochin = {
//   src: '/flash/cochin.swf'
// };
// 
// var rockwell = {
//   src: '/flash/rockwell.swf'
// };
// 
// var attic = {
//   src: '/flash/attic.swf'
// };
// 
// var aaux = {
//   src: '/flash/aaux.swf'
// };
// 
// var typewriter = {
//   src: '/flash/typewriter.swf'
// };
// 
// var typewriter_normal = {
//   src: '/flash/typewriter_normal.swf'
// };
// 
// var typewriter_cond = {
//   src: '/flash/typewriter_cond.swf'
// };
// 
// var astute = {
//   src: '/flash/astute.swf'
// };
// 
var clarendon = {
  src: 'http://static.coffeedepot.tv/img/flash/clarendon.swf'
};
// 
// var asters = {
//   src: '/flash/asters.swf'
// };

// sIFR.domains = ['novemberborn.net'] // Don't check for domains in this demo
sIFR.useStyleCheck = true;
sIFR.activate(clarendon);
//sIFR.activate(cochin, rockwell);

sIFR.replace(clarendon, {
  selector: 'h2',
	wmode: 'transparent',
  	css: [
		'.sIFR-root { text-align: left; color: #3F7696; font-size: 24px; letter-spacing: -1;}',
		'a { text-decoration: none; }',
		'a:link { color: #3F7696; }',
		'a:hover { color: #FFFFFF; background:#3F7696}'
		],
	filters: {
		DropShadow: {
			knockout: false,
			distance: 2,
			color: '#E0E0E0',
			strength: 1
		}
	}
});

/*
sIFR.replace(rockwell, {
  selector: 'h5#pullquote'
  ,css: 'em { font-style: normal; color: #660000; }'
  ,selectable: false
});

sIFR.replace(cochin, {
  selector: 'h3.sidebox'
  ,css: {
    '.sIFR-root': { 'background-color': '#DCDCDC' }
  }
});

sIFR.replace(cochin, {selector: 'h2,h3'});

sIFR.replace(cochin, {
  selector: 'h4.subhead'
  ,css: {
    '.sIFR-root': { 'color': '#660000', 'letter-spacing': -1.5, 'text-transform': 'capitalize' }
  }
  ,filters: {
    DropShadow: {
      knockout: true
      ,distance: 1
      ,color: '#330000'
      ,strength: 2
    }
  }
});

*/

//=========== MAPS =============
$(window).load(function () {
	
	$('#front-slideshow').css('visibility', 'visible');
	
	//initiate the front page slideshow
	$('#front-slideshow').cycle({ 
	    fx: 'fade', 
	    speed: 600,
		timeout: 9000,
		next: '#slideshowNext',
	    prev: '#slideshowPrev'
	 });
	
	$('div.location-map:first').html('<iframe width="466" height="150" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" style="border:1px solid #999;" src="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=Coffee+Depot+3204+Mission+Inn+Avenue+Riverside+CA+92507&amp;sll=33.955389,-117.389313&amp;sspn=0.009122,0.014055&amp;ie=UTF8&amp;s=AARTsJqr0nyp14Q9l_Jg14yHuir4TDquHg&amp;ll=33.980271,-117.368102&amp;spn=0.010676,0.039997&amp;z=13&amp;output=embed"></iframe><p class="view-map"><a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=Coffee+Depot+3204+Mission+Inn+Avenue+Riverside+CA+92507&amp;sll=33.955389,-117.389313&amp;sspn=0.009122,0.014055&amp;ie=UTF8&amp;ll=33.980271,-117.368102&amp;spn=0.010676,0.039997&amp;z=14&amp;source=embed">View Larger Map</a></p>');
	//$('div.location-map:first').html(escape()'<iframe width=\"466\" height=\"150\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" style="border:1px solid #999;\" src=\"http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=3204+MISSION+INN+AVENUE+RIVERSIDE+CA+92507&amp;sll=33.980894,-117.366514&amp;sspn=0.011886,0.020642&amp;ie=UTF8&amp;s=AARTsJpd23br3dSTA7lj0qa3Ztu9Zhc_Sw&amp;ll=33.980734,-117.367802&amp;spn=0.010676,0.040169&amp;z=14&amp;output=embed\"></iframe><p class=\"view-map\"><a href=\"http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=3204+MISSION+INN+AVENUE+RIVERSIDE+CA+92507&amp;sll=33.980894,-117.366514&amp;sspn=0.011886,0.020642&amp;ie=UTF8&amp;ll=33.980734,-117.367802&amp;spn=0.010676,0.040169&amp;z=14&amp;source=embed\">View Larger Map</a></p>');

	$('div.location-map:last').html('<iframe width="466" height="150" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" style="border:1px solid #999;" src="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=Coffee+Depot+3540+Riverside+Plaza+Dr&amp;sll=33.954787,-117.389324&amp;sspn=0.018244,0.02811&amp;ie=UTF8&amp;s=AARTsJoYn02Rk8E_PC6UAwk-HB-PTU5bmA&amp;ll=33.955393,-117.389324&amp;spn=0.010679,0.039997&amp;z=14&amp;output=embed"></iframe><p class="view-map"><a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;geocode=&amp;q=Coffee+Depot+3540+Riverside+Plaza+Dr&amp;sll=33.954787,-117.389324&amp;sspn=0.018244,0.02811&amp;ie=UTF8&amp;ll=33.955393,-117.389324&amp;spn=0.010679,0.039997&amp;z=14&amp;source=embed">View Larger Map</a></p>');
});

// ]]>
