/* see http://jquery.com/ for help */

var ecfp = {
	quotes: {
		list: [
			{
				cite: "Lynne Worth, York Properties",
				comment: "In Cameron Village Shopping Center, East Coast has installed very complex sprinkler systems in numerous tenant occupied spaces. The ECFP installation crews were very professional and there were no interruptions to the tenant's business."
			},
			{
				cite: "Scott Duckworth, Brasfield & Gorrie",
				comment: "ECFP has been working with our Raleigh office on projects from the day we opened our branch, over 9 years ago. We have completed many projects together over that time period and they are always someone we can count on to provide a top quality product."
			},
			{
				cite: "Mark Hourigan, President of Hourigan Construction Corp.",
				comment: "Integrity. If I get their word, if I get their commitment, and we agree and shake hands on it, that deal is done."
			},
			{
				cite: "DPR Construction, National Audio Visual Conference Center (NAVCC) Team, Craig Fisher, Jason Ragolia, R. Bruce Lowe, Michael B. White",
				comment: "Your entire team worked effectively and efficiently. We appreciated everyone's hard work and commitment to the project. You all were a significant part of the success of the project and look forward to having you all on our next project as the Fire Protection Contractor!"
			}
		],
		setup: function() {
			var r = Math.floor(Math.random()*(ecfp.quotes.list.length));
			$("<em>&#8220;"+ecfp.quotes.list[r].comment+"&#8221;</em> <strong>"+ecfp.quotes.list[r].cite+"</strong>").appendTo("#quote");
		}
	},
	locations: {
		setup: function(){
			$("#content div.location").hide();	
			$("#content div.state h3")
				.addClass("jsclick")
				.click(function(event){
					$("div.location:visible").not($(event.target).siblings()).hide("fast");
					$(event.target).removeClass("jshover").siblings("div.location").show("fast");
				})
				.hover(
					function(event){$(event.target).addClass("jshover");},
					function(event){$(event.target).removeClass("jshover");}
				);
		},
		map: function(){
			if (GBrowserIsCompatible()) {
				var map = new GMap2(document.getElementById("map"));
				map.setCenter(new GLatLng(37.4419, -122.1419), 13);
			}
		}
	},
	links: {
		pop_externals: function() {
			$("#content a[@rel=external]").click(function(event){
				var winpop = window.open($(event.target).attr("href"));
				return false;
			});
		}
	},
	news: {
		setup: function(){
			$("#NewsArticles div.article").hide();	
			$("#content div.year h3")
				.addClass("jsclick")
				.click(function(event){
					$("div.article:visible").not($(event.target).siblings()).hide("slow");
					$(event.target).removeClass("jshover").siblings("div.article").show("slow");
				})
				.hover(
					function(event){$(event.target).addClass("jshover");},
					function(event){$(event.target).removeClass("jshover");}
				);
		}
	},
	slides: {
		setup: function(){
			ecfp.slides.make_nav();
			ecfp.slides.make_titles();
			$("#content div.slides")
				.jCarouselLite({
					btnNext: ".next",
					btnPrev: ".prev",
					visible: 1
				});
		},
		make_nav: function(){
			$('<div class="prev">prev</div> <div class="next">next</div>').appendTo("#content div.slides");
		},
		make_titles: function(){
			$("#content div.slides li img").each(function(item){
				$(this).parent().append("<span>"+$(this).attr("alt")+"</span>");
			});
		}
	},
	teasers: {
		setup_gallery: function(){
			$("#GalleryTeaser")
				.jCarouselLite({
					visible: 1,
					auto: 6000,
					circular: false
				});
		}
	}
}

$(function(){
	ecfp.slides.setup();
	ecfp.teasers.setup_gallery();
	ecfp.quotes.setup();
	ecfp.locations.setup();
	ecfp.news.setup();
	ecfp.links.pop_externals();
});