 $(document).ready(function(){
    $("#tabs1").tabs();
  });

jQuery(function( $ ){
	
   $('#hot_topics').serialScroll({
           items:'.contentRotator',
           axis:'x',
           start:0,
           duration:700,
           queue:false,
           interval:13000,
           force:true,
           step:1,
           prev:"#hot_topics_prev a",
           next:"#hot_topics_next a",
           navigation:"#hot_topics_jump li a",
           onBefore:function( e, elem, $pane, $items, pos ){
			/**
			 * 'this' is the triggered element 
			 * e is the event object
			 * elem is the element we'll be scrolling to
			 * $pane is the element being scrolled
			 * $items is the items collection at this moment
			 * pos is the position of elem in the collection
			 * if it returns false, the event will be ignored
			 */
			 //those arguments with a $ are jqueryfied, elem isn't.
			e.preventDefault();
			if( this.blur )
				this.blur();
			$('#hot_topics_jump li').removeClass('selected');
//							alert('pos:'+pos);
			$('#hot_topics_jump li:eq('+pos+')').addClass('selected');
		}
   });
   $('#hot_topics_jump li:eq(0)').addClass('selected');
		
	$('#slideshow').serialScroll({
 		items:'li',
 		prev:'#partners a.prev',
 		next:'#partners a.next',
 		// offset:-50, when scrolling to photo, stop 100 before reaching it (from the left)
 		start:0, //as we are centering it, start at the 3rd
 		duration:1200,
 		step:6,
 		force:true,
 		stop:true,
 		lock:true,//setting to true prevents the queueing of animation
 		cycle:false, // set to false to prevent a circular strip
 		exclude:5, // set to 5 to stop scrolling at the 5th last record.
 				// IMPORTANT! this assumes you have 6 items to display.
 				// Change the value of exclude may depend on a combination of 
 				// # of images and number to display at one time.
 		jump: false //click on the images to scroll to them
	});
});         

    $(document).ready(function(){
    $("#blogfilter").change(function () {
      $(".blogitem").parent(".mkt_item").hide(); 
      var selectedVal = $('#blogfilter').val();
      if( selectedVal == "All" ) {
        //$(".blogitem").show();
        // Loop over each .blogitem.
            $( ".blogitem" ).each(
            // For .mkt_itemBlogs, run this code. The "indIndex" is the
            // loop iteration index on the current element.
            function( intIndex ){
                // Bind the onclick event to simply alert the
                // iteration index value.
	            /* Apply record limit. */
                if (intIndex < 4) {
                    $( this ).parent(".mkt_item").show() ;
                }            
            }            
            );
      }
      else {
        var myBlogItems = $(".blogitem").filter( function(i) {
            var thisItemClass =  $(this).attr("class");
            return (thisItemClass.match(selectedVal) != null);
        });
        
        myBlogItems.each(function(index) {
	            /* Apply record limit. */
                if (index < 4) {
                    $( this ).parent(".mkt_item").show() ;
                }                  		
        }); 
      }
    });
  });

     $(document).ready(function(){
    if($(".submenu_selected") && $(".submenu_selected").attr("id")) {
     var defaultMenuArray = $(".submenu_selected").attr("id").split('_');
     if (defaultMenuArray != null) {
          var defaultedId = defaultMenuArray[defaultMenuArray.length-1];         
         if (defaultedId == 'Blogs') {
            // Loop over each .blogitem.
            $(".blogitem").parent(".mkt_item").hide();
            $( ".blogitem" ).each(
                // For .mkt_itemBlogs, run this code. The "indIndex" is the
                // loop iteration index on the current element.
                function( intIndex ){
                // Bind the onclick event to simply alert the
                // iteration index value.
	            /* Apply record limit. */
                if (intIndex < 4) {
                    $( this ).parent(".mkt_item").show() ;
                }            
                }            
            );
              $(".blog_view_more").show();         
          } else {
	          /*limit every collateral to 4 */
			  var selectedItem = ".mktitem_"+defaultedId;
	            $(selectedItem).hide();
	            $(selectedItem).each(
	                // For .mkt_itemBlogs, run this code. The "indIndex" is the
	                // loop iteration index on the current element.
	                function( intIndex ){
	                // Bind the onclick event to simply alert the
	                // iteration index value.
	                if (intIndex < 4) {
	                    $( this ).show() ;
	                }            
	                }            
	            );
          }

      }
    }
  });

     $(document).ready(function(){
     $(".mkt_submenu").click(function() {
      $(".mkt_submenu").removeClass("submenu_selected");
      $(this).addClass("submenu_selected");
      /* extract collateral type from id */	  
	  var selectedArray = $(this).attr("id").split('_');
	  var selectedId = selectedArray[selectedArray.length-1];		 
	  var selectedItem = ".mktitem_"+selectedId;
      $(".mkt_item").hide();
      $(".blogFilterPicklist").hide();
      $("#rss_feed").hide();    
      $(".blog_view_more").hide();    
      
      /* apply 4 record limit */
      /*      $(selectedItem).show();     */
      
      if (selectedId == 'Blogs') {
	      $("#rss_feed").show();    
	      $(".blog_view_more").show();    
	      $(".blogFilterPicklist").show();    
	      $("#blogfilter option[selected='selected']").removeAttr("selected");
		  $("#blogfilter option[value='All']").attr("selected","selected");    
      } 

    /*limit every callateral to 4 */
    $(selectedItem).each(
        // For .mkt_itemBlogs, run this code. The "indIndex" is the
        // loop iteration index on the current element.
        function( intIndex ){
        // Bind the onclick event to simply alert the
        // iteration index value.
        /* Apply record limit. */
        if (intIndex < 4) {
            $( this ).show() ;
        }            
        }            
    );

     });
  });
 		
	$(document).ready(function(){
		$(".solutionpicker_link").click(function () {
			// track the current link
			// $(".solution-picker-item").removeClass("solution-picker-item-current");
			var open_this1 = "#solutionpicker_"+$(this).attr("id");
			$(open_this1).parent().children(".solutionpicker").children(".solution-picker-item").removeClass("solution-picker-item-current");
			$(this).parent().addClass("solution-picker-item-current");
			
			var open_this = "#solution_"+$(this).attr("id");
			/*      $(".solution ").hide();*/
			// set the current to display_none based on it's current display_block state
			$(open_this).parent().children(".solution").removeClass("display_block");
			$(open_this).parent().children(".solution").addClass("display_none");
			// set the currently clicked to display_block
			$(open_this).removeClass("display_none");
			$(open_this).addClass("display_block");
			
			// determine state of arrows
			//if ( $(open_this).next().hasClass("solution") ){}         
			checkArrowState($(open_this).attr("id"));      
		
		});
	
	});

