(function($) {
	jQuery(document).ready(function() {
	
	$.fn.digits = function() { 
		return this.each(function() { 
			$(this).text( $(this).text().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") ); 
			})
		}
		
	// TECH SUPPORT TABS
	var tabContainers = $('div#tab-group > div');
    tabContainers.hide().filter(':first').show();
                        
    $('div#tab-group ul#pager a').click(function () {
        tabContainers.hide();
        tabContainers.filter(this.hash).show();
            $('div#tab-group ul#pager a').removeClass('active');
            $(this).addClass('active');
                return false;
    }).filter(':first').click();  

	//add class to remove margin from list item links
	var homeFirst = $('#featured li:first').addClass('first');
	var homeLast = $('#featured li:last').addClass('last');
	
	
	var navFirst = $('ul#menu-primary-navigation li:first');
	var navLast = $('ul#menu-primary-navigation li:last');
	navFirst.addClass('first');
	navLast.addClass('last');
	
	//LOGIN LINK
	var login = $("a#c-login");
	var btn = $("#forgotP span");
	var logbox = $("#login-block");
	login.click(function (e) {
	e.preventDefault();
		logbox.animate({
		"height": "toggle",
		"opacity": "1.0"
		}, 300);
	}); 
	btn.click(function () {
	 if ( logbox.css('visibility', 'visible') ) {
		logbox.slideUp();
	 }
	}); 
	
// cycle header
	$('#company_banner').cycle({ 
			fx:     'fade', 
			speed:  800, 
			timeout: 8000,  
		
		});	
	
	$('#rotation').before("<ul id='pager-nav'></ul>").cycle({ 
		fx:     'fade', 
		speed:  800, 
		timeout: 8000,  
		pager: '#pager-nav',
		// callback fn that creates a thumbnail to use as pager anchor 
		pagerAnchorBuilder: function(idx, slide) { 
			return '<li><a href="#">' + (slide.title) + '</a></li>';
		}
	});	

	$(document).ready(function() { 				
var options = { 
	target:    '#alert'
	}; 
	$('#opus-form').ajaxForm(options); 
	}); 
										
	$.fn.clearForm = function() {
	return this.each(function() {
		var type = this.type, tag = this.tagName.toLowerCase();
		if (tag == 'form')
			return $(':input',this).clearForm();
		if (type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if (type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if (tag == 'select')
			this.selectedIndex = -1;
		});
	};

	
	});
	
})(jQuery);
