var $j = jQuery.noConflict();
$j(document).ready(function(){
	// search field events
	var sf = $j('#s'), sfd = $j('#search-field');
	sf.focus(function(){
		sf.addClass('search-focus');
		sfd.addClass('search-focus');
		if(sf.val() == 'Search...'){
			sf.val('');
		}
		sf.select();
	});
	sf.blur(function(){
		sf.removeClass('search-focus');
		sfd.removeClass('search-focus');
		if(sf.val() == ''){
			sf.val('Search...');
		}
	});
	
	// rotator init
	initRotator();
	
	// wire up lightbox
	var lb = $j('a.lightbox');
	if(lb.length){
		lb.lightBox();
	}
	
	// contact form events
	
	
});

// rotator
var rd, rdFirst, rInt, rTran;
function initRotator(rd){
	rd = $j('#rotator div');
	rdFirst = rd.first();
	rInt = 7000;
	rTran = 1000;
	if(rd.length){
		rd.css({opacity: 0.0});
		rdFirst.css({opacity: 1.0}).addClass('show');
		if(rd.length > 1){
			setInterval('rotate()', rInt);
		}
	}
}
function rotate() {
	var shown = $j('#rotator div.show');
	var curr = (shown ?  shown : rdFirst);
	var next = (curr.next().length ? (curr.next().hasClass('show') ? rdFirst : curr.next()) : rdFirst);	
	next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, rTran);
	curr.animate({opacity: 0.0}, rTran).removeClass('show');
};
	
	