	jQuery(document).ready(function(){		
		$(function(){
			$.fn.supersized.options = {  
				startwidth: 700,  
				startheight: 475,
				vertical_center: 0,
				slideshow: 1,
				navigation: 0,
				transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
				pause_hover: 0,
				slide_counter: 0,
				slide_captions: 1,
				slide_interval: 9000,
				slide_dots: 0  
			};
	        $('#supersize').supersized(); 
	    });
	    
	    $("#supersizeOverlay").fullBg();

	    
	    //tamingselect($('#views-exposed-form-p-filters-block-9').find('.form-select'));
	    
		$("#views-exposed-form-p-filters-block-9").change(function() {
		  $("#views-exposed-form-p-filters-block-9").submit();
		});
		$("#views-exposed-form-project-view-page-1").change(function() {
		  $("#views-exposed-form-project-view-page-1").submit();
		});
		
		
		$("#views-exposed-form-mid-labs-page-1").find('#edit-focus, #edit-lab-type, #edit-mid, #edit-class').dropdownchecklist({ width: 125 });
		  // Hide the apply button.
		 $('#views-exposed-form-mid-labs-page-1 input:submit').hide();
		
		  // When the change event fires, run the submit handler
		  $('.ui-dropdownchecklist-item input').change(function() {
		    $("#labs_loading").fadeIn("normal");
		    $urlToLoad = "labs?" + $("#views-exposed-form-mid-labs-page-1").serialize() + " #labs_container > .wrapper";
		    $('#labs_container').load($urlToLoad, function() { $("#labs_loading").fadeOut("normal"); });
		  }); 
		  
		  /*
$('#labs_container > .teaser_title').click(function(e){
		  	   $("#labs_loading").fadeIn("normal");
		  	   $urlToLoad = $(this).attr('href');
		       $('#labs_container').load($urlToLoad, function() { $("#labs_loading").fadeOut("normal"); });
		  });
*/
		
		
		/*
		// labs - toggle display from list to images
		
		
$('.toggle_archive').each( function(e) {
	    	var featured = $(this).find('.widget_list');
	    	var archive = $(this).find('.archive_list');
	    	var button = $(this).find('a.pushButton');
	    	
	    	$(button).click( function(e) {
		    	if ($(featured).css("display") == "none") { // if featured is currently hidden 
		    		$(featured).css("display", "block");
		    		$(archive).css("display", "none");
		    	} else {
		    		$(featured).css("display", "none");
		    		$(archive).css("display", "block");
		    	}
		    	e.preventDefault();
	    	});
		});
*/




/*
	    $('.project_teaser').each(function() {
	    
	    	var elem = $(this).find('a.imagecache');
	    	var details = $(this).find('div.project_details');
	    
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#FDFDFB',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			      border: {
			         width: 1,
			         radius: 10,
			         color: '#FDFDFB',
			         
			      },
			      tip: 'topRight',
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'rightTop'
				      }
				   }
			 });
		 });
*/
	  
	  var ct = 0;
	  
	  $('.project_teaser').each(function() {
	    	ct ++;
	    	var elem = $(this);
	    	if (ct == 4) {
	    		elem.addClass("clear");
	    		ct = 1;
	    	}
	    	
	    	
	   
		 });
		 
		 
		
	    $('.profile_teaser').each(function() {
	    
	    	var elem = $(this).find('img.imagecache-173_250_thumb');
	    	var details = $(this).find('div.profile_details');
	    
	   
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#FDFDFB',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			      border: {
			         width: 1,
			         radius: 10,
			         color: '#FDFDFB',
			         
			      },
			      tip: 'topRight',
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'rightTop'
				      },
				      adjust: { x: 10, y: -50 }
				   }
			 });
		 });
		 
		 $('.blog_teaser').each(function() {
	    
	    	var elem = $(this).find('a.blog_title');
	    	var details = $(this).find('div.blog_details');
	    
	   
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#FDFDFB',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			      border: {
			         width: 1,
			         radius: 10,
			         color: '#FDFDFB',
			         
			      },
			      tip: 'topRight',
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'rightTop'
				      }
				   }
			 });
		 });
		 
		/*
 $('.guest_teaser > h3 > a[href]').qtip({
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#FDFDFB',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			      border: {
			         width: 1,
			         radius: 10,
			         color: '#FDFDFB',
			         
			      },
			      tip: 'topRight',
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'rightTop'
				      }
				   }
			 });
*/
			 
		 


		
		
	    
/*
	    $('.project_teaser').each(function() {
	    
	    	var elem = $(this).find('a.imagecache');
	    	var details = $(this).find('div.project_details');
	    
	   
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 215,
			     
			      height: 110,
			      background: 'rgba(255,255,255,0.6)',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			   
			      
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'center'
				      }
				   }
			 });
		 });
	  
		
	    $('.profile_teaser').each(function() {
	    
	    	var elem = $(this).find('img.imagecache-129_thumbnail');
	    	var details = $(this).find('div.profile_details');
	    
	   
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 200,
			      padding: 5,
			      background: '#FDFDFB',
			      color: '#3D3D3C',
			      textAlign: 'Left',
			      
			      border: {
			         width: 1,
			         radius: 10,
			         color: '#FDFDFB',
			         
			      },
			      tip: 'topRight',
			   },
			   hide: { when: 'mouseout', fixed: true},
			   position: {
				      corner: {
				         target: 'center',
				         tooltip: 'rightTop'
				      }
				   }
			 });
		 });
		 
		 $('.blog_teaser').each(function() {
	    
	    	var elem = $(this).find('a.blog_title');
	    	var details = $(this).find('div.blog_details');
	    
	   
	    	$(elem).qtip({
			   content: { text: details},
			   style: { 
			      width: 295,
			      padding: 5,
			      background: '#FFFEE2',
			      color: '#3D3D3C',
			      textAlign: 'center',
			      border: {
			         width: 5,
			         radius: 0,
			         color: '#FFFEE2'
			      },
			      tip: 'rightMiddle',
			   },
			   position: {
				      corner: {
				         target: 'leftMiddle',
				         tooltip: 'rightMiddle'
				      }
				   }
			 });
		 });
		 
		 $('.guest_teaser > h3 > a[href]').qtip({
			   style: { 
			      width: 230,
			      padding: 5,
			      background: '#FFFEE2',
			      color: '#3D3D3C',
			      textAlign: 'center',
			      border: {
			         width: 5,
			         radius: 0,
			         color: '#FFFEE2'
			      },
			      tip: 'rightMiddle',
			   },
			   position: {
				      corner: {
				         target: 'leftMiddle',
				         tooltip: 'rightMiddle'
				      }
				   }
			
		 });
		 
*/
		 		
	    
	   /*
 // initialize tooltip
		$(".profile_teaser > a.imagecache-129_thumbnail").tooltip({
		   // tweak the position
		   // use the "slide" effect
		   effect: 'fade',
		   predelay: 0100,
		   position: 'top center',
		   offset: [0, 0]
		   
		
		// add dynamic plugin with optional configuration for bottom edge
		})
		
		// initialize tooltip
		$("a.guest_name[href]").tooltip({
		   // tweak the position
		   offset: [0, 0],
		
		   // use the "slide" effect
		   effect: 'fade',
		   predelay: 1000,
		   position: 'top center',
		   
		
		// add dynamic plugin with optional configuration for bottom edge
		})
		
*/
		
		
		//var window1 = $.location;
		
		
		$("#loginButton").fancybox({
			'titlePosition' : 'inside',
			'transitionIn' : 'none',
			'transitionOut' : 'none' 
		});
		
