$(document).ready(function() {
	
	//Slide the Employee Portal posts
	$('.view-employee-portals .views-field-view-node .field-content').click(function() {
		$(this).text($(this).text() == 'Less' ? 'More' : 'Less');
  		$(this).parents('.views-row').children('.view-employee-portals .views-field-body, .view-employee-portals .views-field-field-portal-image-fid, .view-employee-portals .views-field-field-uploaddocument-fid').slideToggle('slow', function() {
  		});
	});
	
		//Prevent event propagation and click
		$(".view-employee-portals .views-field-view-node .field-content").click(function(e) {
  			e.preventDefault();
		});
	
	
	$('#sidebar-left ul.menu li ul').siblings('a').append('<img src="/sites/all/themes/mss/images/downarrow.png" alt="+" class="downArrow" />');
	
	$('.inlinequote').each(function() {
		$(this).children('p:last').append('<img src="/sites/all/themes/mss/images/inlineQuote-closing.png" alt="" style="margin-left:5px;" />');
	});
	

	/*$('.section-about-us #sidebar-left ul.menu li a[title=About Us]').addClass('active-trail').siblings('ul').slideDown();*/
	$('.section-major-segments #sidebar-left ul.menu li a[title=Industry Sectors]').addClass('active-trail').siblings('ul').slideDown();
	$('.section-company-profile #sidebar-left ul.menu li a[title=Company Profile]').addClass('active-trail').siblings('ul').slideDown();
	$('.section-employment #sidebar-left ul.menu li a[title=Employment]').addClass('active-trail').siblings('ul').slideDown();
	$('.section-employee-portal #sidebar-left ul.menu li a[title=Employee Portal]').addClass('active-trail').siblings('ul').slideDown();
	
	$('a[href="/major-segments"], a[href="/industry-sectors"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Industry Sectors]').siblings('ul').slideToggle();
		return false;
	});
	
	$('a[href="/company-profile"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Company Profile]').siblings('ul').slideToggle();
		return false;
	});
	
	$('a[href="/employment"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Employment]').siblings('ul').slideToggle();
		return false;
	});
	
	$('a[href="/employee-portal"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Employee Portal]').siblings('ul').slideToggle();
		return false;
	});
	
	$('a[href="/employment/employment-opportunities"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Employment Opportunities]').siblings('ul').slideToggle();
		return false;
	});
	
	$('a[href="/employmee-portal/internal-opportunities"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=Internal Opportunities]').siblings('ul').slideToggle();
		return false;
	});
	
	/* $('a[href="/about-us"]').click(function()	{
		$('#sidebar-left ul.menu li a[title=About Us]').siblings('ul').slideToggle();
		return false;
	}); */
	
	$("#toboggan-login-link").click(function () {
      $(this).hide();
      return true;
    });

	
	/* Link the thirds block */
	$('.thirds-block.what-we-do-block').click(function() {
		window.location.href = '/what-we-do';
	});
	$('.thirds-block.clients-block').click(function() {
		window.location.href = '/clients';
	});
	$('.thirds-block.employment-block').click(function() {
		window.location.href = '/employment/employment-opportunities';
	});
	$('.thirds-block.employment-block a').click(function(ev) {
		ev.stopPropogation();
	});
	
	/* Add Print button and style other links correctly */
	$('#block-menu-secondary-links ul.menu').children('li.first').removeClass('first');
	$('#block-menu-secondary-links ul.menu').prepend('<li class="leaf first"><a href="JavaScript:window.print();">Print</a></li>');
	
	$('.quote:first').fadeIn(1000);
	
	$('#billboard-blocks #block-views-img_rotator-block_1 .views-field-field-banner-img-fid .field-content').cycle('fade');
	$('#billboard-blocks #block-views-img_rotator-block_2 .views-field-field-banner-img-fid .field-content').cycle('fade');
	$('#billboard-blocks #block-views-img_rotator-block_3 .views-field-field-banner-img-fid .field-content').cycle('fade');
	$('.bunchOfQuotes').cycle({fx:'fade', timeout:8000});
	$('.bunchOfIntroQuotes').cycle({fx:'fade', timeout:8000});
	$('#billboard-blocks #block-views-img_rotator-block_4 .views-field-field-banner-img-fid .field-content').cycle('fade');
	$('#billboard-blocks #block-views-img_rotator-block_5 .views-field-field-banner-img-fid .field-content').cycle('fade');
	$('#billboard-blocks #block-views-img_rotator-block_6 .views-field-field-banner-img-fid .field-content').cycle('fade');
		
		$("#video-overlay").flashembed("/sites/all/themes/mss/flash/jwplayer/player-licensed.swf", {
			file: '/sites/all/themes/mss/flash/videos/corporate-video.flv',
			allowfullscreen: true, 
			allowscriptaccess: 'always',
			skin: 'flash/jwplayer/modieus.swf', 
			autostart: true
		});
		
		$('#launch-video').overlay({
			expose: '#000000',
			opacity: 0.7
		});
		
		$("#video-overlay2").flashembed("/sites/all/themes/mss/flash/jwplayer/player-licensed.swf", {
			file: '/sites/default/files/Blue.mp4',
			allowfullscreen: true, 
			allowscriptaccess: 'always',
			skin: 'flash/jwplayer/modieus.swf', 
			autostart: true
		});
		
		$('#launch-video2').overlay({
			expose: '#000000',
			opacity: 0.7
		});

		$('#container-tabs').tabs({ fx: { opacity: 'toggle' } });
		
		//Set 'Pay Your Account' link in top secondary nav to open in new window		
		//$('#block-menu-secondary-links li a[href=https://pnpnet.qvalent.com/cps]').attr('target', '_blank');
		

	$('#webform-client-form-136 #edit-submitted-full-name').val('Your Full Name & Payroll ID');
	$('#webform-client-form-136 #edit-submitted-message').val('Message');
	
	$('#webform-client-form-136 #edit-submitted-full-name').focus(function() {
			if (this.value == 'Your Full Name & Payroll ID') {
				this.value = '';
				}
			});
			
	$('#webform-client-form-136 #edit-submitted-full-name').blur(function() {
			if (this.value == '') {
				this.value = 'Your Full Name & Payroll ID';
				}
			});
			
	$('#webform-client-form-136 #edit-submitted-message').focus(function() {
			if (this.value == 'Message') {
				this.value = '';
				}
			});
			
	$('#webform-client-form-136 #edit-submitted-message').blur(function() {
			if (this.value == '') {
				this.value = 'Message';
				}
			});
			
			
	$(".view-Employee-Forms .views-table a").attr("target","_blank");
	
	$(".block-views .views-field-field-newsletter-upload-fid a").attr("target","_blank");
	
	$(".block-views .views-row .views-field-field-uploaddocument-fid a").attr("target","_blank");
	
	
	

});

/*
$.fn.browseMenu = function(options) {
		var optionsHeight = $(this).children('form').height();
		var optionsWidth = $(this).children('form').width();
		var topMargin = optionsHeight / 2;
		var rootId = $(this).attr('id');
		$(this).find('input').attr('checked', false);

		
		$(this).addClass('browseMenu');
		$(this).children('form').hide().addClass('browseMenu-options').css({'marginLeft':'0','position' : 'absolute', 'height':0});
		
		$(this).hover(function() {
			$(this).children('form').animate({
                    height: optionsHeight + 'px',
					opacity: 1
                }, 400);
		}, function() {
			$(this).children('form').animate({
                    height: 0,
					opacity: 0
				}).fadeOut();
		});

	}*/
