/* AnchorSlide
----------------------------------------------------------------------------------------*/
var AnchorSlide = Class.create({
	initialize : function(anchor) {
		this.anchor = anchor;
		this.content = this.anchor.hash.substr(1);
		this.setup();
	},
	setup: function(ev) {
		this.anchor.observe('click', this.scroll_to.bind(this));
	},
	scroll_to: function(ev) {
		new Effect.ScrollTo(this.content);
		ev.stop();
	}
});

/* setSendTo
----------------------------------------------------------------------------------------*/
function setSendTo() {
  var subject = document.getElementById('subject').value;
  var sendTo = document.getElementById('sendTo')
  
  if(subject==""){
	  sendTo.value = "admin@pexsupply.com";
  }
  if(subject=="my Order"){
	  sendTo.value = "shipping@pexsupply.com";
  }
  if(subject=="product info"){
	  sendTo.value = "stacey@pexsupply.com";
  }
  if(subject=="my Order"){
	  sendTo.value = "shipping@pexsupply.com";
  }
  if(subject=="price quote"){
	  sendTo.value = "nicole@pexsupply.com";
  }
  if(subject=="reorders"){
	  sendTo.value = "kari@pexsupply.com";
  }
  if(subject=="returns"){
	  sendTo.value = "lynn@pexsupply.com";
  }
  if(subject=="other"){
	  sendTo.value = "jessica@pexsupply.com";
  }
}

/*----------------------------------------------------------------------------------------*/

document.observe('dom:loaded', function() {
	$$('#faqs ul li').each(function(el) {
		new SimpleToggler(el.down('a'), el.down('div'));
	});
	
	$$('a[href^=http://www.youtube.com/]').each(function(element) {
		new YouTubePlayer(element, $('video'));
	});

	$$('#definitions a[href^=#]:not([href=#])').each(function(el) {
		new AnchorSlide(el);
	})
});
