/* 

Atlantic Bootup Script
v. 1.0

last mod: 4-24-08
by: Mark

jQuery based onloads.


*/


/*################################################################################## ABT BASE Functions */


$(document).ready(function() {

	$("#project-wrap").addClass("js-on");
	$("#project-info").addClass("js-on");
	
	/* Font Sizing Cookies and Styles */
		$("#secondary-content").append("<div><div id=\"page-tools\"><h5>Page Tools</h5><ul><li id=\"pt-print\"><a href=\"#\" onclick=\"printThis();\">Print page</a></li><li id=\"pt-font\">Font:<ul><li id=\"pt-font-lg\"><a href=\"#\" onclick=\"increaseFont(); return false;\">Larger</a></li><li id=\"pt-font-df\"><a href=\"#\" onclick=\"defaultFont(); return false;\">Default</a></li><li id=\"pt-font-sm\"><a href=\"#\" onclick=\"decreaseFont(); return false;\">Smaller</a></li></ul></li></ul></div></div>");
		
		loadStyles();
		setActiveStyle(getStyleFromCookie());
	/* End Font Sizing Cookies and Styles */
	
	
	
	/* Scroller */
		$(".scroller").jScrollPane({scrollbarWidth: 8});
	/* End Scroller */
	
	
		
	/* Project Details Image Viewer */
		$("#project-photos ul").addClass("canvas");
		
		/*if ($("#project-photos ul li.photo").length > 1){
		    $("#project-photos ul").append("<li><strong class=\"view-images\">View Images</strong></li><li><span class=\"previous\"><a href=\"#\">Previous</a></span></li><li><span class=\"count\"><span class=\"current\">1</span>/<span class=\"total\">&nbsp;</span></span></li><li><span class=\"next\"><a href=\"#\">Next</a></span></li>");
		}
		$("#project-photos ul span.total").html($("#project-photos ul li.photo").length);
		$("#project-photos ul li.photo").hide();
		$("#project-photos ul li.photo").eq(0).show();
		
		$("#project-photos ul li span.next").click(function(){
		
			if ($("#project-photos ul span.current").html() != $("#project-photos ul span.total").html()) {
				$("#project-photos ul li.photo").eq($("#project-photos ul span.current").html()).fadeIn("fast");
				$("#project-photos ul li.photo").eq($("#project-photos ul span.current").html()-1).fadeOut("fast");
				$("#project-photos ul span.current").html(parseInt($("#project-photos ul span.current").html())+1);
			}
			else {
				$("#project-photos ul span.current").html("1");
				$("#project-photos ul li.photo").eq(0).fadeIn("fast");
				$("#project-photos ul li.photo").eq($("#project-photos ul li.photo").length-1).fadeOut("fast");
			}
			
			return false;
		});
		
		$("#project-photos ul li span.previous").click(function(){
			
			if ($("#project-photos ul span.current").html() != "1") {
				$("#project-photos ul li.photo").eq($("#project-photos ul span.current").html()-2).fadeIn("fast");
				$("#project-photos ul li.photo").eq($("#project-photos ul span.current").html()-1).fadeOut("fast");
				$("#project-photos ul span.current").html(parseInt($("#project-photos ul span.current").html())-1);
			}
			else {
				$("#project-photos ul span.current").html($("#project-photos ul li.photo").length);
				$("#project-photos ul li.photo").eq($("#project-photos ul li.photo").length-1).fadeIn("fast");
				$("#project-photos ul li.photo").eq(0).fadeOut("fast");
			}
			
			return false;
		});*/
		$("#project-photos ul").innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '267px' });
	/* End Project Details Image Viewer */
	
	
	/* Locations Photos crossfading */
		$("ul#location-photos").addClass("canvas");
		$('ul#location-photos').innerfade({ speed: 'slow', timeout: 4000, type: 'sequence', containerheight: '164px' });
	/* End Locations Photos crossfading */
	
	/* Home Page main-graphic Photos crossfading */
		$("ul#main-photos").addClass("canvas");
		$('ul#main-photos').innerfade({ speed: 'slow', timeout: 7000, type: 'sequence', containerheight: '438px' });
	/* End main-graphic Photos crossfading */
	
	
	/* Locations Google Maps */
		if ($("#location-map").length > 0) {
			load();
		}
		
		
		$("#location-map p#enlarge-link a").click(function(){
				$("#location-map #map").animate({
				width: "664px",
				height: "300px"
			}, 600);
			
			$("#location-map p#enlarge-link a").hide();
			$("#info-photos ul#location-photos img").hide();
			$("#location-map p#close-link a").show();
			map2.addControl(mapControls);
			map2.addControl(mapType);
			var DrivingForm = '<h3 id="GMap-H3">Driving Directions</h3><form id="GMap-Form" action="http://maps.google.com/maps" method="get" target="_blank"><p><label for="saddr">Starting Address</label><input type="text" id="saddr" name="saddr" /><input type="submit" value="go" class="button" /><input name="daddr" value="' + DrivingFormAddress + '" type="hidden"><input name="hl" value="en" type="hidden"</p></form>';
			map2.openInfoWindowHtml(point, DrivingForm);  				        
		});
		
		$("#location-map p#close-link a").click(function(){
				$("#location-map #map").animate({
				width: "258px",
				height: "257px"
			}, 600, "linear", function() {$("#info-photos ul#location-photos img").show(); map2.closeInfoWindow();});
				
			$("#location-map p#close-link a").hide();			
			$("#location-map p#enlarge-link a").show();
			map2.removeControl(mapControls);
			map2.removeControl(mapType);
			map2.setCenter(new GLatLng(GLat,GLong), 12);
			
		});

	/* End Locations Google Maps */
	
},function(){
	GUnload();
});