jQuery.noConflict();

var plauditSite = (function($){
	
	var defaultMethods = function(){
		$("body").addClass("jsEnabled");
		$("tr:odd").addClass("odd");
		$(".searchForm input#query").focus(function(){ $(this).select(); });
		$("a[href^=\"http://\"]").attr("target", "_blank");
		$("a[href^=\"https://\"]").attr("target", "_blank");
		$("a[href=\"$.pdf\"]").attr("target", "_blank");
		$("#navigation li.hasChildren").hover(
			function(){
				$(this).addClass("hover");
			}, function(){
				$(this).removeClass("hover");
			}
		);
	}();
	
	var customElements = {
			
		init: function(){
			this.faq();
			this.googleMaps();
			this.videoOverlay();
			this.testText();
		},
		
		faq: function(){
			// FAQ Setup
			
			var hash = location.hash;
			
			// If there is a hash open up that answer
			if ( hash ) { 
				$(hash)
					.addClass("open")
					.children(".answer")
					.show();
				$(hash).data("lastToggle1", 1); // jQuery toggle method uses the jquery data method internally and we are faking the value here
			}
		
			$("#faq li").toggle(
				function(){
					$(this).addClass("open");
					$(this).children(".answer").slideDown();
				}, function(){
					$(this).removeClass("open").removeAttr("class");
					$(this).children(".answer").hide();
				}
			);
			
			$("#faq li a").click(function(e){
				e.stopPropagation();
			});
		}, // FAQ
		
		googleMaps: function(){
			
			if( $("#map").length !== 0 ){ // Test if the Map div exists
				 var latlng = new google.maps.LatLng(45.094147,-93.745545);
				 var mapCenter = new google.maps.LatLng(45.049723,-93.593903);
				 var mapOptions = {
				      zoom: 9,
				      center: mapCenter,
				      mapTypeControl: false,
				      mapTypeId: google.maps.MapTypeId.ROADMAP
				};
				var map = new google.maps.Map(document.getElementById("map"), mapOptions);
			    var marker = new google.maps.Marker({
			        position: latlng, 
			        map: map,
			        title:"WH Security"
			    });  
			    
			    var infoWindowContent = '<h4>WH Security</h4>'+
			    '<p style="text-align: left;">6800 Electric Drive<br/>'+
			    'Rockford, MN 55373</p>';
			    
			    var infoWindow = new google.maps.InfoWindow({
			    	content: infoWindowContent
			    });
			    
			    google.maps.event.addListener(marker, 'click', function(){
			    	infoWindow.open(map,marker)
			    });
			}
		}, // Google Maps
		
		videoOverlay: function(){
			var options = {
				animationSpeed: 'normal',
				allowresize: false,
				showTitle: false,
				theme: 'light_rounded'	
			};
			
			$("a[rel^='lightbox']").prettyPhoto(options);
		}
		
	};
	
	customElements.init();
	
})(jQuery);


