/* 
* Skeleton V1.0.2
* Copyright 2011, Dave Gamache
* www.getskeleton.com
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
* 5/20/2011
*/	
	

$(document).ready(function() {
if ($('#home').length) {

  var slideShowDelay = 10000, // fallback
  slideTimes = {
    1 : 25000,
    2 : 10000,
    3 : 10000,
    4 : 10000
  };
   $('#carousel').anythingSlider({
  // Appearance
  theme               : "default", // Theme name
  expand              : false,     // If true, the entire slider will expand to fit the parent element
  resizeContents      : true,      // If true, solitary images/objects in the panel will expand to fit the viewport
  showMultiple        : false,     // Set this value to a number and it will show that many slides at once
  easing              : "linear",   // Anything other than "linear" or "swing" requires the easing plugin or jQuery UI

  buildArrows         : false,      // If true, builds the forwards and backwards buttons
  buildNavigation     : true,      // If true, builds a list of anchor links to link to each panel
  buildStartStop      : false,      // If true, builds the start/stop button

  appendForwardTo     : null,      // Append forward arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
  appendBackTo        : null,      // Append back arrow to a HTML element (jQuery Object, selector or HTMLNode), if not null
  appendControlsTo    : $(".carousel-menu"),      // Append controls (navigation + start-stop) to a HTML element (jQuery Object, selector or HTMLNode), if not null
  appendNavigationTo  : null,      // Append navigation buttons to a HTML element (jQuery Object, selector or HTMLNode), if not null
  appendStartStopTo   : null,      // Append start-stop button to a HTML element (jQuery Object, selector or HTMLNode), if not null

  toggleArrows        : false,     // If true, side navigation arrows will slide out on hovering & hide @ other times
  toggleControls      : false,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times

  startText           : "Start",   // Start button text
  stopText            : "Stop",    // Stop button text
  forwardText         : "&raquo;", // Link text used to move the slider forward (hidden by CSS, replaced with arrow image)
  backText            : "&laquo;", // Link text used to move the slider back (hidden by CSS, replace with arrow image)
  tooltipClass        : "tooltip", // Class added to navigation & start/stop button (text copied to title if it is hidden by a negative text indent)

  // Function
  enableArrows        : false,      // if false, arrows will be visible, but not clickable.
  enableNavigation    : false,      // if false, navigation links will still be visible, but not clickable.
  enableStartStop     : false,      // if false, the play/stop button will still be visible, but not clickable. Previously "enablePlay"
  enableKeyboard      : false,      // if false, keyboard arrow keys will not work for this slider.

  // Navigation
  startPanel          : 1,         // This sets the initial panel
  changeBy            : 1,         // Amount to go forward or back when changing panels.
  hashTags            : true,      // Should links change the hashtag in the URL?
  infiniteSlides      : false,      // if false, the slider will not wrap & not clone any panels
  navigationFormatter : function(index, slide){ // Format navigation labels with text
					return '<span>' + ['Who is Capario?', 'The Capario Portal', 'Easy Enrollment Tool', 'Vendor Program'][index - 1] + '</span>';
				},
  navigationSize      : false,     // Set this to the maximum number of visible navigation tabs; false to disable

  // Slideshow options
  autoPlay            : true,     // If true, the slideshow will start running; replaces "startStopped" option
  autoPlayLocked      : false,     // If true, user changing slides will not stop the slideshow
  autoPlayDelayed     : true,     // If true, starting a slideshow will delay advancing slides; if false, the slider will immediately advance to the next slide when slideshow starts
  pauseOnHover        : true,      // If true & the slideshow is active, the slideshow will pause on hover
  stopAtEnd           : false,     // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false.
  playRtl             : false,     // If true, the slideshow will move right-to-left

  // Times
  delay               : slideTimes[1],      // How long between slideshow transitions in AutoPlay mode (in milliseconds)
  resumeDelay         : 8000,     // Resume slideshow after user interaction, only if autoplayLocked is true (in milliseconds).
  animationTime       : 0,       // How long the slideshow transition takes (in milliseconds)

  // Callbacks
  onBeforeInitialize  : function(e, slider) {}, // Callback before the plugin initializes
  onInitialized       : function(e, slider) {slider.pause}, // Callback when the plugin finished initializing
  onShowStart         : function(e, slider) {}, // Callback on slideshow start
  onShowStop          : function(e, slider) {}, // Callback after slideshow stops
  onShowPause         : function(e, slider) {}, // Callback when slideshow pauses
  onShowUnpause       : function(e, slider) {}, // Callback when slideshow unpauses - may not trigger properly if user clicks on any controls
  onSlideInit         : function(e, slider) {}, // Callback when slide initiates, before control animation
  onSlideBegin        : function(e, slider) {}, // Callback before slide animates
  onSlideComplete     : function(slider) {
	  					slider.clearTimer(true); // stop slideshow
   					 	// Change delay time based on saved timings
    					if (slideTimes.hasOwnProperty(slider.currentPage)) {
      					  slider.options.delay = slideTimes[slider.currentPage];
    					} else {
      					  slider.options.delay = slideShowDelay;
    					}
    					slider.startStop(slider.playing, true); // restart slideshow
 						slider.navWindow( slider.currentPage );
  						
    },    // Callback when slide completes; this is the only callback without an event "e" variable

  // Interactivity
  clickForwardArrow   : "click",         // Event used to activate forward arrow functionality (e.g. add jQuery mobile's "swiperight")
  clickBackArrow      : "click",         // Event used to activate back arrow functionality (e.g. add jQuery mobile's "swipeleft")
  clickControls       : "click focusin", // Events used to activate navigation control functionality
  clickSlideshow      : "click",         // Event used to activate slideshow play/stop button

  // Video
  resumeOnVideoEnd    : true,      // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete
  addWmodeToObject    : "opaque",  // If your slider has an embedded object, the script will automatically add a wmode parameter with this setting
  isVideoPlaying      : function(base){ return false; } // return true if video is playing or false if not - used by video extension
});
   
	$(".panel1").click(function(){$('#carousel').anythingSlider(1);$('.cur').removeClass('cur');$(this).addClass('cur');});
	$(".panel2").click(function(){$('#carousel').anythingSlider(2);$('.cur').removeClass('cur');$(this).addClass('cur');});
	$(".panel3").click(function(){$('#carousel').anythingSlider(3);$('.cur').removeClass('cur');$(this).addClass('cur');});
	$(".panel4").click(function(){$('#carousel').anythingSlider(4);$('.cur').removeClass('cur');$(this).addClass('cur');});
	
	/*$('#testimonials').anythingSlider({
		startPanel          : randomSlide,
		autoPlay            : true
	});*/

	$('#testimonials').easySlider({
		controlsShow:	false,
		vertical:		false,
		speed: 			800,
		auto:			false,
		continuous:		true,
		randomize:		true,
		controlsShow:	true,
		controlsBefore:	'<div class="controls">',
		controlsAfter:	'</div>'
	});
	
	$(".headline").easySlider({
		prevId: 		'prevBtn',
		prevText: 		'Previous',
		nextId: 		'nextBtn',	
		nextText: 		'Next',
		controlsShow:	true,
		controlsBefore:	'<div class="controls">',
		controlsAfter:	'</div>',	
		controlsFade:	false,			
		vertical:		false,
		speed: 			800,
		auto:			false,
		pause:			2000,
		continuous:		true, 
		numeric: 		false,
		numericId: 		'controls'
	});
} else if ($('#contact').length) {
  jQuery.extend(jQuery.validator.messages, { 
      required: "",
      email: "",
      digits: ""
  });
  
  $(function() {
      $(".frm_main").validate();
  });
  } else if ($('#demo').length) {
	jQuery.extend(jQuery.validator.messages, { 
	  required: "",
	  email: "",
	  digits: ""
	});

	$(function() {
		$(".demoForm").validate();
	});
  } else {
	 $(".content").hide();
  	//toggle the componenet with class msg_body
 	 $(".head").click(function() {
		$(this).slideto({highlight:false});
   		$(this).next(".content").slideToggle(500);
		$(this).toggleClass('head-open');
 	});
}
	
	$(function(){

	  // The height of the content block when it's not expanded
	  var adjustheight = 90;
	  // The "more" link text
	  var moreText = "+  More";
	  // The "less" link text
	  var lessText = "- Less";
	  
	  // Sets the .more-block div to the specified height and hides any content that overflows
	  $(".partner-block-long .more-block").css('height', adjustheight).css('overflow', 'hidden');
	  
	  $(".partner-block-long").append('<p class="more-link"><span class="continued">[&hellip;]</span> <a href="#" class="adjust"></a></p>');

	  $("a.adjust").text(moreText);

	  $(".adjust").toggle(function() {
		$(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible');
		// Hide the [...] when expanded
		$(this).parents("div:first").find(".continued").css('display', 'none');
		$(this).text(lessText);
	  }, function() {
		$(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden');
		$(this).parents("div:first").find(".continued").css('display', 'inline');
		$(this).text(moreText);
	  });
	});
		
	/* Tabs Activiation
	================================================== */
	var tabs = $('ul.tabs');
	
	tabs.each(function(i) {
		//Get all tabs
		var tab = $(this).find('> li > a');
		tab.click(function(e) {
			
			//Get Location of tab's content
			var contentLocation = $(this).attr('href') + "Tab";
			
			//Let go if not a hashed one
			if(contentLocation.charAt(0)=="#") {
			
				e.preventDefault();
			
				//Make Tab Active
				tab.removeClass('active');
				$(this).addClass('active');
				
				//Show Tab Content & add active class
				$(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
				
			} 
		});
	}); 
	$('.bubbleInfo').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger', this);
            var info = $('.popup', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        bottom: -20,
                        left: -33,
                        display: 'block'
                    }).animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        bottom: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
});
