﻿$('html').addClass('js');

$(document).ready(function(){

	$('html').removeClass('js');
	
	// Nav manipulation - 'sfhover' class helps out old browsers that don't support the :hover pseudo-class on certain tags,
	// based on http://www.htmldog.com/articles/suckerfish/dropdowns/
	$('#navbar ul').hide();
	$('#navbar li').hover(function(){
		$(this).addClass('sfhover').find('ul').show(0);
	},function(){
		$(this).removeClass('sfhover').find('ul').hide(0);
	});

	// Slideshow module
	$('#slide')
	.after('<div id="photo-pager"></div><a class="button-prev left" href="#"><span>Previous</span></a><a class="button-next right" href="#"><span>Next</span></a>')
	.cycle({
		fx:  'fade',
		timeout:  6000,
		next:  '.button-next',
		prev:  '.button-prev',
		pager:  '#photo-pager',
		activePagerClass:  'selected',
		cleartype:  true,
		cleartypeNoBg:  true
	});
	
	// Industry selector module
	$('#industry-selector div')
	.after('<a class="nav-left" href="#">Prev</a><a class="nav-right" href="#">Next</a>')
	.cycle({
		fx:  'fade',
		timeout:  0,
		speed:  0,
		next:  '.nav-right',
		prev:  '.nav-left'
	});
	
	// Photo viewer module
	$('#photoviewer')
	.after('<div id="photo-pager"></div>')
	.cycle({
		fx:  'fade',
		pager:  '#photo-pager',
		activePagerClass:  'selected'
	});
	
	$('.module #photo-pager').before('<a class="button zoom"><span>View Larger</span></a>');
	
	$('a.zoom').click(function() {
		$('#photoviewer a').each(function(){
			var currentSlide = $(this).css('opacity');
			if(currentSlide > 0.5){
				$(this).trigger('click');
			}
		});
	});
	
	// Overlay
	$("a.overlay, area.overlay").fancybox({
		'overlayOpacity'		: 0.75,
		'overlayColor'			: '#000',
		'titleShow'				: false,
		'speedIn'				: 800,
		'ajax'					:{
				'cache'			: false
				}
	});
	
	// Home Page Nav Overlay - we need to hide the main Flash app on overlay load due to performance issues
	$("body#home a.overlay").fancybox({
		'overlayOpacity'		: 0.75,
		'overlayColor'			: '#000',
		'titleShow'				: false,
		'speedIn'				: 800,
		'onStart'				: hideHomeFlash,
		'onClosed'				: revealHomeFlash,
		'ajax'					:{
				'cache'			: false
				}
	});
	
	function hideHomeFlash() {
		$('#flashcontent').css('display', 'none');
	};
	
	function revealHomeFlash() {
		$('#flashcontent').css('display', 'block');
	};
	
	// Video Overlay - we need to hide the small video on overlay load due to performance issues
	$("a.overlay-video").fancybox({
		'overlayOpacity'		: 0.75,
		'overlayColor'			: '#000',
		'titleShow'				: false,
		'speedIn'				: 800,
		'onStart'				: hideVideo,
		'onClosed'				: revealVideo
	});
	
	function hideVideo() {
		$('#flash_video_thumb').css('display', 'none');
	};
	
	function revealVideo() {
		$('#flash_video_thumb').css('display', 'block');
	};
	


	//$('#accordion').accordion( "destroy" );
	
		// Accordion

		
		$("#accordion div").clone().prependTo("#accordion-printable");	
		//$('#accordion').clone().attr('#accordion', '#accordion')? 

		$('#accordion').accordion({
			active: false,
			autoHeight: false,
			collapsible: true,
			header: 'h5'
		});
	
		
	// Cycle People Photos	
	var peopleArray = ['blue-shirt', 'red-tie', 'gray-suit', 'tan-suit'];
	var arrayIteration = Math.floor(Math.random()*4);
	$('div#main').removeClass();
	$('div#main').addClass(peopleArray[arrayIteration]);	
	$('img.person').attr('src', '/img/img_'+peopleArray[arrayIteration]+'.png');
		
});

function callFancy(my_href) {
	var j1 = document.getElementById("hiddenclicker");
	j1.href = my_href;
	$('#hiddenclicker').trigger('click');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}




