$(function() {
	$("#contactText").attr({
					cols: "30",
					rows: "8"
					})


	var userAgent = navigator.userAgent.toLowerCase();
    $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); 
    
    // Is this a version of IE?
    if(($.browser.msie) && ($.browser.version >= 9)){
        $("#followUsContainer").css("margin-top", "-51px");
        $("#followUsOn").css("padding", "2px 2px 1px 2px");
    }
	
	else {
        $("#followUsContainer").css("margin-top", "-60px");
		 $("#followUsOn").css("padding", "2px 2px 0px 2px");
    }
	
	/*$("#siteFacebookFeed").prependTo("#navbar");
        $("#facebookInfo").prependTo("#navbar");*/
	$("#eventsWidget").prependTo("#navbar");
        
        $("#siteFacebookFeed ul").jScrollPane();
        
	//Sort out the footers
	var uniqueCountsFooterContent = $("#bottomRight").html();
	$("#bottomMiddle").append("<br /><span id='uniqueCounts'>" + uniqueCountsFooterContent + "</span><br /><span id='adurLogo'><a href='http://www.adur.gov.uk/'><img src='../images/adc-logo-web.gif' /></a></span>");
	
	$("#bottomLeft").html("<span id='shorehamPortLogo'><a href='http://www.shoreham-port.co.uk/Home'><img src='../images/shorehamPortAuthority.png' /></a></span>");
	$("#bottomRight").html("<span id='heritageLogo'><a href='http://www.english-heritage.org.uk/'><img src='../images/englishHeritage.png' /></a></span>");
	
	//Do the restoration slideshow
	var pathname = window.location.pathname;
	if(pathname = "/page/1978-1980Restoration") {
		$.getJSON("/js/ajax/general/listFiles.php", { 'folder' : '/images/restoration/' }, function(data) {
			$.each(data, function(key, val) {
				$("#restorationSlideshow").append("<img src=\"/images/restoration/" + val +  "\" />");
			});
		}).complete(function() {
			$.getScript("/js/zingSlideshow.js", function() {
				$("#restorationSlideshow").zingSlideshow({
					timeout: 2000
				});
			});
		});
	}
	
	//Do the Future Management slideshow
	var pathname = window.location.pathname;
	if(pathname = "/page/FutureManagement") {
		$.getJSON("/js/ajax/general/listFiles.php", { 'folder' : '/images/futureManagement/' }, function(data) {
			$.each(data, function(key, val) {
				$("#futureManagementSlideshow").append("<img src=\"/images/futureManagement/" + val +  "\" />");
			});
		}).complete(function() {
			$.getScript("/js/zingSlideshow.js", function() {
				$("#futureManagementSlideshow").zingSlideshow({
					timeout: 2000
				});
			});
		});
	}
	
	$("#surveyForm").submit(function() {
		var q3 = [];
		$.each($("#question3:checked"),function() {
			q3.push($(this).val());
		});
		var q5 = [];
		$.each($("#question5:checked"),function() {
			q5.push($(this).val());
		});
		$.get("/js/ajax/user-specific/surveySubmit.php", {
			"q1" : $("#question1:checked").val(),
			"q2" : $("#question2:checked").val(),
			"q2-1" : $("#question2-1").val(),
			"q3[]" : q3,
			"q3-1" : $("#question3-1").val(),
			"q4" : $("#question4:checked").val(),
			"q5[]" : q5,
			"q6" : $("#question6").val(),
			"q7" : $("#question7:checked").val(),
			"q8" : $("#question8:checked").val(),
			"q9" : $("#question9").val(),
			"q10" : $("#question10:checked").val(),
			"q10-1" : $("#question10-1:checked").val(),
			"q10-2" : $("#question10-2").val(),
			"q11" : $("#question11:checked").val(),
			"email" : $("#emailAddress").val()
			}).complete(function() { 
				var r = confirm("Thank you for taking the time to fill out this survey!"); 
				
				if(r == true) {
					window.location = "/";
				}
				else {
					window.location = "/";
				}
		});
		
		return false;
	});
	
	//Hide the gallery widget
	$("#galleryWidget").hide();
	
});
