var current_ad = 0;
var current_offer = 0;
var ad_on = 1;
var ad_off = 0;
var ad_queue = new Array();
var current_timer;
var in_transition = false;
var temp;
var time_to_show = 6000; // How long to show ads for
var target_id = 1;
var visitor_id = '91gIHZLGz6';
var ads_shown = new Array();
var offers_shown = new Array();
var mini_ads_count = 3; // 3 = number of ads to show
var mini_offers_count = 5;
var offer_width = 386;
// Offer variables
var offer_queue = new Array();
// Offer div
var offer_div = '
';
// Add click handler to our ad images
$(".ad_img").click( function() { show_offer(); } );
// Our show offer data
function show_offer()
{
current_offer = current_ad;
// Tell server we clicked on an ad
$.post("http://www.kilkenny.ab.ca/service/req", {url: 'http://www.theoneco.com/ad_engine/public_html/index.php/service/click_ad', post: 1, t_id: target_id, ip: '38.107.179.222', ad_id: ad_queue[current_ad].id, v_id: visitor_id});
Shadowbox.open({
content: offer_div,
player: "html",
height: 520,
width: offer_width + 50,
options: {onFinish: function() {
create_offers();
} }
});
}
function load_offers()
{
load_offer(current_offer);
var _next_offer = current_offer + 1;
if (_next_offer < ad_queue.length) load_offer(_next_offer);
var _prev_offer = current_offer - 1;
if (_prev_offer >= 0) load_offer(_prev_offer);
viewed_offer(current_offer);
$('#sb-player').animate({scrollLeft: (offer_width+50) * current_offer}, 'slow');
}
// Create our images inside of div
function create_offers()
{
for (var x = 0; x < ad_queue.length; x++) {
if (ad_queue[x].link.length > 5) $('#offer_div').append('
');
else $('#offer_div').append('
');
}
$('#offer_div').css('width', ((offer_width+50) * ad_queue.length));
load_offers();
}
// Tells the server we viewed the offer
function viewed_offer(id)
{
if (offers_shown[id] != true)
{
$.post("http://www.kilkenny.ab.ca/service/req", {url: 'http://www.theoneco.com/ad_engine/public_html/index.php/service/view_offer', post: 1, t_id: target_id, ip: '38.107.179.222', ad_id: ad_queue[id].id, v_id: visitor_id});
offers_shown[id] = true;
}
}
// Shows our next offer
function next_offer()
{
if (current_offer < ad_queue.length - 1) {
current_offer ++;
var _next_offer = current_offer + 1;
if (_next_offer < ad_queue.length) load_offer(_next_offer);
viewed_offer(current_offer);
$('#sb-player').animate({scrollLeft: (offer_width+50) * current_offer}, 'slow');
}
}
// Show previous offer
function prev_offer()
{
if (current_offer > 0) {
current_offer --;
var _prev_offer = current_offer - 1;
if (_prev_offer >= 0) load_offer(_prev_offer);
viewed_offer(current_offer);
$('#sb-player').animate({scrollLeft: (offer_width+50) * current_offer}, 'slow');
}
}
// Load a new offer
function load_offer(_id)
{
$('#_offer_' + _id).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[_id].l_img);
}
// Gets a new ad and places it into image that just transitioned out (not visible)
function show_new_ad(is_next)
{
if (is_next)
{
current_ad++;
if (current_ad > (ad_queue.length - 1)) current_ad = 0;
}
else
{
current_ad--;
if (current_ad < 0) current_ad = ad_queue.length - 1;
}
// Check if we have already displayed this ad, and if so do not post to server
if (ads_shown[current_ad] != true)
{
$.post("http://www.kilkenny.ab.ca/service/req", {url: 'http://www.theoneco.com/ad_engine/public_html/index.php/service/view_ad', post: 1, t_id: target_id, ip: '38.107.179.222', ad_id: ad_queue[current_ad].id, v_id: visitor_id});
ads_shown[current_ad] = true;
}
// Do special image loading for previous ad
if (! is_next)
{
$('#_ad_' + ad_on).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[current_ad].img);
}
// Fade out old ad, fade in new ad
$('#_ad_' + ad_off).attr('z-index', '3');
$('#_ad_' + ad_on).attr('z-index', '2');
$('#_ad_' + ad_off).fadeOut('slow');
$('#_ad_' + ad_on).fadeIn('slow');
in_transition = true;
setTimeout("load_new_ad(" + is_next + ")", 1100);
}
function load_new_ad(is_next)
{
// Just switches the ad that will faded in next
if (ad_on == 0)
{
ad_on = 1; ad_off = 0;
}
else
{
ad_on = 0; ad_off = 1;
}
// Setup our next ad
var temp_ad = current_ad + 1;
if (temp_ad > (ad_queue.length - 1)) temp_ad = 0;
$('#_ad_' + ad_on).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[temp_ad].img);
// Load new mini ads
temp_ad = current_ad;
for (var i=0; i < mini_ads_count; i++)
{
temp_ad += 1;
if (temp_ad > (ad_queue.length - 1)) temp_ad = 0;
$('#_mini_ad_' + i).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[temp_ad].img);
}
in_transition = false;
}
// Initial ad setup, fills in the images with two ads
function get_ads()
{
var ad_size = (235 / mini_ads_count);
// Create our mini ads first
/*for (var i=0; i < mini_ads_count; i++)
{
$('#mini_div').append('
');
}*/
// Get all of our ads
$.ajax({
type: "POST",
url: "http://www.kilkenny.ab.ca/service/req",
data: {url: 'http://www.theoneco.com/ad_engine/public_html/index.php/service/get_all_ads', post: 1, t_id:target_id, ip:'38.107.179.222', v_id: visitor_id},
dataType: 'json',
success: function(data) {
ad_queue = data;
current_ad = 0;
// Load shown ad
$('#_ad_' + ad_off).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[current_ad].img);
// Load hidden ad
$('#_ad_' + ad_on).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[current_ad + 1].img);
// Load mini ads
var temp_ad = current_ad;
for (var i=0; i < mini_ads_count; i++)
{
temp_ad += 1;
if (temp_ad > (ad_queue.length - 1)) temp_ad = 0;
$('#_mini_ad_' + i).attr('src', 'http://www.theoneco.com/ad_engine/public_html/' + ad_queue[temp_ad].img);
$('#_mini_ad_' + i).css({width: ad_size, height: ad_size});
}
// Tell the server that we saw the current ad
$.post("http://www.kilkenny.ab.ca/service/req", {url: 'http://www.theoneco.com/ad_engine/public_html/index.php/service/view_ad', post: 1, t_id: target_id, ip: '38.107.179.222', ad_id: ad_queue[current_ad].id, v_id: visitor_id});
ads_shown[current_ad] = true;
// Set our show new ad function up
current_timer = setInterval("show_new_ad(true)", time_to_show );
}} );
}
function pause_rotate()
{
clearInterval(current_timer);
}
function resume_rotate()
{
clearInterval(current_timer);
current_timer = setInterval("show_new_ad(true)", time_to_show);
}
function prev_ad()
{
if (! in_transition)
{
show_new_ad(false);
pause_rotate();
}
}
function next_ad()
{
if (! in_transition)
{
show_new_ad(true);
pause_rotate();
}
}
document.write('');
document.write('
');
document.write('
');
document.write('
![]()
![]()
');
get_ads();