<script language="JavaScript1.2">
function caltime()
{
get_details('<?=$pids?>');
bid_history('<?=$pid?>');
}

function get_details(pids)
{ 
	url= "<?=_BASEURL_?>/ajax_home_detail.php";	
	check_detail(url,pids);	
}
function check_detail(strURL,pids) { //alert(pids);
    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) {
            updatepage(self.xmlHttpReq.responseText,pids);
        }
    }
    self.xmlHttpReq.send(getquery(pids));
}

function getquery(pids) {   
    qstr = 'pids=' + pids ;  	
	return qstr;
	
}

function updatepage(str,pids)
{ 

	document.getElementById("product_detail").innerHTML = str;
	  <? 
	   $parr = explode(",",$pids);
	   for($a=0; $a < count($parr)-1;$a++)
	   { ?>	  
	  document.getElementById("price_index_page_<?=$parr[$a]?>").innerHTML= document.frm.price_<?=$parr[$a]?>.value;	 
	  document.getElementById("winner_index_page_<?=$parr[$a]?>").innerHTML=document.frm.bider_<?=$parr[$a]?>.value;
	  
	 
	  if(<?=$parr[$a]?> == <?=$pid?> && document.frm.new_<?=$parr[$a]?>.value == '1')
	  {
		bid_history('<?=$pid?>');
	  }
	  
	  if(document.getElementById("current_price_<?=$parr[$a]?>"))
	   {
	   var pro_type=document.price_save_form.product_type.value;
	    if(pro_type!=1 && pro_type!=3)
		  {		 
	 var actual_price = document.price_save_form.actual_price.value;
	 var savings = actual_price-document.frm.price_<?=$parr[$a]?>.value;
	 var result = roundNumber(savings,2);
	 var percent = result*(100/actual_price);
	 var newpercent = roundNumber(percent,0); 
	 
	 document.getElementById("price_saving").innerHTML="<?=$currency_symbol_new?> " + result;
	 document.getElementById("current_price_<?=$parr[$a]?>").innerHTML="<?=$currency_symbol_new?> " + document.frm.price_<?=$parr[$a]?>.value;
	 document.getElementById("percent_save").innerHTML= newpercent + "%";
	      }
	   }
	 
	  if(document.frm.new_<?=$parr[$a]?>.value == '1')
	  {	 
	  document.getElementById("price_index_page_<?=$parr[$a]?>").style.background='#6bceff';	  
	  document.frm.new_<?=$parr[$a]?>.value='0';
	  }
	  else
	  {	  
	  document.getElementById("price_index_page_<?=$parr[$a]?>").style.background='';	 
	  }
	  
	   
	  if(document.frm.diff_<?=$parr[$a]?>.value >= 1)
	  {
	  document.getElementById("button_finished_index_page_<?=$parr[$a]?>").style.display='';
	  document.getElementById("counter_index_page_<?=$parr[$a]?>").innerHTML=calc_counter_from_time22(document.frm.diff_<?=$parr[$a]?>.value); 
	 

			 if(document.frm.diff_<?=$parr[$a]?>.value < 10 )
			   {
				if(document.getElementById("blinkdiv_<?=$parr[$a]?>"))
				 document.getElementById("blinkdiv_<?=$parr[$a]?>").style.display='';
			   }			  
			   else
			   {
			     if(document.getElementById("blinkdiv_<?=$parr[$a]?>"))
				 document.getElementById("blinkdiv_<?=$parr[$a]?>").style.display='none';
			   } 	
	 
	 
	  }
	  else
	  {
	  bid_ended(<?=$parr[$a]?>);
	  if(document.getElementById("blinkdiv_<?=$parr[$a]?>"))
	  document.getElementById("blinkdiv_<?=$parr[$a]?>").style.display='none';
	  
	  document.getElementById("winner_name").innerHTML=document.frm.bider_<?=$parr[$a]?>.value;
	  document.getElementById("counter_index_page_<?=$parr[$a]?>").style.display='none';
	  document.getElementById("close_bid").style.display='';
	  }
	  
	 <? } ?>
	
	
	start_looping();
		
}
function start_looping()
{
setTimeout("get_details('<?=$pids?>')",200);
}




function bid_history(pid)
{
hurl= "<?=_BASEURL_?>/ajax_bid_history.php";	
check_history(hurl,pid);

}


function check_history(hist_URL,pid) { //alert(pids);
    var histxmlHttpReq = false;
    var histself = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        histself.histxmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        histself.histxmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    histself.histxmlHttpReq.open('POST', hist_URL, true);
    histself.histxmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    histself.histxmlHttpReq.onreadystatechange = function() {
        if (histself.histxmlHttpReq.readyState == 4) {
            update_bid_history(histself.histxmlHttpReq.responseText);
        }
    }
    histself.histxmlHttpReq.send(getquery_history(pid));
}

function getquery_history(pid) {   
    hqstr = 'pid=' + pid ; 
	return hqstr;
	
}

function update_bid_history(hstr)
{ 
document.getElementById("stats_test").innerHTML = hstr;
}

function roundNumber(num, dec) {
	var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
	return result;
}


</script>