var basepath = "http://www.hotbiet.de/";


function product_bid(pid)
{	
	url= basepath + "/ajax_p_bid.php";	
	http_product_bid(url,pid);		
}

function http_product_bid(strURL,pid) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('POST', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) 
		{ 
		   maxbidp = "maximumbid_" + pid; 
		   if(self.xmlHttpReq.responseText!=0)
		   document.getElementById(maxbidp).style.display='';
		   setTimeout("hide_max_bid(" + pid + ")",2000);
        }
    }
    self.xmlHttpReq.send(getbidstring(pid));
}

function getbidstring(pid)
{
	qstr = 'pid=' + pid + '&bid=bid' ;  // NOTE: no '?' before querystring  
	return qstr;
}


function hide_max_bid(pid)
{
	var maxbidp = "maximumbid_" + pid;
	 document.getElementById(maxbidp).style.display='none';
}

function bid_ended(pid)
{
	  countdiv="counter_index_page_" + pid;	
	  el = document.getElementById(countdiv);
		if (el) {
		
	       el.innerHTML ="Ended";
        }
	 biddiv="button_finished_index_page_" + pid;
	 document.getElementById(biddiv).style.display='none';
	
	url= basepath + "/ajax_bid_ended.php";	
	http_bid_ended(url,pid);
	 
}

function home_bid_ended(pid)
{
	  countdiv="morecounter_" + pid;	
	  el = document.getElementById(countdiv);
		if (el) {
		
	       el.innerHTML ="Ended";
        }
	url= basepath + "/ajax_bid_ended.php";	
	http_bid_ended(url,pid);
}

function http_bid_ended(strURL,pid) {
    var xmlHttpReq5 = false;
    var self5 = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self5.xmlHttpReq5 = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self5.xmlHttpReq5 = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self5.xmlHttpReq5.open('POST', strURL, true);
    self5.xmlHttpReq5.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self5.xmlHttpReq5.onreadystatechange = function() {
        if (self5.xmlHttpReq5.readyState == 4) 
		{ 
		//alert(self5.xmlHttpReq5.responseText);
        }
    }
    self5.xmlHttpReq5.send(getbidendstring22(pid));
}
function getbidendstring22(pid)
{ 
	qstr = 'pid=' + pid + '&end=end' ;  // NOTE: no '?' before querystring  
	return qstr;
	//alert(qstr);
}


function calc_counter_from_time22(diff) 
{
	
  if (diff > 0) {
    hours=Math.floor(diff / 3600)
    minutes=Math.floor((diff / 3600 - hours) * 60)
    seconds=Math.round((((diff / 3600 - hours) * 60) - minutes) * 60)
  } else {
    hours = 0;
    minutes = 0;
    seconds = 0;
  }
  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;
}

