// Setting '$' to '$j' to avoid conflicts between WordPress and jQuery
var $j = jQuery.noConflict();
  
$j(document).ready(function() {
		
		$j('#header h1').click(function() {
			document.location.href = '/';
		});
	

		$j("a.fb").fancybox({
			'frameWidth':425,
			'frameHeight': 350,
			'padding':5

		});
		
    	$j(document).pngFix(); 
		
        // ajax call for the answers
  		$j('#questions select').change(function(event){
	    	$j('.answer *').fadeOut(200);
	    	$j('.answer').load(event.currentTarget.value);

	  		return false;
	  	});
	
		$j('a.overlay').colorbox();
		
		// ajax call with plug in intialization in the callback for the overlay
		$j('#overlayPostSelect select').livequery('change',function(){
			
			var toLoad = $j(this).attr('value')+' #ajaxWrapper'
			
	    	$j('#ajaxWrapper').fadeOut('fast', loadContent);
	
			function loadContent() {
				$j('#overlayContentWrapper').load(toLoad,'', function() {
					
				 	$j('#ajaxWrapper').fadeIn('normal');

					$j('#slideshow').cycle({fx:'fade',speed:'fast',timeout: 0,next:'#next2',prev:'#prev2'});
					
					// removing the controls for the slideshow if 1 =< images
					
					$j("#slideshow").each(function() { 
					    if($j(this).children().length < 2) 
					        $j('#nav').remove() 
					});
					

				 });   
					
			 }

	  	});
			 
});