$(document).ready(function() {
fetchTimestamp = function() {
return parseInt($('#timezer').text());
};
var auctionUpdateTime = 10;
var isOctionEnded = 0;
if ($('#frequenzer')) auctionUpdateTime = parseInt($('#frequenzer').text());
auctionUpdateTime = auctionUpdateTime*1000;
var auctions = '';
$('.auction-product').each(function() {
var auctionId = $(this).attr('id');
var auctionTitle = $(this).attr('title');
var counter = $('#' + auctionId + ' .countdown');
if (counter) auctions = auctions + auctionId + '=' + auctionTitle + '&';	
});
var auction_status_url;
if ($('#closedup').length) auction_status_url = '../status.php?'+auctions+'cu=1&ms=';
else if ($('#scheduledup').length) auction_status_url = '../status.php?'+auctions+'fu=1&ms=';
else if ($('#seatup').length) auction_status_url = '../status.php?'+auctions+'su=1&ms=';
else if ($('#bidhis_screen').length) auction_status_url = '../status.php?'+auctions+'hi=1&hi_id='+$('#bidhis_screen').attr('title')+'&ms=';
else auction_status_url = '../status.php?'+auctions+'ms=';
setInterval(function() {
if (auctions) {
var auction_status_url_time = auction_status_url + new Date().getTime();
$.ajax({
url: auction_status_url_time,
dataType: 'json',
type: 'POST',
timeout: 900,
data: auctions,
success: function(data) {
$.each(data, function(i, item) {
var auctionEndTime = $('#' + item.Auction.element + ' .countdown').attr('title');
var auctionLatestBidder = $('#' + item.Auction.element + ' .bid-bidder').text();
var auctionCountdown = $('#' + item.Auction.element + ' .countdown');
var auctionClosesOn = $('#' + item.Auction.element + ' .closes-on');
if (document.getElementById('bidhis_screen') && item.LastBid.username != 'No bids yet' && item.Auction.id == $('#bidhis_screen').attr('title')) {
$('#bidhis_screen tbody tr').remove();
var rowCounter = 0;
$.each(item.Histories, function(n,tRow) {
if ($('#bidhis_screen p').text()) $('#bidhis_screen p').remove();
if (rowCounter == 0) var row = '<tr><td nowrap style=\'padding:3px 3px;font-weight:bolder;\'>' + tRow.Bid.created + '</td><td nowrap style=\'padding:3px 3px;font-weight:bolder;\'>' + tRow.User.username + '</td><td nowrap style=\'padding:3px 3px;font-weight:bolder;\'>' + tRow.Bid.description + '</td></tr>';
else var row = '<tr><td nowrap style=\'padding:3px 3px;\'>' + tRow.Bid.created + '</td><td nowrap style=\'padding:3px 3px;\'>' + tRow.User.username + '</td><td nowrap style=\'padding:3px 3px;\'>' + tRow.Bid.description + '</td></tr>';
$('#bidhis_screen tbody').append(row);
if (document.getElementById('stats_screen')) $('#stats_screen').html(item.Auction.biddersUsernameList);
rowCounter++;
});
}
if (auctionLatestBidder != item.LastBid.username) {
auctionCountdown.attr('title', item.Auction.end_time);
$('#' + item.Auction.element + ' .bid-bidder').html(item.LastBid.username);
$('#' + item.Auction.element + ' .bid-price').html(item.Auction.start_price);
$('#' + item.Auction.element + ' .bid-price2').html(item.Auction.start_price);
$('#' + item.Auction.element + ' .bid-price3').html(item.Auction.start_price);
auctionClosesOn.text(item.Auction.closes_on);
if (auctionLatestBidder!='No bids yet') $('#' + item.Auction.element + ' .bid-price').css('backgroundColor','#FD2B98');
if (auctionLatestBidder!='No bids yet') $('#' + item.Auction.element + ' .bid-price').css('backgroundColor','#FFF');
if (auctionLatestBidder!='No bids yet') $('#' + item.Auction.element + ' .bid-price2').css('backgroundColor','#FD2B98');
if (auctionLatestBidder!='No bids yet') $('#' + item.Auction.element + ' .bid-price2').css('backgroundColor','#FFF');
if (auctionLatestBidder!='No bids yet') $('#' + item.Auction.element + ' .bid-price, #' + item.Auction.element + ' .bid-price2').animate({ backgroundColor: '#FD2B98' }, 500).animate({backgroundColor: '#FFF'}, 1000);
}
$('#' + item.Auction.element + ' .bid-savings-percentage').html(item.Auction.savings.percentage);
$('#' + item.Auction.element + ' .bid-savings-price').html(item.Auction.savings.price);
if (item.Auction.peak_only==1 && item.Auction.isPeakNow==0) {
auctionCountdown.text('Paused');
$('#' + item.Auction.element + ' .nash-button a').hide();
$('#' + item.Auction.element + ' .nash-button p').remove();
if (item.Auction.time_left > 0 && item.Auction.closed == 0) $('#' + item.Auction.element + ' .nash-button').append('<p style=\'padding-bottom:10px;\'>Peak only auction</p>');
} else {
if ((item.Auction.end_time - item.Auction.serverTimestamp) > 0) {
auctionCountdown.text(item.Auction.end_time_string);
if (item.Auction.time_left <= 10) {
auctionCountdown.css('color','#FD2B98');
} else if ($('#scheduledup').length) {
$('#' + item.Auction.element + ' .countdown').html('Not started!');
} else {
auctionCountdown.css('color','#000000');
}
}
if ($('#' + item.Auction.element + ' .nash-button p').text()!="") {
$('#' + item.Auction.element + ' .nash-button a').show();
$('#' + item.Auction.element + ' .nash-button p').remove();
}
$('#' + item.Auction.element + ' .nash-button').append('<p style=\'padding-bottom:10px;\'>&nbsp;</p>');
}
if ((item.Auction.end_time - item.Auction.serverTimestamp) <= 0 || item.Auction.closed == 1) {
auctionCountdown.css('color','#000000');
auctionCountdown.text('Ended');
isOctionEnded = 1;
}
});
},
error: function (XMLHttpRequest,textStatus,errorThrown) {
$('.countdown').each(function() {
var current  = $(this).text();
var lastGoodCurrent;
if (current != 'Not started!' && current != 'Paused' && current != 'SEAT') {
var day_time = '';
var day = '';
var time = '';
if (current.indexOf('d') > 0) {
day_time = current.split(' ');
day = day_time[0];
time = day_time[1].split(':');
} else {
time = current.split(':');
}
var hour = parseInt(time[0]);
var minute = parseInt(time[1]);
var second = parseInt(time[2]);
if (second > 0) {
second = second - 1;
} else if (second == 0) {
if (minute > 0) {
second = 59;
minute = minute - 1;
}}
if (hour < 10) hour = '0' + hour;
if (minute < 10) minute = '0' + minute;
if (second < 10) second = '0' + second;
if (current == 'Ended') {
$(this).text('Ended');
} else if (isNaN(hour) || isNaN(minute) || isNaN(second)) {
$(this).text('Waiting...');
} else {
if (day != '') $(this).text(day + ' ' + hour + ':' + minute + ':' + second);
else $(this).text(hour + ':' + minute + ':' + second);
}
}
});
}
});
}}, auctionUpdateTime);
$('.nash-button-link').click(function() {
var auctionElement = 'tslice' + $(this).attr('title');
var bidButton = $('#' + auctionElement + ' .nash-button');
var bidMessage = $('#' + auctionElement + ' .nash-message');
bidButton.hide(1);
$.ajax({
url: $(this).attr('href') + '&' + new Date().getTime(),
dataType: 'json',
success: function(data) {
bidMessage.html(data.Auction.message).show(1).animate({opacity: 1.0}, 2000).hide(1);
bidButton.show(1);
}
});
return false;
});
$("#report tr:odd").addClass("odd");
$("#report tr:not(.odd)").hide();
$("#report tr:first-child").show();
$("#report tr.odd").click(function(){
$(this).next("tr").toggle();
});
});
function roll_over(img_name,img_src) {
document[img_name].src = img_src;
}
function submitForm() {
if (document.mainsearchform.s.value == ""||document.mainsearchform.s.value == "Search auctions...") return false;
else document.mainsearchform.submit();
}
function submitForm2() {
if (document.tmaticsform.bidfrom.value == ""||document.tmaticsform.bidto.value == ""||document.tmaticsform.nbbids.value == "") return false;
else document.tmaticsform.submit();
}
function checkAll(formId,cName,check) {
for (i = 0,n = formId.elements.length; i < n; i++) {
if (formId.elements[i].className.indexOf(cName) != -1) formId.elements[i].checked = check;
}}
if (document.layers) window.captureEvents(Event.MOUSEMOVE);
window.onMouseMove = resetTimer();
var tID = "";
function resetTimer() {
clearTimeout(tID);
tID = setTimeout('executeTimer()',1800000);
}
function executeTimer() {
location.href = "http://www.a6c.com/noactivity/index.php";
}
window.onload = pageInit;
function pageInit() {
tID = setTimeout('executeTimer()',1800000);
}
var str1 = "You have no more tenders in your account.";
var str2 = "You are top bidder already.";
var str3 = "Auction has ended.";
var str4 = "Auction has not started yet.";
var str5 = "This is a peak auction.";
var str6 = "Your bid was placed.";
var str7 = "Beginners can bid on Beginner Auctions only, until you won it.";
var str8 = "Beginners can bid on 1 auction at a time only, until you won it or the auction has ended.";
var str9 = "You can bid on 5 auctions only at the same time.";
var str10 = "You have no seat in this auction.";
var burl = "../index.php?page=auctionbid&id=";
function bidit(aid) {
http.open("GET",burl+aid,true);
http.onreadystatechange = bhandleHttpResponse;
http.send(null);
}
function bhandleHttpResponse() {
if (http.readyState==4) {
bresults = http.responseText;
if (bresults.search(str1) > -1) {
document.getElementById('leftTenders').innerHTML = "0";
alert('You have no more tenders in your account.');
window.location = "refill.html";
} else if (bresults.search(str2) > -1) {
alert('You are top bidder already.');
} else if (bresults.search(str3) > -1) {
alert('Auction has ended.');
window.location = "ended.html";
} else if (bresults.search(str4) > -1) {
alert('Auction has not started yet.');
} else if (bresults.search(str5) > -1) {
alert('This is a peak auction.');
} else if (bresults.search(str6) > -1) {
} else if (bresults.search(str7) > -1) {
alert('Beginners can bid on Beginner Auctions only, until you won it.');
window.location = "format-13-Beginner-auctions.html";
} else if (bresults.search(str8) > -1) {
alert('Beginners can bid on 1 auction at a time only, until you won it or the auction has ended.');
} else if (bresults.search(str9) > -1) {
alert('You can bid on 5 auctions only at the same time.');
} else if (bresults.search(str10) > -1) {
alert('You have no seat in this auction.');
}}}
var strLTP1 = "Our banner is missing from the provided web page!";
var strLTP2 = "Our banner is found on the provided web page!";
var urlLTP = "../check_linktopage.php?param=";
function updateLTP() { 
var nameLTP = document.getElementById("linktopageX").value; 
http.open("GET",urlLTP+escape(nameLTP),true); 
http.onreadystatechange = handleHttpResponseLTP; 
http.send(null); 
}
function handleHttpResponseLTP() { 
if (http.readyState==4) { 
resultsLTP = http.responseText;
if (resultsLTP.search(strLTP2) > -1) {
document.getElementById('displayer_linktopageX').innerHTML = "<font color=green><strong>Our banner is found on the provided web page!</strong></font>";
document.getElementById("linktobannerX").className = "puRPfields";
document.getElementById("linktobannerX").disabled = false;
} else {
alert('Our banner is missing from the provided web page!');
document.getElementById('displayer_linktopageX').innerHTML = "<font color=red><strong>Our banner is missing from the provided web page!</strong></font>";
document.getElementById('linktopageX').value = "";
document.getElementById("linktobannerX").className = "puRPfields disabled";
document.getElementById("landinglinkX").className = "puRPfields disabled";
document.getElementById("linktobannerX").disabled = true;
document.getElementById("landinglinkX").disabled = true;
}}}
function getHTTPObject() {
var xmlhttp;
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
}
catch (e) { xmlhttp = false; }
}
return xmlhttp;
}
var http = getHTTPObject();
