var dynLoaded = false;
// function to load jQuery...
load = function() {
load.getScript("http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js");
load.tryReady(0); // This function waits until jQuery loads before using it.
}
// dynamically load a javascript file.
load.getScript = function(filename) {
var script = document.createElement('script')
script.setAttribute("type","text/javascript")
script.setAttribute("src", filename)
if (typeof script!="undefined")
document.getElementsByTagName("head")[ 0 ].appendChild(script)
}
load.tryReady = function(time_elapsed) {
// Continually polls to see if jQuery is loaded.
if (typeof jQuery == "undefined") { // if jQuery isn't loaded yet...
if (time_elapsed <= 10000) { // and we havn't given up trying...
setTimeout("load.tryReady(" + (time_elapsed + 200) + ")", 200); // set a timer to check again in 200 ms.
} else {
// alert("Timed out while loading jQuery.")
}
} else {
// Any code to run after jQuery loads goes here!
// for example:
dynLoaded = true;
groupon_init();
}
}
if (typeof(jQuery) == 'undefined') {
// jQuery isn't loaded, so we need to load it...
load();
} else {
groupon_init();
}
var DateDiff = function(d1, d2) {
var t2 = d2.getTime();
var t1 = d1.getTime();
var wholeDays = 0;
var wholeHours = 0;
var wholeMinutes = 0;
var wholeSeconds = 0;
var totalSeconds = parseInt((t2-t1) / 1000);
// 86400 seconds in 1 day
(totalSeconds > 86400) ? wholeDays = Math.abs(parseInt(totalSeconds / (86400))) : wholeDays = 0;
var leftAfterDays = totalSeconds - (wholeDays * 86400);
// 3600 seconds in 1 hour
var wholeHours = Math.abs(parseInt(leftAfterDays / 3600));
var leftAfterHours = leftAfterDays - (wholeHours * 3600);
// 60 seconds in 1 minute
var wholeMinutes = Math.abs(parseInt(leftAfterHours / 60));
var leftAfterMinutes = leftAfterHours - (wholeMinutes * 60);
var breakDown = new Object();
breakDown[ 'days' ] = wholeDays;
if (wholeDays > 0) {
wholeHours = wholeHours + (24*wholeDays);
}
breakDown[ 'hours' ] = wholeHours;
breakDown[ 'minutes' ] = wholeMinutes;
breakDown[ 'seconds' ] = leftAfterMinutes;
return breakDown;
}
var niceDateDiff = '';
var gInterval=new Array();
function startCountdown(endDate, i) {
gInterval[ i ]=setInterval(function() {
d1 = new Date();
niceDateDiff = DateDiff(d1, endDate);
// $('#grouponDays' + i).text(niceDateDiff[ 'days' ]);
jQuery('#grouponHours' + i).text(niceDateDiff[ 'hours' ]);
jQuery('#grouponMinutes' + i).text(niceDateDiff[ 'minutes' ]);
jQuery('#grouponSeconds' + i).text(niceDateDiff[ 'seconds' ]);
}, 1000);
}
function displayGrouponAd(APIKEY, size, location, color1, showpreloader, pid, aid, title) {
ASSETDOMAIN = 'http://www.groupon.com';
//CSSURL = new String();
//CSSURL = 'http://www.coolsavings.com/' + size + '.css';
//console.log(CSSURL);
//jQuery('HEAD').append('');
IMGURL = ASSETDOMAIN + '/images/groupon/widget/';
APIURL = 'http://api.groupon.com/v2/deals.json?client_id='+APIKEY+'&callback=?';
if (location.length) {
var latLon = location.split(',');
APIURL += '&lat=' + latLon[ 0 ];
APIURL += '&lng=' + latLon[ 1 ];
}
jQuery('
').insertAfter('#grouponAd');
sizeSplit = size.split('.');
if (showpreloader) {
jQuery('#grouponAdContainer').html('
Loading Groupon
');
}
jQuery.getJSON(APIURL, function(data) {
var i;
var d1 = new Date();
var theDate = data.deals[ 0 ].endAt;
var safeDateTime = theDate.split('T');
var safeDate = safeDateTime[ 0 ].replace(/-/g,"/");
var safeTime = safeDateTime[ 1 ].replace(/Z/g,"");
var d2 = new Date(safeDate + ' ' + safeTime);
for (i = 0; i < data.deals.length; i++) {
data.deals[ i ].price = data.deals[ i ].options[ 0 ].price.formattedAmount.replace(/\.\d+/, '');
data.deals[ i ].value = data.deals[ i ].options[ 0 ].value.formattedAmount.replace(/\.\d+/, '');
data.deals[ i ].discountAmount = data.deals[ i ].options[ 0 ].discount.formattedAmount.replace(/\.\d+/, '');
data.deals[ i ].discountPercent = data.deals[ i ].options[ 0 ].discountPercent;
}
jQuery('#grouponAdContainer').html('');
//adding code to not loop through to side-deal if there isnt one
if(data.deals[ 1 ]==undefined){var lE=1;}else{var lE=2;}
//and if the color doesnt have hashtag, we'll add one
if(color1.indexOf("#")<0){color1="#"+color1;}
//prepend CJ information to the clickthru
var cjprepend='http://www.anrdoezrs.net/click-'+pid+'-'+aid+'?url=';
switch (size) {
case 'groupon-deals':
for (i=0; i';
jQuery('#grouponAdContainer').append(grouponAd);
var cityDiv = '
Daily Deal: ' + data.deals[ i ].division.name + '
';
jQuery(thisDeal).append(cityDiv);
var titleDiv = '
' + data.deals[ i ].title.replace("&","and") + '
';
jQuery(thisDeal).append(titleDiv);
var imgDiv = '
';
jQuery(thisDeal).append(imgDiv);
if(lE==2){
if (i == 0) {
thisButtonID = 'grouponShowSide'
var otherDealDiv = '