// stick everyting in this doc ready so it doesn't conflict with prototype.
// see dettials of other options here -  http://docs.jquery.com/Using_jQuery_with_Other_Libraries


jQuery(document).ready(function($){





// Requires jquery.marquee.js

$(document).ready(function() {
// Standard implementation	$('marquee').marquee(optionalClass);
$('marquee').marquee('pointer').mouseover(function () {
            $(this).trigger('stop');
        }).mouseout(function () {
            $(this).trigger('start');
        }).mousemove(function (event) {
            if ($(this).data('drag') == true) {
                this.scrollLeft = $(this).data('scrollX') + ($(this).data('x') - event.clientX);
            }
        }).mousedown(function (event) {
            $(this).data('drag', true).data('x', event.clientX).data('scrollX', this.scrollLeft);
        }).mouseup(function () {
            $(this).data('drag', false);
        });

});


// CYCLE.ALL calls below

$(document).ready(function() {
	$('.slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom
		speed:  3000 ,  //  time each trans takes
		pause:  0 , // 1 is on, pasues on hover
		random:  1 ,  // 1 is on
		timeout: 1000 ,  // time before the start of each, use 0 for click to next
		cleartype:  1 // helps things in IE 6
		// next:   '#s1',  // same div name for click image, or '#next2' for text link
		// prev:   '#prev2' , // goes with text link from above
		// pager:  '#nav',		// add below to the top, where 'slideshow' is
				// .before('<div id="nav">') 
				//.cycle({ 
	});
});




$(document).ready(function() {
	$('.testimonial').cycle({
		fx: 'scrollUp', // choose your transition type, ex: blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom
		speed:  2000 ,  //  time each trans takes
		pause:  1 , // 1 is on, pasues on hover
		random:  1 ,  // 1 is on
		timeout: 0 ,  // time before the start of each, use 0 for click to next
		cleartype:  1 // helps things in IE 6
		// next:   '#s1',  // same div name for click image, or '#next2' for text link
		// prev:   '#prev2' , // goes with text link from above
		// pager:  '#nav',		// add below to the top, where 'slideshow' is
				// .before('<div id="nav">') 
				//.cycle({ 
	});
});




$(document).ready(function() {
	$('.cases').cycle({
		fx: 'scrollUp', // choose your transition type, ex: blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom
		speed:  2000 ,  //  time each trans takes
		pause:  1 , // 1 is on, pasues on hover
		random:  1 ,  // 1 is on
		timeout: 25000 ,  // time before the start of each, use 0 for click to next
		cleartype:  1 // helps things in IE 6
		// next:   '#s1',  // same div name for click image, or '#next2' for text link
		// prev:   '#prev2' , // goes with text link from above
		// pager:  '#nav',		// add below to the top, where 'slideshow' is
				// .before('<div id="nav">') 
				//.cycle({ 
	});
});

$(document).ready(function() {
	$('.cases-still').cycle({
		fx: 'scrollUp', // choose your transition type, ex: blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom
		speed:  2000 ,  //  time each trans takes
		pause:  1 , // 1 is on, pasues on hover
		random:  1 ,  // 1 is on
		timeout: 0 ,  // time before the start of each, use 0 for click to next
		cleartype:  1 // helps things in IE 6
		// next:   '#s1',  // same div name for click image, or '#next2' for text link
		// prev:   '#prev2' , // goes with text link from above
		// pager:  '#nav',		// add below to the top, where 'slideshow' is
				// .before('<div id="nav">') 
				//.cycle({ 
	});
});

$(document).ready(function() {
	$('.side-testimonial').cycle({
		fx: 'scrollUp', 
		speed:  2000 ,  //  time each trans takes
		pause:  1 , // 1 is on, pasues on hover
		random:  1 ,  // 1 is on
		timeout: 25000 ,  // time before the start of each, use 0 for click to next
		cleartype:  1 // helps things in IE 6
	});
});

/* NOTE FOR IE (6) USE - If your content is absolutely positioned then you need to give the container and slides explicit size. - also use cleartype: 1 */

/* OPTIONS BELOW
// override these globally if you like (they are all optional) 
$.fn.cycle.defaults = { 
    fx:           'fade', // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle) 
							//choose your transition type, ex: blindX, blindY, blindZ, cover, curtainX, curtainY, fade, fadeZoom, growX, growY, scrollUp, scrollDown, scrollLeft, scrollRight, scrollHorz, scrollVert, shuffle, slideX, slideY, toss, turnUp, turnDown, turnLeft, turnRight, uncover, wipe, zoom
							
    timeout:       4000,  // milliseconds between slide transitions (0 to disable auto advance) 
    timeoutFn:     null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag) 
    continuous:    0,     // true to start next transition immediately after current one completes 
    speed:         1000,  // speed of the transition (any valid fx speed value) 
    speedIn:       null,  // speed of the 'in' transition 
    speedOut:      null,  // speed of the 'out' transition 
    next:          null,  // selector for element to use as click trigger for next slide 
    prev:          null,  // selector for element to use as click trigger for previous slide 
    prevNextClick: null,  // callback fn for prev/next clicks:  function(isNext, zeroBasedSlideIndex, slideElement) 
    pager:         null,  // selector for element to use as pager container 
    pagerClick:    null,  // callback fn for pager clicks:  function(zeroBasedSlideIndex, slideElement) 
    pagerEvent:   'click', // name of event which drives the pager navigation 
    pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement) 
    before:        null,  // transition callback (scope set to element to be shown):     function(currSlideElement, nextSlideElement, options, forwardFlag) 
    after:         null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag) 
    end:           null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options) 
    easing:        null,  // easing method for both in and out transitions 
    easeIn:        null,  // easing for "in" transition 
    easeOut:       null,  // easing for "out" transition 
    shuffle:       null,  // coords for shuffle animation, ex: { top:15, left: 200 } 
    animIn:        null,  // properties that define how the slide animates in 
    animOut:       null,  // properties that define how the slide animates out 
    cssBefore:     null,  // properties that define the initial state of the slide before transitioning in 
    cssAfter:      null,  // properties that defined the state of the slide after transitioning out 
    fxFn:          null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag) 
    height:       'auto', // container height 
    startingSlide: 0,     // zero-based index of the first slide to be displayed 
    sync:          1,     // true if in/out transitions should occur simultaneously 
    random:        0,     // true for random, false for sequence (not applicable to shuffle fx) 
    fit:           0,     // force slides to fit container 
    containerResize: 1,   // resize container to fit largest slide 
    pause:         0,     // true to enable "pause on hover" 
    pauseOnPagerHover: 0, // true to pause when hovering over pager link 
    autostop:      0,     // true to end slideshow after X transitions (where X == slide count) 
    autostopCount: 0,     // number of transitions (optionally used with autostop to define X) 
    delay:         0,     // additional delay (in ms) for first transition (hint: can be negative) 
    slideExpr:     null,  // expression for selecting slides (if something other than all children is required) 
    cleartype:     !$.support.opacity,  // true if clearType corrections should be applied (for IE) 
    cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides) 
    nowrap:        0,     // true to prevent slideshow from wrapping 
    fastOnEvent:   0,     // force fast transitions when triggered manually (via pager or prev/next); value == time in ms 
    randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random 
    rev:           0,     // causes animations to transition in reverse 
    manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored 
    requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded 
    requeueTimeout: 250   // ms delay for requeue 
};
*/


// show-hide scripts

// For pricing show/hide...

      $(document).ready(function() {
        $('span.prices').hide();
        $('a.price-swap').click(function() {		  
//		  $('span.prices').slideToggle('normal');  // had to put this in the if because it didn't read visibility change fast enough? wasn't changing text, could have tried changing a class with it to read it that way, as below.
		  
		  if ($('span.prices').is(":hidden")) {
			$('span.prices').slideDown('normal');
			$('a.price-swap> span.swap-text').html("hide");
		  }
		  else {
			$('span.prices').slideUp('normal');
		  	$('a.price-swap> span.swap-text').html("show");
		  }	

        });
      });



		$(document).ready(function() {
//        $('div.slider> div').hide();   /* turned off the HIDE to i could control manually for opening different caese studies */
        $('div.slider> h2').click(function() {
          $(this).next('div').slideToggle('normal')
          .siblings('div:visible').slideUp('normal');
        });
      });


// fancier slide up

      $(document).ready(function() {
        $('div.slider-fancy> div').hide();  
        $('div.slider-fancy> h2').click(function() {
          var $nextDiv = $(this).next();
          var $visibleSiblings = $nextDiv.siblings('div:visible');
       
          if ($visibleSiblings.length ) {
            $visibleSiblings.slideUp('fast', function() {
              $nextDiv.slideToggle('fast');
            });
          } else {
             $nextDiv.slideToggle('fast');
          }
        });
      });


// custom for sidebars, also swaps HTML text
      $(document).ready(function() {
        $('div.sidebar-slider> div.target').hide();  
        $('div.sidebar-slider> h3> a> span').click(function() {															
		  $('span.trigger').html("details");													
          $(this)//.html("hide")
		  .parent().parent().next('div.target').slideToggle('normal').toggleClass("showing")
          .siblings('div.target:visible').slideUp('normal');
		  
		  
          if ($(this).parent().parent().next('div.target').is(".showing")) {
            $(this).html("hide")
		  }
          else {
            $(this).html("details")
          }
		  
		  
    	  });
	});

// EZ texting code
function submitAJAXForm(sub) {

    var phoneCheck = document.getElementById('phonenumber').getValue();

    if(phoneCheck.length!=10 || isNaN(phoneCheck)) {
        var msgdialog = new Dialog();
        msgdialog.showMessage('Error', 'Please enter a valid phone number without spaces or dashes.');
        return false;
    }

    sub.setDisabled(true);
    sub.setValue(".. Sending ..");

    var ajax = new Ajax();
    ajax.responseType = Ajax.FBML;

    // confirmation message is msgAfterSub
    ajax.ondone = function(data) {
        var msgdialog = new Dialog();
        msgdialog.showMessage('Confirmation', "You've been successfully subscribed!");
        sub.setValue("Success!");
        return false;
    }

    ajax.onerror = function() {
        var msgdialog = new Dialog();
        msgdialog.showMessage('Error', 'An error has occurred while trying to join.');
        return false;
    }

    // collect field values
    var queryParams = {
        'firstName' : document.getElementById('firstName').getValue(),
        'lastName' : document.getElementById('lastName').getValue(),
        'phonenumber' : document.getElementById('phonenumber').getValue()
    };

    // post to widget URL
    ajax.post('https://app.eztexting.com/weblink/subscribe?ids=124741&group=104953', queryParams);
    return false;
}



// this is the end  of the jQuery docready
      });

