$(document).ready(function() {

//HOME SLIDER
var currentPosition = 0;
  var slideWidth = 850;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#homeslidecontainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
  .wrapAll('<div id="slideInner"></div>')
  // Float left to display horizontally, readjust .slides width
  .css({
    'float' : 'left',
    'width' : slideWidth
  });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert left and right arrow controls in the DOM
  $('#homeslider')
    .prepend('<span class="homeslidercontrol" id="leftControl">Move left</span>')
    .append('<span class="homeslidercontrol" id="rightControl">Move right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.homeslidercontrol')
    .bind('click', function(){
    // Determine new position
      currentPosition = ($(this).attr('id')=='rightControl')
    ? currentPosition+1 : currentPosition-1;

      // Hide / show controls
      manageControls(currentPosition);
      // Move slideInner using margin-left
      $('#slideInner').animate({
        'marginLeft' : slideWidth*(-currentPosition)
      });
    });

  // manageControls: Hides and shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() }
    else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() }
    else{ $('#rightControl').show() }
    }
//END HOME SLIDER


// HOVER-FADE FUNCTIONS$("a.fade img").hover(function () {// animate opacity to full$(this).stop().animate({opacity: 0.65}, 200);},// on mouse outfunction () {// animate opacity to nill$(this).stop().animate({opacity: 1}, 200);});


//VERTICAL THUMB SLIDING$('.filmslide').hover(function(){	$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});	}, function() {	$(".cover", this).stop().animate({top:'-170px'},{queue:false,duration:300});});
//SCROLLING$(".scroll").click(function(event){//prevent the default action for the click eventevent.preventDefault();//get the full url - like mysitecom/index.htm#homevar full_url = this.href;//split the url by # and get the anchor target name - home in mysitecom/index.htm#homevar parts = full_url.split("#");var trgt = parts[1];//get the top offset of the target anchorvar target_offset = $("#"+trgt).offset();var target_top = target_offset.top;//goto that anchor by setting the body scroll top to anchor top$('html, body').animate({scrollTop:target_top}, 500);});


//CLEAR FORM FIELDS
$("input#CustomFields_37_38").focus(function () {
if ($(this).val() == "xxx-xxx-xxxx") {
$(this).val("");
}
});});//END DOM LOADING// CHECK REGISTRATION
function SignupCheck(form) {
valcheck = form.EMAIL;hasDot = valcheck.value.indexOf(".");hasAt = valcheck.value.indexOf("@");if (hasDot == -1 || hasAt == -1) {	alert("Please enter your Email Address.");	valcheck.focus();	return false;} else {	return true;}}
