/**************************************************************************************************************************
This top portion of code comes from Tim's file and has been modifed slightly to accept the event
parameter.
**************************************************************************************************************************/
var bDisplayPopup = true;
var timeOut = null;
var popUp = null;
var intTimeOut = 500;
var compatible = 1;
if (YAHOO.env.ua.ie > 0 && YAHOO.env.ua.ie < 7) {compatible = 0;}
function rollOnCerts(evt, intClubid){
if (!popUp && compatible==1) {
var call = "showCertPopup(" + evt.clientX + ", " + evt.clientY + ", " + intClubid + ")";
timeOut = setTimeout(call, intTimeOut);
}
};
function showCertPopup(x, y, intClubid){
if (timeOut) {
clearTimeout(timeOut);
timeOut = null;
popUp = new CertPopup({
searchArea: '',
startDate: '',
endDate: '',
clubID: intClubid,
onClose: hidePopup
});
popUp.show(x, y);
}
};
function rollOnTeeTimes(evt, intCourseId, tdate, intTtid){
if (!popUp && compatible==1) {
var call = "showTeeTimePopup(" + evt.clientX + ", " + evt.clientY + ", " + intCourseId + ",'" + tdate + "'," + intTtid + ")";
timeOut = setTimeout(call, intTimeOut);
}
};
function showTeeTimePopup(x, y, intCourseId, tdate, intTtid){
if (timeOut) {
clearTimeout(timeOut);
timeOut = null;
popUp = new TeeTimePopup({
courseID: intCourseId,
ttid: intTtid,
uniqseqno: '',
searchDate: tdate,
onClose: hidePopup
});
popUp.show(x, y);
}
};
function rollOnClubs(evt, intClubid){
if (!popUp && compatible==1) {
var call = "showClubPopup(" + evt.clientX + ", " + evt.clientY + ", " + intClubid + ")";
timeOut = setTimeout(call, intTimeOut);
}
};
function showClubPopup(x, y, intClubid){
if (timeOut) {
clearTimeout(timeOut);
timeOut = null;
popUp = new ClubPopup({
clubid: intClubid,
onClose: hidePopup
});
popUp.show(x, y);
}
};
function rollOff(){
clearTimeout(timeOut);
};
function hidePopup(){
if (popUp) {
popUp = null;
}
};
/**************************************************************************************************************************
End of Tim's code
**************************************************************************************************************************/
/**
* Utility to format floats as dollars (XXX.XX)
* @param {Object} amount
*/
function formatCurrency(amount){
var i = parseFloat(amount);
if (isNaN(i)) {
i = 0.00;
}
var minus = '';
if (i < 0) {
minus = '-';
}
i = Math.abs(i);
i = parseInt((i + 0.005) * 100, 10);
i = i / 100;
s = new String(i);
if (s.indexOf('.') < 0) {
s += '.00';
}
if (s.indexOf('.') == (s.length - 2)) {
s += '0';
}
s = minus + s;
return s;
};
/**
* Defines the CertPopup class.
*
* @param {Object} options
*/
function CertPopup(options){
this.url = "services/getPopup.cfm";
this.action = "certDetails";
this.searchArea = options.searchArea;
this.startDate = options.startDate;
this.endDate = options.endDate;
this.clubID = options.clubID;
this.options = options;
if (jQuery('.cert_popup_container').length === 0 && jQuery('.cert_popup').length === 0) {
var html = "";
html += "
";
jQuery('body').append(html);
//
// Setup the event handlers.
//
obj = this;
jQuery('.cert_popup #closebox').click(function(){
obj.close();
});
}
};
/**
* Called to display the popup.
*
* @param {Object} x
* @param {Object} y
*/
CertPopup.prototype.show = function(x, y){
this.location = {top: y, left: x};
this.load();
};
/**
* Called to close (hide) the popup
*/
CertPopup.prototype.close = function(){
jQuery('.cert_popup_container').css('display', 'none');
if (this.options.onClose) {
this.options.onClose();
}
};
/**
* Call the data service to load the information. When the load is done, calls
* onLoadComplete to popup and display the window.
*/
CertPopup.prototype.load = function(){
obj = this;
jQuery.getJSON(this.url, {
action: this.action,
searcharea: this.searchArea,
startdate: this.startDate,
enddate: this.endDate,
clubid: this.clubID
}, function(data){
obj.onLoadComplete(data);
});
};
/**
* Once the data comes back, format it and display it.
*
* @param {Object} data
*/
CertPopup.prototype.onLoadComplete = function(result){
var obj = this;
this.data = result;
jQuery(".cert_popup #title").html(result.DATA.COURSENAME[0]);
jQuery(".cert_popup #subtitle").html(result.DATA.CITY[0] + ", " + result.DATA.STATE[0]);
jQuery(".cert_popup #col1").html("");
//
// Loop through the data and do a couple of things... first, calculate the sum of all
// available certificates. Next, determine the longest description and install it into
// the DOM. We do this so that we can calculate the max height later.
//
var sum = 0;
var itemhtml = "";
for (var i = 0; i < result.ROWCOUNT; i++) {
sum += result.DATA.AVAILABLE[i];
var now = formatCurrency(result.DATA.NOW[i]);
var savings = formatCurrency(result.DATA.SAVINGS[i]);
itemhtml = "";
itemhtml += "";
itemhtml += "" + result.DATA.TITLE[i] + "";
itemhtml += "
";
itemhtml += "Now $" + now + " - Save $" + savings + "";
itemhtml += "
";
jQuery(".cert_popup #col1").append(itemhtml);
}
if (sum == 1) {
jQuery(".cert_popup #available").html(sum + " Certificate Available");
}
else {
jQuery(".cert_popup #available").html(sum + " Certificates Available");
}
//
// All this bs is used to calculate the biggest height, which can't be done until
// the thing is display. First, hide the right column, then display the popup. At
// that point we can get the calculated height of the right column and then specifically
// set it. Finally, we make the column visible.
//
//jQuery(".cert_popup_container").css("visibility", "hidden");
jQuery('.cert_popup_container').css('display', 'block');
var biggest_size = 0;
jQuery(".cert_popup #col2").height(0);
for (i = 0; i < result.ROWCOUNT; i++) {
jQuery(".cert_popup #buy_now").html("Buy Now");
jQuery(".cert_popup #expiration").html("Good Through: " + this.data.DATA.ENDDATE[i]);
jQuery(".cert_popup #save").html("Save $" + savings);
jQuery(".cert_popup #restrictions").html(result.DATA.RESTRICTIONS[i]);
var height = jQuery(".cert_popup #col2").height();
biggest_size = height > biggest_size ? height : biggest_size;
}
jQuery(".cert_popup #col2").height(biggest_size + "px");
jQuery(".cert_popup #buy_now").html("");
jQuery(".cert_popup #expiration").html("");
jQuery(".cert_popup #save").html("");
jQuery(".cert_popup #restrictions").html("");
this.position();
jQuery(".cert_popup_container").css("visibility", "visible");
//
// Set up the roll over event handlers for the items.
//
jQuery(".cert_popup .item").hover(function(evt){
obj.onItemRollOn(this, evt);
}, function(evt){
obj.onItemRollOff(this, evt);
});
};
CertPopup.prototype.position = function() {
var scrollTop = jQuery(document).scrollTop();
var scrollLeft = jQuery(document).scrollLeft();
var width = jQuery('.cert_popup_container').outerWidth();
var height = jQuery('.cert_popup_container').outerHeight();
var viewportHeight = jQuery(window).height();
var viewportWidth = jQuery(window).width();
//alert("Mouse: " + this.location.left + ", " + this.location.top);
//alert("Scroll: " + scrollLeft + ", " + scrollTop);
//alert("Location: " + this.location.left + ", " + this.location.top);
this.location.left += scrollLeft;
this.location.top += scrollTop;
if (this.location.top + height > viewportHeight + scrollTop) {
this.location.top = viewportHeight - height + scrollTop;
}
if (this.location.left + width > viewportWidth + scrollLeft) {
this.location.left = viewportWidth - width + scrollLeft;
}
if (this.location.top < 0) { this.location.top = scrollTop; }
if (this.location.left < 0) { this.location.left = scrollLeft; }
jQuery('.cert_popup_container').css('top', this.location.top + "px");
jQuery('.cert_popup_container').css('left', this.location.left + "px");
};
CertPopup.prototype.onClick = function(evt){
window.location = this.reserveLink;
return false;
};
CertPopup.prototype.onItemRollOn = function(item, evt){
var obj = this;
jQuery(".cert_popup .item").unbind("click");
jQuery(".cert_popup .#col2").unbind("click");
jQuery(".cert_popup .item").removeClass("active");
jQuery(".cert_popup #col2").removeClass("active");
this.currentIndex = jQuery(item).attr("index");
jQuery(".cert_popup #item_" + this.currentIndex).addClass("active");
jQuery(".cert_popup #col2").addClass("active");
jQuery(".cert_popup .active").click(function(evt){
obj.onClick(evt);
});
this.reserveLink = "https://www.clickateetime.com/coupons.cfm?modaction=purchase&groupid=" + this.data.DATA.GID[this.currentIndex] + "&clubid=" + + this.data.DATA.CLUBID[this.currentIndex];
var savings = formatCurrency(this.data.DATA.SAVINGS[this.currentIndex]);
jQuery(".cert_popup #buy_now").html("Buy Now");
jQuery(".cert_popup #expiration").html("Good Through: " + this.data.DATA.ENDDATE[this.currentIndex]);
jQuery(".cert_popup #save").html("Save $" + savings);
jQuery(".cert_popup #restrictions").html(this.data.DATA.RESTRICTIONS[this.currentIndex]);
};
CertPopup.prototype.onItemRollOff = function(item, evt){
};
/**
* Defines the club popup.
*
* @param {Object} options
*/
function ClubPopup(options){
this.url = "services/getPopup.cfm";
this.action = "clubDetails";
this.clubid = options.clubid;
this.options = options;
if (jQuery('.teetime_popup_container').length === 0 && jQuery('.club_popup').length === 0) {
var html = "";
html += "";
jQuery('body').append(html);
//
// Setup the event handlers.
//
obj = this;
jQuery('.club_popup #closebox').click(function(){
obj.close();
});
}
};
/**
* Called to display the popup.
*
* @param {Object} x
* @param {Object} y
*/
ClubPopup.prototype.show = function(x, y){
this.location = {top: y, left: x};
this.load();
};
/**
* Called to close (hide) the popup
*/
ClubPopup.prototype.close = function(){
jQuery('.club_popup_container').css('display', 'none');
if (this.options.onClose) {
this.options.onClose();
}
};
/**
* Call the data service to load the information. When the load is done, calls
* onLoadComplete to popup and display the window.
*/
ClubPopup.prototype.load = function(){
obj = this;
jQuery.getJSON(this.url, {
action: this.action,
clubid: this.clubid
}, function(data){
obj.onLoadComplete(data);
});
};
/**
* Once the data comes back, format it and display it.
*
* @param {Object} data
*/
ClubPopup.prototype.onLoadComplete = function(data){
this.data = data;
var name = data.DATA.NAME[0];
var address1 = data.DATA.ADDRESS[0];
var address2 = data.DATA.CITY[0] + ', ' + data.DATA.STATE[0] + ' ' + data.DATA.ZIP[0];
jQuery('.club_popup #content').html(data.DATA.DESCRIPTION[0]);
jQuery('.club_popup #more_button').attr("href", "billboard.cfm?clubid=" + this.options.clubid);
jQuery(".club_popup #title").html(name);
jQuery(".club_popup #subtitle").html(address1 + "
" + address2);
jQuery('.club_popup_container').css('visibility', 'hidden');
jQuery('.club_popup_container').css('display', 'block');
this.position();
jQuery('.club_popup_container').css('visibility', 'visible');
};
ClubPopup.prototype.position = function() {
var scrollTop = jQuery(document).scrollTop();
var scrollLeft = jQuery(document).scrollLeft();
var width = jQuery('.club_popup_container').outerWidth();
var height = jQuery('.club_popup_container').outerHeight();
var viewportHeight = jQuery(window).height();
var viewportWidth = jQuery(window).width();
this.location.left += scrollLeft;
this.location.top += scrollTop;
if (this.location.top + height > viewportHeight + scrollTop) {
this.location.top = viewportHeight - height + scrollTop;
}
if (this.location.left + width > viewportWidth + scrollLeft) {
this.location.left = viewportWidth - width + scrollLeft;
}
if (this.location.top < 0) { this.location.top = scrollTop; }
if (this.location.left < 0) { this.location.left = scrollLeft; }
jQuery('.club_popup_container').css('top', this.location.top + "px");
jQuery('.club_popup_container').css('left', this.location.left + "px");
};
/**
* Defines the TeeTime Popup
* @param {Object} options
*/
function TeeTimePopup(options){
this.url = "services/getPopup.cfm";
this.action = "teetimeDetails";
this.courseID = options.courseID;
this.searchDate = options.searchDate;
this.options = options;
if (jQuery('.teetime_popup_container').length === 0 && jQuery('.teetime_popup').length === 0) {
var html = "";
html += "";
jQuery('body').append(html);
//
// Setup the event handlers.
//
obj = this;
jQuery('.teetime_popup #closebox').click(function(){
obj.close();
});
}
};
/**
* Called to display the popup.
*
* @param {Object} x
* @param {Object} y
*/
TeeTimePopup.prototype.show = function(x, y){
this.location = {top: y, left: x};
this.load();
};
/**
* Called to close (hide) the popup
*/
TeeTimePopup.prototype.close = function(){
jQuery('.teetime_popup_container').css('display', 'none');
if (this.options.onClose) {
this.options.onClose();
}
};
/**
* Call the data service to load the information. When the load is done, calls
* onLoadComplete to popup and display the window.
*/
TeeTimePopup.prototype.load = function(){
obj = this;
jQuery.getJSON(this.url, {
action: this.action,
courseID: this.courseID,
searchDate: this.searchDate
}, function(data){
obj.onLoadComplete(data);
});
};
/**
* Once the data comes back, format it and display it.
*
* @param {Object} data
*/
TeeTimePopup.prototype.onLoadComplete = function(result){
var obj = this;
this.data = result;
jQuery(".teetime_popup #col1").html("");
jQuery(".teetime_popup #title").html(result.DATA.COURSENAME[0]);
jQuery(".teetime_popup #subtitle").html(result.DATA.CITY[0] + ", " + result.DATA.STATE[0]);
var itemhtml = "";
for (var i = 0; i < result.ROWCOUNT; i++) {
var now = formatCurrency(result.DATA.NOW[i]);
var savings = formatCurrency(result.DATA.SAVINGS[i]);
itemhtml = "";
itemhtml += "";
itemhtml += " " + result.DATA.TIME[i] + "";
itemhtml += " $" + now + " - Save $" + savings + "";
itemhtml += "
";
jQuery(".teetime_popup #col1").append(itemhtml);
}
//
// All this bs is used to calculate the biggest height, which can't be done until
// the thing is display. First, hide the right column, then display the popup. At
// that point we can get the calculated height of the right column and then specifically
// set it. Finally, we make the column visible.
//
jQuery(".teetime_popup_container").css("visibility", "hidden");
jQuery('.teetime_popup_container').css('display', 'block');
var biggest_size = 0;
jQuery(".teetime_popup #col2").height(0);
for (i = 0; i < result.ROWCOUNT; i++) {
jQuery(".teetime_popup #buy_now").html("Buy Now");
jQuery(".teetime_popup #save").html("Save $");
jQuery(".teetime_popup #information").html(result.DATA.TEETIMEPOLICY[i]);
var height = jQuery(".teetime_popup #col2").height();
biggest_size = height > biggest_size ? height : biggest_size;
}
jQuery(".teetime_popup #col2").height(biggest_size + "px");
jQuery(".teetime_popup #buy_now").html("");
jQuery(".teetime_popup #save").html("");
jQuery(".teetime_popup #restrictions").html("");
this.position();
jQuery(".teetime_popup_container").css("visibility", "visible");
//
// Set up the roll over event handlers for the items.
//
jQuery(".teetime_popup .item").hover(function(evt){
obj.onItemRollOn(this, evt);
}, function(evt){
obj.onItemRollOff(this, evt);
});
};
TeeTimePopup.prototype.position = function() {
var scrollTop = jQuery(document).scrollTop();
var scrollLeft = jQuery(document).scrollLeft();
var width = jQuery('.teetime_popup_container').outerWidth();
var height = jQuery('.teetime_popup_container').outerHeight();
var viewportHeight = jQuery(window).height();
var viewportWidth = jQuery(window).width();
this.location.left += scrollLeft;
this.location.top += scrollTop;
if (this.location.top + height > viewportHeight + scrollTop) {
this.location.top = viewportHeight - height + scrollTop;
}
if (this.location.left + width > viewportWidth + scrollLeft) {
this.location.left = viewportWidth - width + scrollLeft;
}
if (this.location.top < 0) { this.location.top = scrollTop; }
if (this.location.left < 0) { this.location.left = scrollLeft; }
jQuery('.teetime_popup_container').css('top', this.location.top + "px");
jQuery('.teetime_popup_container').css('left', this.location.left + "px");
};
TeeTimePopup.prototype.onClick = function(evt){
window.location = this.reserveLink;
return false;
};
TeeTimePopup.prototype.onItemRollOn = function(item, evt){
var obj = this;
jQuery(".teetime_popup .item").unbind("click");
jQuery(".teetime_popup .#col2").unbind("click");
jQuery(".teetime_popup .item").removeClass("active");
jQuery(".teetime_popup #col2").removeClass("active");
this.currentIndex = jQuery(item).attr("index");
jQuery(".teetime_popup #item_" + this.currentIndex).addClass("active");
jQuery(".teetime_popup #col2").addClass("active");
jQuery(".teetime_popup .active").click(function(evt){
obj.onClick(evt);
});
var source = this.data.DATA.SOURCE[this.currentIndex];
this.reserveLink = (source == 1 ? "https://www.clickateetime.com/ResStep1.cfm?ttid=" : "https://www.clickateetime.com/cypress_getsessionid.cfm?ttid=") + this.data.DATA.TTID[this.currentIndex] + "&clubid=" + + this.data.DATA.CLUBID[this.currentIndex];
var savings = formatCurrency(this.data.DATA.SAVINGS[this.currentIndex]);
jQuery(".teetime_popup #buy_now").html("Buy Now");
jQuery(".teetime_popup #save").html(this.data.DATA.TIME[this.currentIndex] + ' You Save $' + savings);
jQuery(".teetime_popup #information").html(this.data.DATA.INFORMATION[this.currentIndex]);
};
TeeTimePopup.prototype.onItemRollOff = function(item, evt){
};