$(window).load(function() {
    $('#slider').nivoSlider({
    	directionNavHide: false,
    	pauseTime:6000,
    	captionOpacity:1,
    	afterLoad: function() {
    		// get and set the width, remove float so controls can be centered.
    		var sliderControls = $('.nivo-controlNav');
    		var width = sliderControls.width();
    		sliderControls.width(width);
    		sliderControls.css('float', 'none');
    		
    	}
    });
    
});

this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("label.has-example").live('mouseover', function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='example'><img src='"+ $(this).attr('rel') +"' alt='url preview' />"+ c +"</p>");								 
		$("#example")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    });
    $("label.has-example").live('mouseout',
	function(){
		this.title = this.t;	
		$("#example").remove();
    });
    
	$("label.has-example").live('mousemove', function(e){
		$("#example")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function() {

	$('.FAQ .question').bind('click', function() {
			
		var child = $(this).children('.answer');
			
		if(child.hasClass('active')) {
			child.removeClass('active');
		} else {
			$('.FAQ li div').removeClass('active');
			child.addClass('active');
		}
			
	});

	if($('.gallery-images a').length) {
 		$('.gallery-images a').fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	600, 
			'speedOut'		:	200, 
			'overlayShow'	:	false
		});
	}
	
	$('#sales-reps select').bind('change', function() {
		$('#sales-reps').submit();
	});
	
	$('#sales li').bind('click', function() {
			
		var child = $(this).children('.information');
			
		if(child.hasClass('active')) {
			child.hide();
		} else {
			$('#sales .information').removeClass('active');
			child.show();
		}
			
	});
	
	$(".dashboard .zip .submit").bind('click', function() {
		$('#top-locator').submit();
	});
	
	
	
});

$(function() {
	$('#tabs').tabs();
});

	function expandcontent(e, id) {
		evt = e || window.event;
		evt.preventDefault;
		var menuItem = $('#' + id);
		if(menuItem.is(":visible")) {
			menuItem.hide();
			menuItem.siblings('.button-collapse').removeClass('button-collapse').addClass('button-expand');
		} else {
			menuItem.show();
			menuItem.siblings('.button-expand').removeClass('button-expand').addClass('button-collapse');
		}
		return false;
	}
