﻿
var _ct_counter_time = 0;
var _ct_force_update = 0;

var _index_counter_prices = new Object();

var _auction_status_resume = 4;
var _auction_status_future = 3;
var _auction_status_finished = 2;
var _auction_status_paused = 10;
var _auction_status_live = 1;

var _auction_resume_msg = "";

var _ms_diff = 0;

var _requested_aids = new Array();
var _requested_spec_aids = new Array();
var _request_counter_aids = true;
var _request_counter_spec_aids = true;

var _bid_running = 0;


var _last_action_div_displayed = 0;
var _last_action_div_displayed1 = 0;

var _wording_single_bid = 'Single bid';
var _wording_bid_agent = 'BidButler';

var bidRet = true;

var _index_counter_prices = new Object();
var _default_bid_increment = 1;


function _set_refreshed_auction() {
    _is_refreshed = 1;
}
var clock_id = 0;

new PeriodicalExecuter(refreshBid, 1);

function refreshBid() {

    new Ajax.Request("/Client/ClientResponse.aspx", {
        //new Ajax.Request("/Server/ServerTrip.aspx", {
        onSuccess: function(transport) {
            parse_counter_response_index(transport.responseText, 1)
            //alert("The response from the server is: " + transport.responseText);

        },
        onFailure: function(transport) {
            //alert("Oops, there's been an error. Contact to Varologic");
        }
    });
}

function parse_counter_response_index(transport, plain) {
    plain = 1;

    if (plain != undefined && plain != null && plain == 1) {
        counters = transport.split('#');
    } else {
        counters = transport.split('#');
    }



    for (cnt = 0; cnt <= counters.length; cnt++) {

        counter_data = counters[cnt].split(';');

        auction_id = counter_data[0];
        div_name_counter = 'counter_index_page_' + auction_id;
        div_price_name = 'price_index_page_' + auction_id;
        div_name_winner = 'winner_index_page_' + auction_id;
        div_button_name = 'button_index_page_' + auction_id;
        div_button_name_finished = 'button_finished_index_page_' + auction_id;
        div_button_name_resume = 'button_Resume_index_page_' + auction_id;
        div_Last_auction = 'last_actions_div_' + auction_id;
        div_name_counter_future = 'counter_future_page_' + auction_id;
        div_name_counter_spec = 'spec_countertime_' + auction_id;
        div_price_name_spec = 'spec_current_price_' + auction_id;
        div_name_winner_spec = 'spec_current_winner_' + auction_id;
        counter = counter_data[1].split('|');
        display_Response(counter_data, auction_id, div_name_counter, div_price_name, div_name_winner, div_button_name, div_button_name_finished, div_button_name_resume, div_Last_auction, div_name_counter_future, div_name_counter_spec, div_price_name_spec, div_name_winner_spec, counter);

        div_name_counter = 'pv_counter_index_page_' + auction_id;
        div_price_name = 'pv_price_index_page_' + auction_id;
        div_name_winner = 'pv_winner_index_page_' + auction_id;
        div_button_name = 'pv_button_index_page_' + auction_id;
        div_button_name_finished = 'pv_button_finished_index_page_' + auction_id;
        div_button_name_resume = 'pv_button_Resume_index_page_' + auction_id;
        div_name_counter_future = 'pv_counter_future_page_' + auction_id;
        div_name_counter_spec = 'pv_spec_countertime_' + auction_id;
        div_price_name_spec = 'pv_spec_current_price_' + auction_id;
        div_name_winner_spec = 'pv_spec_current_winner_' + auction_id;
        div_Last_auction = 'pv_last_actions_div_' + auction_id;
        display_Response(counter_data, auction_id, div_name_counter, div_price_name, div_name_winner, div_button_name, div_button_name_finished, div_button_name_resume, div_Last_auction, div_name_counter_future, div_name_counter_spec, div_price_name_spec, div_name_winner_spec, counter);

        div_name_counter = 'sa_counter_index_page_' + auction_id;
        div_price_name = 'sa_price_index_page_' + auction_id;
        div_name_winner = 'sa_winner_index_page_' + auction_id;
        div_button_name = 'sa_button_index_page_' + auction_id;
        div_button_name_finished = 'sa_button_finished_index_page_' + auction_id;
        div_button_name_resume = 'sa_button_Resume_index_page_' + auction_id;
        div_name_counter_future = 'sa_counter_future_page_' + auction_id;
        div_name_counter_spec = 'sa_spec_countertime_' + auction_id;
        div_price_name_spec = 'sa_spec_current_price_' + auction_id;
        div_name_winner_spec = 'sa_spec_current_winner_' + auction_id;
        div_Last_auction = 'sa_last_actions_div_' + auction_id;
        display_Response(counter_data, auction_id, div_name_counter, div_price_name, div_name_winner, div_button_name, div_button_name_finished, div_button_name_resume, div_Last_auction, div_name_counter_future, div_name_counter_spec, div_price_name_spec, div_name_winner_spec, counter);
    }
}