/*
		$("span.fancyEdit > a, span.fancyAdd > a, .fancyAdd > a, .fancyEdit > a, .fancyAdd, .fancyEdit ").fancybox({
								
								'transitionIn'		: 'none',
								'transitionOut'		: 'none',
								'type'				: 'iframe',
								'width'				: '600',
								'height'			: '800',
								'autoScale'			: true,
								
								
								 onStart : function() {
									//return window.confirm('Continue?');
								 },
								 onCancel : function() {
								 	//alert('Canceled!');
								 },
								 onComplete : function() {
								 	//alert('Completed!');
									
								 },
								 onCleanup : function() {
								 	//return window.confirm('Close?');
								 },
								 onClosed : function(e) {
								 	//alert('Closed!');
									ajaxReloadPage(e)
								 }
						
		});
*/
		
		//$(".fancyBox").fancybox({
		//});
		
	/*
	$(".fancyBox").fancybox({
			ajax : {
			type : "POST",
			url: "ajax-labs.php",
			}
		}); 
*/
		
		
		function submitSave(e) {
			$("input#edit-submit")
		}
		
		//var urlToLoad;
		
		
		function ajaxReloadPage(e) {
			location.reload();
			//urlToLoad = location.href;
			
			//$("html").load(urlToLoad);
			
		}
		
		$('#accordion').accordion({ 
								  autoHeight: false, 
								  header: '.header',
								  alwaysOpen: false,
								  active: true,
								  navigation: true,
								  navigationFilter: function() {
										//console.log ("      link: " + this.href.toLowerCase());
										//console.log ("must match: " + location.href.toLowerCase());
										//return this.href.toLowerCase() == location.href.toLowerCase();
								}
								  
								  });
	
				
			
		//	$('#accordion a.header').click(function() {
		//		$(this).next().slideToggle('normal');
		//		return false;
		//	}).next().hide();
		
					
	

									  
									  
		
		function ajaxLoadEditPage(e) {

			
			$.ajax({
			  type: "GET",
			  url: urlToGet,
			  dataType: "xml",
			  processData: false,
			  beforeSend: function(){
				 //console.log("starting ajax");
				 //console.log("url to get is: " + urlToGet);
			   },
			  success: function(xml){
				var temp1 = $(xml).find( "set");
				insertData(temp1);
				//console.log("AJAX success");
				//console.log(temp1);
				
				//$("#content1").append(html);
			  },
			  complete: function(){
				//console.log("AJAX complete");
			  },
			  
			  ajaxError: function(){
				//console.log("AJAX error");
			  }
		});
	}
});

(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);		
 
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
 
      var winwidth = $(window).width();
      var winheight = $(window).height();
 
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
 
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
 
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });		
      }
    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };
})(jQuery)

