var basepath = "http://www.smart-bids.com";



var checkbid=1;







function product_bid(pid)



{	



	url= basepath + "/ajax_p_bid.php";	



	http_product_bid(url,pid);		



}







function http_product_bid(strURL,pid) { 



	



    if(checkbid==0)	



    return false;    



    



    checkbid=0;



    



    var bid_xmlHttpReq = false;



    var bid_self = this;



    // Mozilla/Safari



    if (window.XMLHttpRequest) {



        bid_self.bid_xmlHttpReq = new XMLHttpRequest();



    }



    // IE



    else if (window.ActiveXObject) {



        bid_self.bid_xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");



    }



    bid_self.bid_xmlHttpReq.open('POST', strURL, true);



    bid_self.bid_xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');



    bid_self.bid_xmlHttpReq.onreadystatechange = function() {



        if (bid_self.bid_xmlHttpReq.readyState == 4) 



		{ 



		 



		   checkbid=1;



		   maxbidp = "maximumbid_" + pid; 

		   

		   if(bid_self.bid_xmlHttpReq.responseText =="provend")



		   {



		   document.getElementById(maxbidp).style.display='';



		   document.getElementById(maxbidp).innerHTML='You have no provisions!'



		   setTimeout("hide_max_bid(" + pid + ")",1000);



		   }



		   if(bid_self.bid_xmlHttpReq.responseText =="nobid")



		   {



		   document.getElementById(maxbidp).style.display='';



		   document.getElementById(maxbidp).innerHTML='You have no bids!'



		   setTimeout("hide_max_bid(" + pid + ")",1000);



		   }



		    if(bid_self.bid_xmlHttpReq.responseText =="maxbid")



		   {



		   document.getElementById(maxbidp).style.display=''; 



		   document.getElementById(maxbidp).innerHTML='You are currently the winning bidder'



		   setTimeout("hide_max_bid(" + pid + ")",1000);



		   }



        }



    }



    bid_self.bid_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;



}