checkArrowState = function(this_object) {
		//alert('yoyo' + this_object);

		var currentSolutionArray = this_object.split('_');
		var currentSolutionBase = currentSolutionArray[currentSolutionArray.length-2];		 
        // construct next node in, for example, {'solution', '_', 'prev', '_', 'Capabilities'}

		var nextNode = "#solution_next_"+currentSolutionBase;
		var prevNode = "#solution_prev_"+currentSolutionBase;
		var testnext = 	$("#"+this_object);

		if ( $("#"+this_object).next().hasClass("solution") ){
			$(nextNode).show();
		} else {
			$(nextNode).hide();
		}         
		if ( $("#"+this_object).prev().hasClass("solution") ){
			$(prevNode).show();

			// This is a hack because under IE6, the left arrow doesn't appear.   (Bug 726)
			$(prevNode).children("img").css("width", "4px");
			$(prevNode).children("img").css("height", "7px");
		} else {
			$(prevNode).hide();
		}         
};

   $(document).ready(function(){
	    $(".solutionpicker_next").click(function () {
	      var currentSolutionArray = $(this).attr("id").split('_');
		  var currentSolutionBase = currentSolutionArray[currentSolutionArray.length-1];		 
		  var currentSolution = "#"+currentSolutionBase;		 
		  // Grab the first child of the selected SolutionType
          var $curr = $(currentSolution).children(".display_block").eq(0);
//          alert($curr.attr("id"));
          
 	      /* Make sure there is a next before going next. */
          if ( $($curr).next().hasClass("solution") ){         
	          $($curr).removeClass("display_block");
		      $($curr).addClass("display_none");
	          $curr = $curr.next();
           	  /* find the item in the list of numbers and highlight it */
			  var selectedArray = $curr.attr("id").split('_');
			  var selectedId = selectedArray[selectedArray.length-1];		 
			  var selectedItemBase = currentSolutionBase+"_"+selectedId;
			  var selectedItem = "#"+selectedItemBase;
			  
	          var open_this1 = "#solutionpicker_"+selectedItemBase;
		      $(open_this1).parent().children(".solutionpicker").children(".solution-picker-item").removeClass("solution-picker-item-current");

		      $(selectedItem).parent().addClass("solution-picker-item-current");

	          $($curr).removeClass("display_none");
	          $($curr).addClass("display_block");

	  			// determine state of arrows
				checkArrowState($curr.attr("id"));      

          }
	    });    
  });

   $(document).ready(function(){
	    $(".solutionpicker_prev").click(function () {
	      // Split the id string into an array
	      var currentSolutionArray = $(this).attr("id").split('_');
	      // we want the last node in, for example, {'solution', '_', 'prev', '_', 'Capabilities'}
		  var currentSolutionBase = currentSolutionArray[currentSolutionArray.length-1];		 		  
		  var currentSolution = "#"+currentSolutionBase;		 
		  // Grab the first child of the selected SolutionType container with a class '.display_block'
          var $curr = $(currentSolution).children(".display_block").eq(0);
//          alert($curr.attr("id"));
          
 	      /* Make sure there is a prev before going prev. */
          if ( $($curr).prev().hasClass("solution") ){         
	          $($curr).removeClass("display_block");
		      $($curr).addClass("display_none");
	          $curr = $curr.prev();
           	  /* find the item in the list of numbers and highlight it */
			  var selectedArray = $curr.attr("id").split('_');
			  var selectedId = selectedArray[selectedArray.length-1];		 
			  var selectedItemBase = currentSolutionBase+"_"+selectedId;
			  var selectedItem = "#"+selectedItemBase;
			  
	          var open_this1 = "#solutionpicker_"+selectedItemBase;
		      $(open_this1).parent().children(".solutionpicker").children(".solution-picker-item").removeClass("solution-picker-item-current");

		      $(selectedItem).parent().addClass("solution-picker-item-current");

	          $($curr).removeClass("display_none");
	          $($curr).addClass("display_block");

	  			// determine state of arrows
				checkArrowState($curr.attr("id"));      

          }
	    });    
  });
    
  // clear title attribute on all hyperlinks to avoid displaying tooltips
   $(document).ready(function() {
		$("a[title]").each(function() {
        	this.title = null;
    	});
  });