﻿

function my_home_slides() {

  $('#registrationLeftSlider').cycle({ fx: 'fade', speed: 1500, timeout: 10000, pager: '#nav', pagerEvent: 'click', fastOnEvent: true,     
      pagerAnchorBuilder: function(idx, slide) {
        // return selector string for existing anchor 
        return '#nav li:eq(' + idx + ') a';
    }
  });
  
  $('#direct').click(function() {
    $('#nav li:eq(2) a').trigger('click');
    return false;
  });


  $('#rightDescription').cycle({
    fx: 'fade',
    timeout: 10000,
    speed: 0,
    pager: '#nav',
    pagerEvent: 'click',
    fastOnEvent: true,
    pagerAnchorBuilder: function(idx, slide) {
      // return selector string for existing anchor 
      return '#nav li:eq(' + idx + ') a';
    }
  });
  $('#direct').click(function() {
    $('#nav li:eq(2) a').trigger('click');
    return false;
  });

}

function my_gallery_slides() {

  $('#highlightGaller_slider').cycle({ fx: 'fade', speed: 1500, timeout: 10000, pagerEvent: 'mouseover', fastOnEvent: true, next: '#next_slide', pager: '#highlightGaller_thumbs_navigation_pager', prev: '#previous_slide',
    pagerAnchorBuilder: function (idx, slide) { return '#highlightGaller_thumbs_navigation_pager li:eq(' + idx + ') a'; } 
  });

}

function my_hotel_slides() {

  $('#hotel_slider').cycle ({ fx: 'fade', speed: 1500, timeout: 10000, pager: '#hotel_navigation_pager', next: '#next_slide', prev: '#previous_slide', pagerEvent: 'click', fastOnEvent: true, pagerAnchorBuilder: function(idx, slide) {
  return '#hotel_navigation_pager li:eq(' + idx + ') a'; }});

  $('#hotel_description').cycle({ fx: 'fade', timeout: 10000, speed: 0,
    pager: '#hotel_navigation_pager', pagerEvent: 'click', fastOnEvent: true, next: '#next_slide', prev: '#previous_slide',
    pagerAnchorBuilder: function(idx, slide) { return '#hotel_navigation_pager li:eq(' + idx + ') a'; }
  });
  
 

 
  
  $('#direct').click(function() { $('#hotel_navigation_pager li:eq(2) a').trigger('click');   
    return false;
  });

}

var highlighted = Array(); 

function ValidateRequiredFields() {
  var blnErrors = false;
  var blnEmailFormatError = false;
  var errorlabels = Array();

  unhighlight(highlighted);

  if (isEmptyField(txtFirstName)) {
    errorlabels.push(lblFirstName);
    blnErrors = true;
  }

  if (isEmptyField(txtLastName)) {
    errorlabels.push(lblLastName);
    blnErrors = true;
  }

  if (isEmptyField(txtCompany)) {
    errorlabels.push(lblCompany);
    blnErrors = true;
  }

  if (isEmptyField(txtAddress1)) {
    errorlabels.push(lblAddress1);
    blnErrors = true;
  }

  if (isEmptyField(txtCity)) {
    errorlabels.push(lblCity);
    blnErrors = true;
  }

  if (isEmptyField(txtState)) {
    errorlabels.push(lblState);
    blnErrors = true;
  }

  if (isEmptyField(txtPostalCode) || !isValidZipField(txtPostalCode)) {
    errorlabels.push(lblPostalCode);
    blnErrors = true;
  }

  if (isEmptyField(txtPhone1) || isEmptyField(txtPhone2) || isEmptyField(txtPhone3)) {
    errorlabels.push(lblPhone);
    blnErrors = true;
  }
  var phonestring = document.getElementById(txtPhone1).value + document.getElementById(txtPhone2).value + document.getElementById(txtPhone3).value;
  if (!isValidPhone(phonestring)) {
    errorlabels.push(lblPhone);
    blnErrors = true;
  }

  if (isEmptyField(txtEmail)  || !isValidEmailField(txtEmail) ){
    errorlabels.push(lblEmail);
    blnErrors = true;
  }

  if (isEmptyField(txtConfirmEmail)  || !isValidEmailField(txtConfirmEmail) ){
    errorlabels.push(lblConfirmEmail);
    blnErrors = true;
  }

  if (document.getElementById(txtEmail).value != document.getElementById(txtConfirmEmail).value) {
    errorlabels.push(lblConfirmEmail);
    blnErrors = true;
  }

  var errorTop = document.getElementById(divError);
  
  if (blnErrors) {
    highlight(errorlabels);
    errorTop.innerHTML = "<ul><li>Please locate the highlighted fields shown above and fill in the required information.</li></ul>";
    errorTop.style.display = "block";
    return false;
  }
  else {
    errorTop.style.display = "none";
    return true;
  }
}


function ValidateRequiredFieldsCallIn() {
  var blnErrors = false;
  var blnEmailFormatError = false;
  var errorlabels = Array();

  unhighlight(highlighted);

  if (isEmptyField(txtFirstName)) {
    errorlabels.push(lblFirstName);
    blnErrors = true;
  }

  if (isEmptyField(txtLastName)) {
    errorlabels.push(lblLastName);
    blnErrors = true;
  }

  if (isEmptyField(txtCompany)) {
    errorlabels.push(lblCompany);
    blnErrors = true;
  }
  
  if (isEmptyField(txtCallIn)) {
    errorlabels.push(lblCallIn);
    blnErrors = true;
  }
  
  if (isNotTwoCharacters(txtCallIn)) {
    errorlabels.push(lblCallIn);
    blnErrors = true;
  }

   var errorTop = document.getElementById(divError);


  if (blnErrors) {
    highlight(errorlabels);
    errorTop.innerHTML = "<ul><li>Please locate the highlighted fields shown above and fill in the required information.</li></ul>";
    errorTop.style.display = "block";
    return false;
  }
  else {
    errorTop.style.display = "none";
    return true;
  }
}