function display_Response(counter_data, auction_id, div_name_counter, div_price_name, div_name_winner, div_button_name, div_button_name_finished, div_button_name_resume, div_Last_auction, div_name_counter_future, div_name_counter_spec, div_price_name_spec, div_name_winner_spec, counter) {
    for (ii = 0; ii < counter.length; ii++) {
        data = counter[ii].split('=');

        if (data[0] == 'ct') {
            if (data[1] == '-') {
                _ct_time = '--:--:--';
            } else {
                _ct_time = calc_counter_from_time(data[1]);
            }
            if ($(div_name_counter)) {
                $(div_name_counter).style.display = 'block';
                $(div_name_counter).innerHTML = _ct_time;
                if (parseInt(data[1]) <= 10 && parseInt(data[1]) > 0) {
                    $(div_name_counter).style.color = '#DD0000';
                } else {
                    $(div_name_counter).style.color = '';
                }

                if ($(div_Last_auction)) {
                    if (parseInt(data[1]) <= 10 && parseInt(data[1]) > 0) {
                        if ($(div_Last_auction).style.display == 'none' && $(div_Last_auction).innerHTML != '/images/just-a-few-seconds-i.gif">') {
                            $(div_Last_auction).innerHTML = '<img src="/images/just-a-few-seconds-i.gif">';
                            $(div_Last_auction).style.display = '';
                        }
                    }
                    else {
                        if (_last_action_div_displayed == 0) {
                            $(div_Last_auction).style.display = 'none';
                        }
                    }
                }

            }
            if ($(div_name_counter_spec)) {
                $(div_name_counter_spec).innerHTML = _ct_time;
                if (parseInt(data[1]) <= 10 && parseInt(data[1]) > 0) {
                    $(div_name_counter_spec).style.color = '#DD0000';
                } else {
                    $(div_name_counter_spec).style.color = '';
                }
            }
        }
        else if (data[0] == 'cs') {
            if (data[1] == _auction_status_paused) {
                $(div_name_counter).innerHTML = 'Pause';
                $(div_Last_auction).style.display = 'none';
            }

            //            else if (data[1] == _auction_status_future) {
            //                $(div_Last_auction).style.display = 'none';
            //            }

            //            else if (data[1] == _auction_status_future) {
            //                $(div_Last_auction).style.display = 'none';
            //            }

            else if (data[1] == _auction_status_finished) {

                hidedisplay_show($(div_button_name_finished));
                hidedisplay_dis($(div_button_name));
                hidedisplay_dis($(div_button_name_resume));
                if ($(div_name_counter)) {
                    $(div_name_counter).innerHTML = 'Ended';
                }
                // $(div_Last_auction).style.display = 'none';
            }

            else if (data[1] == _auction_status_live) {

                // $(div_button_name).style.color = '#DD0000';
                //   alert($(div_button_name).style.color);
                hidedisplay_dis($(div_button_name_finished));
                hidedisplay_dis($(div_button_name_resume));
                hidedisplay_show($(div_button_name));

                //$(div_button_name).style="display:none;";
                //                $(div_button_name).style.overflow = 'visible';


                //                    if ($(div_name_counter)) {
                //                        $(div_name_counter).innerHTML = 'Ended';
                //                    }
            }

            else if (data[1] == _auction_status_future) {

                hidedisplay_show($(div_button_name_resume));
                hidedisplay_dis($(div_button_name));
                hidedisplay_dis($(div_button_name_finished));
            }

            else if (data[1] == _auction_status_resume) {
                hidedisplay_show($(div_button_name_resume));
                hidedisplay_dis($(div_button_name));
                hidedisplay_dis($(div_button_name_finished));
            }
        }
        else if (data[0] == 'cw' && data[1] != '') {

            if ($(div_name_counter) && $(div_name_winner).innerHTML != data[1]) {
                _last_action_div_displayed1 = 1;

            }
            el = $(div_name_winner);
            if (el) {
                el.innerHTML = data[1];
            }
            if ($(div_name_winner_spec)) {
                $(div_name_winner_spec).innerHTML = data[1];
            }
        }
        else if (data[0] == 'cm') {
            if (data[1] != '') {

                if ($(div_name_counter_future)) {
                    $(div_name_counter_future).innerHTML = data[1];
                }
                if ($(div_name_counter)) {
                    $(div_name_counter).innerHTML = '';
                }
            }
            else {
                if ($(div_name_counter_future)) {
                    $(div_name_counter_future).innerHTML = '';
                }
            }
        }
        else if (data[0] == 'cp') {

            if (data[1] == '---') {
                if ($(div_price_name)) {
                    $(div_price_name).innerHTML = data[1];
                }
            }
            else if ($(div_price_name)) {
                $(div_price_name).innerHTML = format_raw_to_price(data[1]);
            }

            if (_index_counter_prices[auction_id] == null || _index_counter_prices[auction_id] == '') {
                _index_counter_prices[auction_id] = data[1];
            }

            else {
                if (_index_counter_prices[auction_id] != data[1]) {
                    if ($(div_price_name)) {
                        new Effect.Highlight($(div_price_name), { duration: 1, startcolor: '#ff0000', endcolor: '#FFFFFF', restorecolor: '#FFFFFF' });
                    }
                    //_index_counter_prices[auction_id] = new Object();
                    _index_counter_prices[auction_id] = data[1];
                }
            }
        }
        else if (data[0] == 'lui') {
            if (_last_action_div_displayed1 == 1) {
                parse_last_update_info(data[1]);
                _last_action_div_displayed1 = 0;
            }
        }

    }
}


