//*****************************************
// Coda slider - jquery function for sliding images
//*****************************************

$().ready(function() {
    $('#coda-slider-1').codaSlider({
          autoSlide: true,
          autoSlideInterval: 5500,
          autoSlideStopWhenClicked: true,
          autoHeightEaseDuration: 3000,
          autoHeightEaseFunction: "easeInOutElastic",
          slideEaseDuration: 3000
     });
});


//*****************************************
// Soft Scroll for jquery, using anchors
//*****************************************

$(function(){
    $('a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
        && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
            if ($target.length) {
                var targetOffset = $target.offset().top;
                $('html,body').animate({scrollTop: targetOffset}, 2000);
                return false;
            }
        }
    });
});


//*****************************************
// Validation for contact form
//*****************************************

function c_inquiry_val() {

// variables recorded for the entries on the comments and suggestions page
  var name;
  var phone;
  var email;
  var comments;
  var spam;
  var c;
  var d;
  
 // assigning values
  name = document.contact.contactName.value;
  c = document.contact.contactPhone.value;
  d = document.contact.contactEmail.value;
  comments = document.contact.comments.value;
  spam = document.contact.contactSpam.value;

// validating that a legitmate phone number, with area code is entered
   phone = c.match(/^(\d{3})-?\d{3}-?\d{4}$/);
// variable to check integrity of email address, by checking for @
   email = d.indexOf("@");
// Start of validations

// validatiing the user name is entered
    if (name == " "){
	    alert("Please enter your name");
	   return false;
	}	
	else if (name == "") {
	     alert("Please enter your name");
	     return false;
	}

// validating that a valid phone number is entered
	else if (phone == null) {
	     alert("Please enter your entire phone number, area code included in the form 111-111-1111");
	     return false;
	}
// validating that a valid email address is entered
	else if (email == -1) {
	     alert("Please enter your entire email address e.g. your-name@domain.com");
	     return false;
	}

// validating that a valid email address is entered
	else if (comments == "") {
	     alert("Please enter your comments or suggestions");
	     return false;
	}
// validating that this is not spam
	else if (spam != "4") {
	     alert("Please answer the question");
	     return false;
	}
//  if form is properly completed, then submit the form	
	else {
       return true;
   }
}


//*****************************************
// Validation for contact form
//*****************************************
function s_inquiry_val() {

// variables recorded for the entries on the comments and suggestions page
  var name;
  var phone;
  var email;
  var spam;
  var c;
  var d;
  
 // assigning values
  name = document.contact.contactName.value;
  c = document.contact.contactPhone.value;
  d = document.contact.contactEmail.value;
  spam = document.contact.contactSpam.value;

// validating that a legitmate phone number, with area code is entered
   phone = c.match(/^(\d{3})-?\d{3}-?\d{4}$/);
// variable to check integrity of email address, by checking for @
   email = d.indexOf("@");
// Start of validations

// validatiing the user name is entered
    if (name == " "){
	    alert("Please enter your name");
	   return false;
	}	
	else if (name == "") {
	     alert("Please enter your name");
	     return false;
	}

// validating that a valid phone number is entered
	else if (phone == null) {
	     alert("Please enter your entire phone number, area code included in the form 111-111-1111");
	     return false;
	}
// validating that a valid email address is entered
	else if (email == -1) {
	     alert("Please enter your entire email address e.g. your-name@domain.com");
	     return false;
	}

// validating that this is not spam
	else if (spam != "4") {
	     alert("Please answer the question");
	     return false;
	}
//  if form is properly completed, then submit the form	
	else {
       return true;
   }
}




//*****************************************
// Script for opening new window for directions
//*****************************************

function popUpword(URL) {

   // establishing an id to distinguish unique windows
      day = new Date();
      id = day.getTime();
      
   // using a unique id, the eval statement opens up the new window with the characteristics below
       eval("window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=650,height=550');");
}