/* ----------------------- Misc utils ----------------------- */


function isNotTwoCharacters(field) {
  var myField = document.getElementById(field);
  if (myField.value.length == 2) {
    return false;
  }
  else {
    return true;
  }
}

// takes OBJ as param
function isEmptyField(field) {

  chkfield = document.getElementById(field);

  
  if (isEmpty(chkfield.value)) {
    return true;
  }
  else {
    return false;
  }
}

// takes OBJ as param
function isNumericField(field) {
  chkfield = document.getElementById(field);
  if (isNaN(chkfield.value)) {
    return true;
  }
  else {
    return false;
  }
}


// takes STRING as parameter
function isEmpty(str) {
    
  if (str.length == 0) {
    return true;
  }
  else {
    return false;
  }
}

function isValidEmailOrPhone(str) {
  if (isValidEmail(str) || isValidPhone(str)) {
    return true;
  } else {
    return false;
  }
}

function isValidPhone(fld) {
  var phoneFilter = /^\+?1?[\( \-\.]*[0-9]{3}[\) \-\.]*[0-9]{3}[ \-\.]?[0-9]{4}$/;
  return (fld.match(phoneFilter) != null);
}

function isValidPhoneField(fld) {
  var str = document.getElementById(fld).value;

  var phoneFilter = /^\+?1?[\( \-\.]*[0-9]{3}[\) \-\.]*[0-9]{3}[ \-\.]?[0-9]{4}$/;
  return (str.match(phoneFilter) != null);
}

function isValidEmail(fld) {
  var emailFilter = /^[^+][+\-.\w]*@([\w\-+]+\.)+[\w]{2,}$/;
  return (fld.match(emailFilter) != null);
}

function isValidEmailField(fld) {
  var str = document.getElementById(fld).value;
  var emailFilter = /^[^+][+\-.\w]*@([\w\-+]+\.)+[\w]{2,}$/;
  return (str.match(emailFilter) != null);
}

function isValidZipField(fld) {
  var str = document.getElementById(fld).value;
  var emailFilter = /^[0-9]{5}$/;
  return (str.match(emailFilter) != null);
}




function checkMaxLength(fld, maxlen) {
  return (fld.value.length <= maxlen)
}

function unhide(div) { document.getElementById(div).style.display = "block"; }

function hide(div) { document.getElementById(div).style.display = "none"; }


// highlight() -- displays given labels with highlighted class
function highlight(fields) {

  for (var label in fields) {
    if (document.getElementById(fields[label])) {
      document.getElementById(fields[label]).className += " highlighted";
    }
  }
  highlighted = fields; // remember what fields you just highlighted
}


// unhighlight() turns highlighting off: revert to pre-highlighted CSS class 

function unhighlight(fields) {

  var currentClass;
  var unhighlightedClass;

  for (var label in fields) {
    if (document.getElementById(fields[label])) {
      currentClass = document.getElementById(fields[label]).className;
      unhighlightedClass = currentClass.replace(/highlighted/g, "");
      document.getElementById(fields[label]).className = unhighlightedClass;
    }
  }

} // end function unhighlight

function Unhide(oControl) {
  if (document.getElementById(oControl).className == "unhidden") {
    document.getElementById(oControl).className = "hidden";
  }
  if (document.getElementById(oControl).className == "hidden") {
    document.getElementById(oControl).className = "unhidden";
  }
}




var qTipTag = "a,label,input"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 0; //This is qTip's X offset//
var qTipY = 15; //This is qTip's Y offset//

//There's No need to edit anything below this line//
tooltip = {
  name: "qTip",
  offsetX: qTipX,
  offsetY: qTipY,
  tip: null
}

tooltip.init = function() {
  var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
  if (!tipContainerID) { var tipContainerID = "qTip"; }
  var tipContainer = document.getElementById(tipContainerID);

  if (!tipContainer) {
    tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
    tipContainer.setAttribute("id", tipContainerID);
    document.getElementsByTagName("body").item(0).appendChild(tipContainer);
  }

  if (!document.getElementById) return;
  this.tip = document.getElementById(this.name);
  if (this.tip) document.onmousemove = function(evt) { tooltip.move(evt) };

  var a, sTitle, elements;

  var elementList = qTipTag.split(",");
  for (var j = 0; j < elementList.length; j++) {
    elements = document.getElementsByTagName(elementList[j]);
    if (elements) {
      for (var i = 0; i < elements.length; i++) {
        a = elements[i];
        sTitle = a.getAttribute("title");
        if (sTitle) {
          a.setAttribute("tiptitle", sTitle);
          a.removeAttribute("title");
          a.removeAttribute("alt");
          a.onmouseover = function() { tooltip.show(this.getAttribute('tiptitle')) };
          a.onmouseout = function() { tooltip.hide() };
        }
      }
    }
  }
}

tooltip.move = function(evt) {
  var x = 0, y = 0;
  if (document.all) {//IE
    x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
    y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
    x += window.event.clientX;
    y += window.event.clientY;

  } else {//Good Browsers
    x = evt.pageX;
    y = evt.pageY;
  }
  this.tip.style.left = (x + this.offsetX) + "px";
  this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function(text) {
  if (!this.tip) return;
  this.tip.innerHTML = text;
  this.tip.style.display = "block";
}

tooltip.hide = function() {
  if (!this.tip) return;
  this.tip.innerHTML = "";
  this.tip.style.display = "none";
}

window.onload = function() {
  tooltip.init();
}