var _lui_running = '';
function parse_last_update_info(lui) {
    lui_data = lui.split('@');
    lui_out = '';
    lui_div = 'last_actions_div_' + auction_id;
    bid_increment = _default_bid_increment;

    if (lui_data.length == 4) {

        ////        if (lui_data[0] != null && lui_data[0] != undefined && lui_data[1] != null && lui_data[1] != undefined) {
        ////            if (lui_data[0] != 0 && lui_data[1] != 0) {
        ////                lui_out += lui_data[1] + ' ';
        ////                lui_out += _wording_single_bid;
        ////                if (lui_data[1] > 1) {
        ////                    lui_out += 's';
        ////                }
        ////                lui_out += ' + ' + format_raw_to_price(parseInt(bid_increment) * parseInt(lui_data[1]))
        ////                lui_out += ' + ' + calc_counter_from_time(lui_data[0]);
        ////                lui_out += '<br />';

        ////            }
        ////        }

        ////        if (lui_data[2] != null && lui_data[2] != undefined
        ////                && lui_data[3] != null && lui_data[3] != undefined) {
        ////            if (lui_data[2] != 0 && lui_data[3] != 0) {
        ////                lui_out += lui_data[3] + ' ';
        ////                lui_out += _wording_bid_agent;
        ////                lui_out += ' + ' + format_raw_to_price(parseInt(bid_increment) * parseInt(lui_data[3]))
        ////                lui_out += ' + ' + calc_counter_from_time(lui_data[2]);
        ////            }
        ////        }
    }



    if (lui_out != "") {

        el = $(lui_div);
        if (el) {
            if (_lui_running) {
                window.clearTimeout(_lui_running);
            }
            el.innerHTML = lui_out;
            _last_action_div_displayed = 1;
            new Effect.BlindDown(el);
            _lui_running = window.setTimeout('new Effect.BlindUp(\'' + lui_div + '\', {duration:1}); _last_action_div_displayed = 0', 4500);
        }
    }
}


