// JavaScript Document
$(document).ready(function() {
	var ROOF = {

	  init: function() {
	    ROOF.megaMenus.init();
	  },

	  megaMenus: {
	    init: function() {
	      $('#nav ul > li').hoverIntent({
	        sensitivity: 2,
	        interval: 100,
	        over: ROOF.megaMenus.over,
	        out: ROOF.megaMenus.out,
	        timeout: 0
	      });
	    },
	    over: function() {
	      $(this).find('.sub').stop().show('fast');
	    },
	    out: function() {
	      var _this = $(this);
	      $(this).find('.sub').stop().hide('fast');
	    }//end over and out
	  }
                                                                                
	}//end roof
	
ROOF.init();
	
$("a.fancy").fancybox();

$("a.iframe").fancybox({width: 300, height: 100,overlayOpacity: .4, overlayColor: '#000'});

$(".home-button-link").fancybox({
	'width'				: '75%',
	'height'			: '75%',
    'autoScale'     	: false,
    'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
    'scrolling'         : true
});


$(".emergency-button").fancybox({
	'width'				: '75%',
	'height'			: '90%',
    'autoScale'     	: false,
    'transitionIn'		: 'none',
	'transitionOut'		: 'none',
	'type'				: 'iframe',
	'scrolling'         :  true
});


$("a.youtube").click(function() {
	$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'		: 'transparent',
		    'allowfullscreen'	: 'true'
			}
		});

	return false;
});


	$("a.group").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayShow'	:	true
	});


$(function() {
$(".swapper").hover(
function () {
$(this).attr("src", $(this).attr("src").replace(/-off.png/, "-on.png"));
},
function () {
$(this).attr("src", $(this).attr("src").replace(/-on.png/, "-off.png"));
} 
);
});

//home page image rotation
$('#default').cycle({
		fx: 'fade',
	   timeout: 5000
	});
	
	
// DO NOT USE MESSES WITH MEGA DROP DOWNS
// $('#navigate').autosprites({
//         offset: '58px',
//         activeState: false,
//         activeSprites: true,
//         outSpeed: 100
//     });

$("#home-accordion").tabs("#home-accordion div.home-pane", {tabs: 'h2', effect: 'slide', /*event: 'mouseover',*/ initialIndex: null });
$("#faq-accordion").tabs("#faq-accordion div.faq-pane", {tabs: 'h2', effect: 'slide', /*event: 'mouseover',*/ initialIndex: 0 });

$('.home-trigger').click(function(){
$(".home-active").hide('blind',500);
$(".home-active").removeClass();
});

$('#people-trigger').click(function(){
$('#people').show('blind',500);
$('#people').addClass('home-active');

});

$('#advantage-trigger').click(function(){
$('#advantage').show('blind',500);
$('#advantage').addClass('home-active');
});

$('#customers-trigger').click(function(){
$('#customers').show('blind',500);
$('#customers').addClass('home-active');
});

$('.more').click(function(){
$('.less').show();
});

$('#project-vid').click(function(){
$('#project-pic').removeClass('project-picture-on');
$('#project-pic').addClass('project-picture');
$('#project-vid').removeClass('project-video');
$('#project-vid').addClass('project-video-on');
$('.pictures-scrollable').hide();
$('#project-video').show();
$('#project-media .prev').hide();
$('#project-media .next').hide();
});

$('#project-pic').click(function(){
$('#project-vid').removeClass('project-video-on');
$('#project-vid').addClass('project-video');
$('#project-pic').removeClass('project-picture');
$('#project-pic').addClass('project-picture-on');
$('#project-video').hide();
$('.pictures-scrollable').show();
$('#project-media .prev').show();
$('#project-media .next').show();
});



$(function() {
	$(".people-scrollable").scrollable({ circular: false, mousewheel: true });
});

$(function() {
	$(".team-scrollable").scrollable({ circular: false, mousewheel: true });
});

$(function() {
	$(".advantage-scrollable").scrollable({ circular: false, mousewheel: true });
});

$(function() {
	$(".customers-scrollable").scrollable({ circular: false, mousewheel: true });
});

$(function() {
	$(".pictures-scrollable").scrollable({ circular: false, mousewheel: true });
});

//$(".tabs:first").tabs(".project-panes:first > div.pane", {initialIndex: 0});

//$(".round-me").corner();

});//end whole thing

$(function(){
	//Get our elements for faster access and set overlay width
	var div = $('div.sc_menu'),
		ul = $('ul.sc_menu'),
		ulPadding = 15;
	
	//Get menu width
	var divWidth = div.width();

	//Remove scrollbars	
	div.css({overflow: 'hidden'});
	
	//Find last image container
	var lastLi = ul.find('li:last-child');
	
	//When user move mouse over menu
	div.mousemove(function(e){
		//As images are loaded ul width increases,
		//so we recalculate it each time
		var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;	
		var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
		div.scrollLeft(left);
	});
});

$(function()
{
	var pane = $('#project-copy');
	pane.jScrollPane(
		{
			showArrows: false,
			animateScroll: true
		}
	);
	var api = pane.data('jsp');

	$('.more').bind(
		'click',
		function()
		{
			api.scrollBy(parseInt($(this).attr('rel')), parseInt($(this).attr('rel')));
			return false;

		}
	);

	$('.less').bind(
		'click',
		function()
		{
			api.scrollBy(parseInt($(this).attr('rel')),parseInt($(this).attr('rel')));
			return false;
		}
	);
});



