 var GB_ANIMATION = true;
 $(document).ready(function(){
	
	// NAV - SUPERFISH/SUCKERFISH
	$("#nav").superfish({
	});

	// click on splash page div to send to home page
	$('#splash-main').hover(
		function(){
			$(this).css({'cursor':'pointer'});
		},
		function(){
			$(this).css({'cursor':'default'});
	});
	$('#splash-main').click(function(){
		window.location='home.php';
	});
	
	//set class for links to external sites and other document types
	$('#content a[href^="http://"]').attr('target', '_blank');
	$('#content a[href^="http://lcgr.net/"]').attr('target', '_self');
	$('#content a[href^="http://lincrev.org/"]').attr('target', '_self');
	$('#content a[href$=".pdf"]').addClass('pdf').attr('target','_blank');
	$('#content a[href$=".ppt"]').addClass('powerpoint').attr('target','_blank');
	$('#content a[href$=".doc"]').addClass('word').attr('target','_blank');
	$('#content a[href$=".xls"]').addClass('excel').attr('target','_blank');
	$('#content a[href$=".csv"]').addClass('excel').attr('target','_blank');
	
	$('#state_photos a').attr('target', '_blank');
	$('#facebook a').attr('target', '_blank');
	$('#weatherwidget a').attr('target', '_blank');
	
	$('.view_details').click(	
			function(){
				var toggleHide = 'images/templates/hide.gif';
				var toggleShow = 'images/templates/view.gif';
				var eDiv = $('div.'+$(this).attr('rel'));
				var eImg = $(this).children('img');

			if(eDiv.is(':hidden')){
					$(this).children('img').attr('src', toggleHide);
					eDiv.show('slow');
				
				}	
						
			else if(eDiv.is(':visible')){
					$(this).children('img').attr('src', toggleShow);
					eDiv.hide('slow');
				
				}
			
			 $(this).blur();
				
				
		});
					
	// set poll radio as unchecked
	$('input[name=pollvote]').attr('checked', '');

	$('#submitVote').click(function(){
		$.post('get_poll_results.php', {'this_vote' : $('input[name=pollvote]:checked').val(), 'pollid' : $('input[name=pollid]').val() }, function(data){			
			
				$("#showPollResults").show();
				$("#showPollResults").html(data);
				// uncheck the vote
				$('input[name=pollvote]').attr('checked', '');
				
			});			
		});
	
	$('#viewPollResults').click(function(){
			$("#showPollResults").toggle();
			$.post('get_poll_results.php', {'pollid' : $('input[name=pollid]').val() }, function(data){			
			
			$("#showPollResults").html(data);
					
		});			

	});
	
	// before-after image swap on property listings
	$.swapImage(".swapImage");

	 

   $("a.greybox").click(function(){
		 var t = this.title || $(this).text() || this.href;
		GB_show(t,this.href,450,500);
	
		return false;
	});

	if($('a[rel^=facebox]')){
		
		$('a[rel^=facebox]').facebox();
	
	}
	
	$('.sf-menu li:last-child a').addClass("nb");  

	if($("a[rel^='prettyPhoto']")){
			
		$("a[rel^='prettyPhoto']").prettyPhoto({
			allow_resize: false,
			overlay_gallery: false,
			theme: 'light_rounded'
		});
		
	}


// slideshow
if($('#slideshow-photos')){
	$('#slideshow-photos').after('<div id="slideshow-nav">').cycle({ 
		fx:     'fade', 
		speed:  5000, 
		before: onBefore,
		after : onAfter,
		pager: '#slideshow-nav' 
	});
	
}

if($('#slideshow-photos-home')){
	$('#slideshow-photos-home').cycle({ 
		fx:     'fade', 
		speed:  4000
	});
	
}




}); /* END DOCUMENT READY */


function onAfter() { 
    $('#slideshow-caption').html(this.alt);
   
}

function onBefore() { 
    $('#slideshow-caption').html(this.alt);
   
}