function calc_counter_from_time(diff) {
    var hours;
    var minutes;
    var seconds;

    if (diff > 0) {
        hours = Math.floor(diff / 3600)

        minutes = Math.floor((diff / 3600 - hours) * 60)

        seconds = Math.round((((diff / 3600 - hours) * 60) - minutes) * 60)


        if (seconds == 60) {
            seconds = 0;
        }

        if (minutes < 10) {
            if (minutes < 0) {
                minutes = 0;
            }
            minutes = '0' + minutes;
        }
        if (seconds < 10) {
            if (seconds < 0) {
                seconds = 0;
            }
            seconds = '0' + seconds;
        }
        if (hours < 10) {
            if (hours < 0) {
                hours = 0;
            }
            hours = '0' + hours;
        }

        return hours + ":" + minutes + ":" + seconds;

    } else {

        hours = 0;
        minutes = 0;
        seconds = 0;

        return "Checking..";

    }


}


function format_raw_to_price(price) {
    //alert(price);
    delimiter = ".";
    currency = "&pound;";
    price = new String(price);
    price_length = price.length;
    if (price_length == 1) {
        return currency + "0.0" + price;
    } else if (price_length == 2) {
        return currency + "0." + price;
    } else {
        cent = price.substr((price_length - 2), 2);
        return currency + price.substr(0, (price_length - 2)) + delimiter + cent;
    }
}

function format_price_To_raw(price) {
    price = new String(price);
    price_length = price.length;
    if (price_length == 1) {
        return "0.0" + price;
    } else if (price_length == 2) {
        return "0." + price;
    } else {
        cent = price.substr((price_length - 2), 2);
        return price.substr(0, (price_length - 2)) + delimiter + cent;
    }
}

function hidedisplay_fade(div_id, only_show) {
    el = $(div_id);
    if (el) {
        if (el.style.display == "none") {
            if (only_show != 1) {
                el.style.display = "";
            }
            //      new Effect.BlindDown(div_id, {duration:.3});
        } else {
            //      new Effect.BlindUp(div_id);
            el.style.display = "none";
        }
    }
}



function hidedisplay_show(div_id) {
    el = $(div_id);
    if (el) {
        el.style.display = "block";
        //        alert(el.id.substring(0, 2));
        if (el.id.substring(0, 3) == "pv_") {
            el.style.height = "27px";
        }

        else if (el.id.substring(0, 3) == "sa_") {
            el.style.height = "32px";
        }
        
        else {

            el.style.height = "44px";
        }

    }
}

function hidedisplay_dis(div_id) {
    el = $(div_id);
    if (el) {
        el.style.display = "none";
        el.style.height = "0px";
    }
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) {
        document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2];
        if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") == -1) {
            LoadPng();
        }
    }



}

var _last_savings_update = 0;

function update_savings_details(auction_id, force_update, auction_type) {

    _last_savings_update = (new Date()).getTime();

    url = '/Server/SavingTrip.aspx?aid=' + auction_id + "&at=" + auction_type;
    new Ajax.Request(url, { onSuccess: function(transport) {
        parse_savings_detail(transport);
        //&& transport.responseText == 'NOMOREBID'
        //alert(transport.responseText);

    }
    });
}

