jQuery(document).ready(function(){

if (!!('ontouchstart' in window)) {
	jQuery('#main').touchScroll({scrollHeight: 6836*2-jQuery(window).height(), touchTags: ['a']});
}

				
  //
  // Rotation
  //
  function rock() {
	//jQuery('#leavesContainer').animate({rotate: '-=2deg'}, 3000, 'easeInOutSine',  rockForth );
	jQuery('#leavesContainer').animate({rotate: '-=20deg'}, 0, 'easeInOutSine',  rockForth );
	}
  function rockBack() {
	jQuery('#leavesContainer').animate({rotate: '-=4deg'}, 6000, 'easeInOutSine',  rockForth );
	}
  function rockForth() {
	jQuery('#leavesContainer').animate({rotate: '+=4deg'}, 6000, 'easeInOutSine', rockBack );
	}
  rock();

  //
  // Leaves hover
  //
  function allOut () {
    jQuery('#leaves').css('background-position','0px 0px');
  }
  function servicesIn () {
    jQuery('#leaves').css('background-position','0px -350px');
  }
  function praiseIn () {
    jQuery('#leaves').css('background-position','0px -700px');
  }
  function faqIn () {
    jQuery('#leaves').css('background-position','0px -1050px');
  }
  function aboutIn () {
    jQuery('#leaves').css('background-position','0px -1400px');
  }
  function blogIn () {
    jQuery('#leaves').css('background-position','0px -1750px');
  }
  jQuery('#area_services').hover(servicesIn, allOut);
  jQuery('#area_praise').hover(praiseIn, allOut);
  jQuery('#area_faq').hover(faqIn, allOut);
  jQuery('#area_about').hover(aboutIn, allOut);
  jQuery('#area_blog').hover(blogIn, allOut);


  //
  // ICONS hover and click
  //
  function phoneIn () { jQuery('#icon-phone').css('background-position','0px -60px'); }
  function phoneOut () { jQuery('#icon-phone').css('background-position','0px 0px'); }
  jQuery('#icon-phone').hover(phoneIn, phoneOut);
  function phoneClick () { phoneOut(); document.location.href='tel:+1-908-915-1998'; }
  jQuery('#icon-phone').click(phoneClick);

  function mailIn () { jQuery('#icon-mail').css('background-position','-60px -60px'); }
  function mailOut () { jQuery('#icon-mail').css('background-position','-60px 0px'); }
  jQuery('#icon-mail').hover(mailIn, mailOut);
  function mailClick () { mailOut(); document.location.href='mailto:tami@sundancewellness.com'; }
  jQuery('#icon-mail').click(mailClick);

  function twitterIn () { jQuery('#icon-twitter').css('background-position',' -120px -60px'); }
  function twitterOut () { jQuery('#icon-twitter').css('background-position',' -120px 0px'); }
  jQuery('#icon-twitter').hover(twitterIn, twitterOut);
  function twitterClick () { twitterOut(); document.location.href='http://www.twitter.com/sundancetami'; }
  jQuery('#icon-twitter').click(twitterClick);

  function facebookIn () { jQuery('#icon-facebook').css('background-position','-180px -60px'); }
  function facebookOut () { jQuery('#icon-facebook').css('background-position','-180px 0px'); }
  jQuery('#icon-facebook').hover(facebookIn, facebookOut);
  function facebookClick () { facebookOut(); document.location.href='https://www.facebook.com/pages/Sundance-Wellness/100021230741'; }
  jQuery('#icon-facebook').click(facebookClick);
  
    
  //
  // Blowing leaves
  //
  /*function rotateLeafBack() {
    jQuery('#blowingLeafContainer').animate({rotate: '+=360deg'}, 10000, 'easeInOutSine', rotateLeafForth );
    }
  function rotateLeafForth() {
    jQuery('#blowingLeafContainer').animate({rotate: '+=360deg'}, 10000, 'easeInOutSine', rotateLeafBack );
    }
  rotateLeafBack();*/
    
});

