(function($) {

  // // Fancybox opverride to add image count and "next" and "prev" links
  //  Drupal.behaviors.initFancybox = {
  //    attach : function() {
  //      var settings = Drupal.settings.fancybox;
  // 
  //       settings.options.titleFormat = function(title, currentArray, currentIndex, currentOpts) { if(currentArray.length > '1'){ return '<a href="javascript:;" id="fancybox-left-lo">&lt;</a> <span class="image-number">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span> <a href="javascript:;" id="fancybox-right-lo">&gt;</a> <span class="image-title-wrap">' + title + '</span>'; } else { return '<span class="image-number">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span> <span class="image-title-wrap">' + title + '</span>'; }  }
  // 
  //       if (settings && settings.selector.length) {
  //        $(settings.selector).fancybox(settings.options);
  //       }
  // 
  //     $('.imagefield-fancybox').fancybox(settings.options);
  // 
  //    }
  //  }  
  
  $(document).ready(function() {    	  
	  
	  //Prev and Next links on Fancybox Title
	  $('#fancybox-left-lo').live('click' ,function(e) {
   		e.preventDefault();
   		$.fancybox.prev();
   	});
	  
	  $('#fancybox-right-lo').live('click' ,function(e) {
   		e.preventDefault();
   		$.fancybox.next();
   	});
   	
   	//$('.view-next-steps-sidebar-block a.popup:not(.popup-processed)').addClass('popup-processed').fancybox({
   	//  'content': 'asdfasdf',  
   	//});
	  
      // Video and News Rotator: stop rotation
			// $('#views_slideshow_cycle_main_homepage_rotator-block_1 .video-popup').hide();
	    // $('#views_slideshow_cycle_main_homepage_rotator-block_1 .views-field-entity-id-6 a') .click(function() {
	    //   //uniqueClass = Math.round(new Date().getTime() / 1000);
	    //   //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
	    //   
	    //   $('#page').append('<div class="liveoffice-js-overlay"></div>');
			// 	$('#page').append('<div id="popup-content"></div>');
	    //   var content = $(this).parents('.right').find('.video-popup').html();
	    //   $('#popup-content').html(content);
      //   
      //   // on HTML mouseover, pause the slideshow.
      //   $('html').mouseover(function(event) {
  	  //     Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": 'homepage_rotator-block_1' });
  	  //     Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": 'news_rotator-block_1' });	      
  	  //   });
  	  //   
			// 	// hide all popups when clicking away or clicking on the close button.
	    //   $('.close-btn a').click(function() {
	    //     $('#popup-content').remove();
	    //     $('.liveoffice-js-overlay').remove();
	    //     
	    //     // Play slideshow again.
      //     $('html').mouseover(function(event) {
    	//       Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": 'homepage_rotator-block_1' });
    	//       Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": 'news_rotator-block_1' });	      
    	//     });
  	  //     
	    //     return false;        
	    //   });     
	    //   return false;  
	    // });
	    // 
	    // // Tool tips
	    // $('td.tool-tip a').hover(function() { 
	    //   $(this).next('.tool-tip').toggle();
	    //   return false; 
	    // });
	    
	
			// Provides popup on second video popup link
			//$('#views_slideshow_cycle_main_homepage_rotator-block_1 a.popup') .click(function() {
	    //  //uniqueClass = Math.round(new Date().getTime() / 1000);
	    //  //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
	    //  
	    //  $('#page').append('<div class="liveoffice-js-overlay"></div>');
			//	$('#page').append('<div id="popup-content"></div>');
	    //  var content = $(this).parents('.right').find('.video-popup').html();
	    //  $('#popup-content').html(content);
      //  
      //  // on HTML mouseover, pause the slideshow.
      //  $('html').mouseover(function(event) {
  	  //    Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": 'homepage_rotator-block_1' });
  	  //    Drupal.viewsSlideshow.action({ "action": 'pause', "slideshowID": 'news_rotator-block_1' });	      
  	  //  });
  	  //  
			//	// hide all popups when clicking away or clicking on the close button.
	    //  $('.close-btn a').click(function() {
	    //    $('#popup-content').remove();
	    //    $('.liveoffice-js-overlay').remove();
	    //    
	    //    // Play slideshow again.
      //    $('html').mouseover(function(event) {
    	//      Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": 'homepage_rotator-block_1' });
    	//      Drupal.viewsSlideshow.action({ "action": 'play', "slideshowID": 'news_rotator-block_1' });	      
    	//    });
  	  //    
	    //    return false;        
	    //  });     
	    //  return false;  
	    //});
	
	

// Video: first node
			//$('div.attachment div.view-resources-video-page .demo-video').hide();
	    //$('div.attachment .view-resources-video-page .views-field a.popup') .click(function() {
	    //  //uniqueClass = Math.round(new Date().getTime() / 1000);
	    //  //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
	    //  $('#page').append('<div class="liveoffice-js-overlay"></div>');
			//	$('#page').append('<div id="popup-content"></div>');
	    //  var content = $(this).parents('.view-content').find('.demo-video').html();
	    //  $('#popup-content').html(content);
      //
			//	// hide all popups when clicking away or clicking on the close button.
	    //  $('.close-btn a').click(function() {
	    //    $('#popup-content').remove();
	    //    $('.liveoffice-js-overlay').remove();				
	    //    return false;        
	    //  });
      //
	    //  return false;  
	    //});

// Video: Accordion
			//$('div.view-resources-video-page .video-list-row .demo-video').hide();
	    //$('div.view-resources-video-page .video-list-row .views-field a.popup') .click(function() {
	    //  //uniqueClass = Math.round(new Date().getTime() / 1000);
	    //  //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
	    //  $('#page').append('<div class="liveoffice-js-overlay"></div>');
			//	$('#page').append('<div id="popup-content"></div>');
	    //  var content = $(this).parents('.video-list-row').find('.demo-video').html();
	    //  $('#popup-content').html(content);
      //
			//	// hide all popups when clicking away or clicking on the close button.
	    //  $('.close-btn a').click(function() {
	    //    $('#popup-content').remove();
	    //    $('.liveoffice-js-overlay').remove();
	    //    return false;        
	    //  });
      //
	    //  return false;  
	    //});


// Webinars: first node
			$('div.attachment div.view-resources-webinar-page .demo-video').hide();
	    $('div.attachment div.view-resources-webinar-page .views-field a.webinar-popup') .click(function() {
	      //uniqueClass = Math.round(new Date().getTime() / 1000);
	      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
	      $('#page').append('<div class="liveoffice-js-overlay"></div>');
				$('#page').append('<div id="popup-content" class="webinar-popup-content"></div>');
	      var content = $(this).parents('.view-content').find('.demo-video').html();
	      $('#popup-content').html(content);

				// hide all popups when clicking away or clicking on the close button.
	      $('.close-btn a').click(function() {
	        $('#popup-content').remove();
	        $('.liveoffice-js-overlay').remove();
	        return false;        
	      });

	      window.location = '#inner-page';
				return false;  
	    });



			// Webinar: Accordion
						$('div.view-resources-webinar-page .webinar-list-row .demo-video').hide();
				    $('div.view-resources-webinar-page .webinar-list-row a.webinar-popup') .click(function() {
				      //uniqueClass = Math.round(new Date().getTime() / 1000);
				      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
				      $('#page').append('<div class="liveoffice-js-overlay"></div>');
							$('#page').append('<div id="popup-content" class="webinar-popup-content"></div>');
				      var content = $(this).parents('.webinar-list-row').find('.demo-video').html();
				      $('#popup-content').html(content);

							// hide all popups when clicking away or clicking on the close button.
				      $('.close-btn a').click(function() {
				        $('#popup-content').remove();
				        $('.liveoffice-js-overlay').remove();
				        return false;        
				      });

	      			window.location = '#inner-page';
				      return false;  
				    });


						// Whitepapers: first node
									$('div.attachment div.view-resources-whitepaper-page .resource-form').hide();
							    $('div.attachment div.view-resources-whitepaper-page .views-field a.form-popup') .click(function() {
							      //uniqueClass = Math.round(new Date().getTime() / 1000);
							      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
							      $('#page').append('<div class="liveoffice-js-overlay"></div>');
										$('#page').append('<div id="popup-content" class="form-popup-content"></div>');
							      var content = $(this).parents('.view-content').find('.resource-form').html();
							      $('#popup-content').html(content);

										// hide all popups when clicking away or clicking on the close button.
							      $('.close-btn a').click(function() {
							        $('#popup-content').remove();
							        $('.liveoffice-js-overlay').remove();
							        return false;        
							      });

							      window.location = '#inner-page';
										return false;  
							    });



									// Whitepapers: Accordion
												$('div.ui-accordion-content .resource-form').hide();
										    $('div.ui-accordion-content .views-field a.form-popup') .click(function() {
										      //uniqueClass = Math.round(new Date().getTime() / 1000);
										      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
										      $('#page').append('<div class="liveoffice-js-overlay"></div>');
													$('#page').append('<div id="popup-content" class="form-popup-content"></div>');
										      var content = $(this).parents('.ui-accordion-content').find('.resource-form').html();
										      $('#popup-content').html(content);

													// hide all popups when clicking away or clicking on the close button.
										      $('.close-btn a').click(function() {
										        $('#popup-content').remove();
										        $('.liveoffice-js-overlay').remove();
										        return false;        
										      });

							      			window.location = '#inner-page';
										      return false;  
										    });


												// Industry Research: first node
															$('div.attachment div.view-resources-industry-research-page .resource-form').hide();
													    $('div.attachment div.view-resources-industry-research-page .views-field a.form-popup') .click(function() {
													      //uniqueClass = Math.round(new Date().getTime() / 1000);
													      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
													      $('#page').append('<div class="liveoffice-js-overlay"></div>');
																$('#page').append('<div id="popup-content" class="form-popup-content"></div>');
													      var content = $(this).parents('.view-content').find('.resource-form').html();
													      $('#popup-content').html(content);

																// hide all popups when clicking away or clicking on the close button.
													      $('.close-btn a').click(function() {
													        $('#popup-content').remove();
													        $('.liveoffice-js-overlay').remove();
													        return false;        
													      });

													      window.location = '#inner-page';
																return false;  
													    });
													
													
															// Data Sheet: first node
																		$('div.attachment div.view-resources-data-sheet-page .resource-form').hide();
																    $('div.attachment div.view-resources-data-sheet-page .views-field a.form-popup') .click(function() {
																      //uniqueClass = Math.round(new Date().getTime() / 1000);
																      //$(this).parent().parent().parent().addClass('activepopup ' + uniqueClass);
																      $('#page').append('<div class="liveoffice-js-overlay"></div>');
																			$('#page').append('<div id="popup-content" class="form-popup-content"></div>');
																      var content = $(this).parents('.view-content').find('.resource-form').html();
																      $('#popup-content').html(content);

																			// hide all popups when clicking away or clicking on the close button.
																      $('.close-btn a').click(function() {
																        $('#popup-content').remove();
																        $('.liveoffice-js-overlay').remove();
																        return false;        
																      });

																      window.location = '#inner-page';
																			return false;  
																    });


				// Popup Display for the Management Team Page
				$('body.page-node-293 .views-field-entity-id-8').hide();
				$('body.page-node-293 a.popup') .click(function() {
					$('#page').append('<div class="liveoffice-js-overlay"></div>');
					$('#page').append('<div id="popup-content"></div>');
						var content = $(this).parents('.views-row').find('.views-field-entity-id-8').html();
						  $('#popup-content').html(content);
						
							// hide all popups when clicking away or clicking on the close button.
						  $('.close-btn a').click(function() {
						  $('#popup-content').remove();
						  $('.liveoffice-js-overlay').remove();
						  return false;        
						});
	      		
						window.location = '#inner-page';
						return false;  
					});

					// Popup Display for the Blog Subscribe Block
					$('#block-block-41').hide();
					$('.mid-1081 a') .click(function() {
						$('#page').append('<div class="liveoffice-js-overlay"></div>');
						$('#page').append('<div id="popup-content" class="blog-subscribe"></div>');
							var content = $(this).parents('.region-sidebar-second').find('#block-block-41').html();
							  $('#popup-content').html(content);

								// hide all popups when clicking away or clicking on the close button.
							  $('.close-btn a').click(function() {
							  $('#popup-content').remove();
							  $('.liveoffice-js-overlay').remove();
							  return false;        
							});

							window.location = '#inner-page';
							return false;  
						});


						// Popup Display for the Blog Subscribe Block
						$('.mid-1178 a') .click(function() {
							$('#page').append('<div class="liveoffice-js-overlay"></div>');
							$('#page').append('<div id="popup-content" class="blog-subscribe"></div>');
								var content = $(this).parents('.region-sidebar-second').find('#block-block-41').html();
								  $('#popup-content').html(content);

									// hide all popups when clicking away or clicking on the close button.
								  $('.close-btn a').click(function() {
								  $('#popup-content').remove();
								  $('.liveoffice-js-overlay').remove();
								  return false;        
								});

								window.location = '#inner-page';
								return false;  
							});
							
							// Popup Display for the ThankYou Subscribe Block
							// $('#block-block-42').hide();
							$('.mid-1179 a') .click(function() {
								$('#page').append('<div class="liveoffice-js-overlay"></div>');
								$('#page').append('<div id="popup-content" class="thankyou-subscribe"></div>');
									var content = $(this).parents('.region-sidebar-second').find('#block-block-42').html();
									  $('#popup-content').html(content);

										// hide all popups when clicking away or clicking on the close button.
									  $('.close-btn a').click(function() {
									  $('#popup-content').remove();
									  $('.liveoffice-js-overlay').remove();
									  return false;        
									});

									window.location = '#inner-page';
									return false;  
								});


							// Sets the client login link inactive
								$('li.menu-994.menu-path-front a:first').click(function() {
								   return false;
								});


						// TABS on Page Content Type
						
						$('#tab-wrapper ul.htabs li.t1').addClass('tab-current');
				
					 //if this is not the first tab, hide it
					 $("#tab-wrapper .tab:not(:first)").hide();
					
					 //to fix u know who
					 $("#tab-wrapper .tab:first").show();
					
					 //when we click one of the tabs
					 $("#tab-wrapper .htabs a").click(function(){
					 //get the ID of the element we need to show
					 		stringref = jQuery(this).attr("href").split('#')[1];
					 //hide the tabs that doesn't match the ID
					 		$('#tab-wrapper .tab:not(#'+stringref+')').hide();
					 //fix
					 		if (jQuery.browser.msie && jQuery.browser.version.substr(0,3) == "6.0") {
					 			jQuery('#tab-wrapper .tab#' + stringref).show();
					 			}
					 		else
					 //display our tab fading it in
					 $('#tab-wrapper .tab#' + stringref).fadeIn();
						$('#tab-wrapper ul.htabs li').removeClass('tab-current');
							$(this).parents('#tab-wrapper ul.htabs li').addClass('tab-current');
					 //stay with me
					 return false;
					 });



  });  
})(jQuery);

