var nc = jQuery.noConflict();

nc(document).ready(function(){
	tab = "ul.tab_links li";
	tabcontent = "#featured_posts .tab_content";
	Nitems = nc(tab).length;
	tindex = 1;
	interval = 15000;


//adminbar login form: shows when hover on Login link
	//loginform_wrapper = "#loginform_wrapper";
/*
	nc("#wp-admin-bar ul.main-nav li.bp-login").click(function(event){
		event.preventDefault();
		nc("#loginform_wrapper").toggle(300);
	});	
	nc('#wrapper').click(function(){ nc("#loginform_wrapper").hide();});
*/	

//homepage tabber: tab rotation stops if clicked on the tab
	nc(tab).click(function(event){		
		event.preventDefault();

		self.tindex = nc(tab).index(this);
		nc(tab).removeClass('selected');
		nc(tab+':eq('+ self.tindex +')').addClass('selected');
		
		nc(tabcontent).hide();		
		nc(tabcontent+':eq('+ self.tindex +')').fadeIn();		
		clearTimeout(tabtimeout);
	});
	
	searchInputBg();
});

//called at homepage to start tab rotation
function startTabRotate(){
	tabtimeout = setTimeout('next_tab()', self.interval);
}

function next_tab(){	
	if(self.tindex < Nitems){		
		nc(tab).removeClass('selected');	
		nc(tab+':eq('+ self.tindex +')').addClass('selected');
	
		nc(tabcontent).hide();	
		nc(tabcontent+':eq('+ self.tindex +')').fadeIn(500);				
		self.tindex++;		
		tabtimeout = setTimeout('next_tab()', interval);
	}else{
		self.tindex = 0;
		next_tab();
	}		
}



function searchInputBg(){
	nc('.searchform .bginput').focus(function(){
		nc(this).addClass('focus');
	});
	
	nc('.searchform .bginput').blur(function(){
		if(nc(this).attr('value') == '' ){
			nc(this).removeClass('focus');
		}
	});
}