function parse_savings_detail(transport) {
    result_array = transport.responseText.split("#");

    auction_id = result_array[2]
    auction_type = result_array[1]

    if (result_array[0] == "REACHWINNINGLIMIT") {
        if (auction_type == "sa") {
            el2 = $("sa_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("sa_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have reached the Auction Winning Limit. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/faq.aspx#WINLIMIT'> Click Here</a> </span> ";
        }

        else if (auction_type == "pv") {
            el2 = $("pv_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("pv_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have reached the Auction Winning Limit. <br /> <span style='color: #ffc8c7;'> For more information. </span> <br /> <a style='color: #ffffff;' href='/faq.aspx#WINLIMIT'> Click Here</a> </span> ";
        }

        else {

            el2 = $("fehlerfeld_" + auction_id);
            el2.style.display = 'block';

            el = $("bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have reached the Auction Winning Limit.  <br /> <span style='color: #ffc8c7;'> For more information.  </span> <br /> <a style='color: #ffffff;' href='/faq.aspx#WINLIMIT'> Click Here</a> </span> ";
        }
    }


    else if (result_array[0] == "HIGHESTBIDDER") {
        if (auction_type == "sa") {
            el2 = $("sa_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("sa_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You are the current highest Bidder. So you cannot bid now <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#HIGHBID'> Click Here</a> </span> ";
        }

        else if (auction_type == "pv") {
            el2 = $("pv_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("pv_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You are the current highest Bidder. So you cannot bid now <br /> <span style='color: #ffc8c7;'> For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#HIGHBID'> Click Here</a> </span> ";
        }

        else {

            el2 = $("fehlerfeld_" + auction_id);
            el2.style.display = 'block';

            el = $("bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You are the current highest Bidder. So you cannot bid now  <br /> <span style='color: #ffc8c7;'> For more information.  </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#HIGHBID'> Click Here</a> </span> ";
        }
    }

    else if (result_array[0] == "BEGINNER") {
        if (auction_type == "sa") {
            el2 = $("sa_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("sa_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>This auction is for begginer, you had already winner in past. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUCTBEG'> Click Here</a> </span> ";
        }

        else if (auction_type == "pv") {
            el2 = $("pv_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("pv_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>This auction is for begginer, you had already winner in past. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUCTBEG'> Click Here</a> </span> ";
        }

        else {

            el2 = $("fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>This auction is for begginer, you had already winner in past. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUCTBEG'> Click Here</a> </span> ";
            el = $("bid_error_div_" + auction_id);
        }
    }

    else if (result_array[0] == "ISRUNNINGAUTOBID") {
        if (auction_type == "sa") {
            el2 = $("sa_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("sa_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have already set auto bidding for this auction. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUTOBID'> Click Here</a> </span> ";
        }

        else if (auction_type == "pv") {
            el2 = $("pv_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("pv_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have already set auto bidding for this auction. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUTOBID'> Click Here</a> </span> ";
        }

        else {

            el2 = $("fehlerfeld_" + auction_id);
            el2.style.display = 'block';

            el = $("bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have already set auto bidding for this auction. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#AUTOBID'> Click Here</a> </span> ";
        }
    }


    else {



        if (auction_type == "sa") {
            el2 = $("sa_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("sa_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #ffc8c7;'>Your Bid Account is Zero</span><br />You need Like2Bid Credits to place a bid on an auction.<br /> <a href='/buyBids.aspx' style='color: #ffffff; font-weight: bold;'>Buy Bid Credits here</a>";
        }

        else if (auction_type == "pv") {
            el2 = $("pv_fehlerfeld_" + auction_id);
            el2.style.display = 'block';
            el = $("pv_bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #ffc8c7;'>Your Bid Account is Zero</span><br />You need Like2Bid Credits to place a bid on an auction.<br /> <a href='/buyBids.aspx' style='color: #ffffff; font-weight: bold;'>Buy Bid Credits here</a>";
        }

        else {

            el2 = $("fehlerfeld_" + auction_id);
            el2.style.display = 'block';

            el = $("bid_error_div_" + auction_id);
            el.innerHTML = "<span style='color: #ffc8c7;'>Your Bid Account is Zero</span><br />You need Like2Bid Credits to place a bid on an auction.<br /> <a href='/buyBids.aspx' style='color: #ffffff; font-weight: bold;'>Buy Bid Credits here</a>";
        }
    }
}

function Check_auction(auction_id, hdnauctMsg) {
    url = '/Server/SavingTrip.aspx?akey=' + auction_id;
    new Ajax.Request(url, { onSuccess:
        function(transport) {
            alert(document.getElementById(hdnauctMsg.id));
            autoBid_Msg(transport);
            document.getElementById(hdnauctMsg).value = "true";
            alert(document.getElementById(hdnauctMsg));

        }
    });


    //  return bidRet;
}

function autoBid_Msg(transport) {


    result_array = transport.responseText.split("#");


    if (result_array[0] == "REACHWINNINGLIMIT") {
        el2 = $("fehlermeldungbb");
        el2.style.display = 'block';
        el = $("bid_error_msg");
        el.innerHTML = "<span style='color: #000000; padding:10px; text-align:center'>You have reached the Auction Winning Limit. <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/faq.aspx#WINLIMIT'> Click Here</a> </span> ";
    }

    else if (result_array[0] == "ACCTZERO") {
        el2 = $("fehlermeldungbb");
        el2.style.display = 'block';
        el = $("bid_error_msg");
        el.innerHTML = "<span style='color: #ffc8c7;'>Your Bid Account is Zero</span><br />You need Like2Bid Credits to place a bid on an auction.<br /> <a href='/buyBids.aspx' style='color: #ffffff; font-weight: bold;'>Buy Bid Credits here</a>";

    }

    else if (result_array[0] == "AUCTNOTLIVE") {
        el2 = $("fehlermeldungbb");
        el2.style.display = 'block';
        el = $("bid_error_msg");
        el.innerHTML = "<span style='color: #ffc8c7;'>This auction is not live</span><br />You can set Auto Bidding is only live auctions <br /> <br /> <span style='color: #ffc8c7;'>  For more information. </span> <br /> <a style='color: #ffffff;' href='/Faq.aspx#WINLIMIT'> Click Here</a> </span>  ";

    }
    else {


    }

}



function place_reminder(auction_id, error_div) {

    if (auction_id != null && auction_id != '') {
        url = '/auction-reminder.aspx?aid=' + auction_id;
        window.location.href = url;
    }
}



function place_bid(auction_id, error_div, user_id, is_detail_page, auction_type) {

    _last_bid_placed = (new Date()).getTime();
    _bid_running = 1;
    if (user_id == undefined || user_id == null || user_id == '') {
        user_id = 0;
    }

    if (is_detail_page == undefined || is_detail_page == null || is_detail_page == '') {
        is_detail_page = 0;
    }

    if (auction_type == undefined || auction_type == null || auction_type == '') {
        auction_type = 'na';
    }


    // clean error div

    if (auction_type == "na") {
        el = $(error_div);
        el2 = $("fehlerfeld_" + auction_id);
        if (el2) {
            el2.style.display = "none";
        }
        if (el) {
            el.innerHTML = "";
        }
    }
    else if (auction_type == 'sa') {
        el = $(error_div);
        el2 = $("sa_fehlerfeld_" + auction_id);
        if (el2) {
            el2.style.display = "none";
        }
        if (el) {
            el.innerHTML = "";
        }

    }

    else if (auction_type == 'pv') {

        el = $(error_div);
        el2 = $("pv_fehlerfeld_" + auction_id);
        if (el2) {
            el2.style.display = "none";
        }
        if (el) {
            el.innerHTML = "";
        }

    }




    window.setTimeout("update_savings_details(" + auction_id + ",1,'" + auction_type + "')", 100);

    if (is_detail_page == 1) {
        _ct_force_update = 1;
        //do_counter_request(auction_id, user_id);
    }

}



if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent && navigator.userAgent.indexOf("Opera") == -1) {
    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    if (Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7) {
        document.writeln('<style type="text/css">img { visibility:hidden; } </style>');
        window.attachEvent("onload", LoadPng);
    }
}

function LoadPng() {

    var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
    var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5 && Number(rslt[1]) < 7);
    for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
        if (itsAllGood && img.src.match(/\.png$/i) != null) {
            var src = img.src;
            img.style.width = img.width + "px";
            img.style.height = img.height + "px";
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
            img.src = "/images/1px.gif";
        }
        img.style.visibility = "visible";
    }
}


function ShowSingleBidMsg(divId, msgId, divType) {

    document.getElementById(divId).style.display = 'block';
    if (divType == 'Single') {
        document.getElementById(msgId).innerHTML = '<b>No Autobidding Allow</b><br /><br />This auction have allow only single bidding click';
    }
    else if (divType == 'Begginer') {
        document.getElementById(msgId).innerHTML = '<b>No Bidding Allow</b><br /><br />This auction have allow only beginners';
    }
}

function HideSingleBidMsg(divId) {
    document.getElementById(divId).style.display = 'none';



}

