// JavaScript Document
/* homepage featured content slider
   ----------------------------------------------------*/
jQuery(document).ready(function(){
//Page Flip on hover
	jQuery("#pageflip").hover(function() {
		// jQuery(".msg_block").stop().css("background-image", "url(http://www.divinehealthwellness.com/subscribe.png)");  
		jQuery(".msg_block").stop().css("background-position", "bottom");
		jQuery("#pageflip img , .msg_block").stop()
			.animate({
				width: '600px', 
				height: '602px'
			}, 500);
			
		} , function() {
		jQuery("#pageflip img").stop() 
			.animate({
				width: '50px', 
				height: '52px'
			}, 220);
		// jQuery(".msg_block").stop().css("background-image", "url(http://www.divinehealthwellness.com/tab.png)");
		jQuery(".msg_block").stop().css({backgroundPosition: 'top right'});
		jQuery(".msg_block").stop() 
			.animate({
				width: '50px', 
				height: '50px'
			}, 200);
	});	
});


jQuery(document).ready(function(jQuery){ 
/* jQuery(document).ready(function() { */
  /* if (jQuery('#slider').exists()) { */
  if ( jQuery('#slider').length ) {
    jQuery('#slider section').cycle({
      after: onAfter,
      fx: 'fade',
  //    fx: 'scrollLeft',
  //    easing: 'easeInOutBack',
      pause: 1,
      speed: 500,
      timeout: 5000,
      next: '#next',
      prev: '#prev',
      pager: '#slide_controller',
      pagerAnchorBuilder: buildSlideControlls
    });
  }
});

// sets class for container specific to each slide
function onAfter(curr,next,opts){
  jQuery('#slider').removeClass().addClass('slide_' + (opts.currSlide + 1) + '_bg');
};

// build links for slide controller
function buildSlideControlls(idx, slide) {
  return '<a href="#">'+(idx+1)+'</a>';
};


/* open links with rel="external" in a new window
   ----------------------------------------------------*/
jQuery(function() {
	jQuery('a[rel*=external]').click( function() {
		window.open(this.href);
		return false;
	});
});


/* open links with fully qualified URL in a new window
   ----------------------------------------------------*/

jQuery(function() {
	jQuery("a[href*='http://']:not([href*='"+location.hostname+"'])").click( function() {
		window.open(this.href);
		return false;
	});
});


/* set height for diagnosing disorders div on gi tract page so that bg image can be vertically aligned to the bottom
   ----------------------------------------------------*/

jQuery(document).ready(function(){
  var div_height = jQuery('body#gi_tract section#content section.main div.diagnosing_disorders').height();
  jQuery('body#gi_tract section#content section.main div.diagnosing_disorders div.sandbag_1').css({'height' :
  div_height - 172});
});



