// JavaScript Document




function popup(thefile)
{
   var w;
   var h;
   if (document.all || document.layers) {
      w = screen.availWidth;
      h = screen.availHeight;
   } else {
        w = 1024;
        h = 768;
    }
   var popW = 600, popH = 400;
   var leftPos = (w-popW)/2, topPos = (h-popH)/2;
   appString = "height=" + popH + "," + "width=" + popW + "," + "alwaysRaised=yes" + "," + "scrollbars=yes" + "," + "status=no" + "," + "toolbar= no" + "," + "resizable=yes"; //Set up the Dialogue window
   newWin = window.open(thefile, "Window1", appString); //Call the Window open 
   newWin.moveTo(leftPos,topPos);
   newWin.focus()
}

function popup_image(thefile)
{
   if (document.all || document.layers) {
      w = screen.availWidth;
      h = screen.availHeight;
   } else {
        w = 1024;
        h = 768;
    }
   var popW = 550, popH = 500;
   var leftPos = (w-popW)/2, topPos = (h-popH)/2;
   appString = "height=" + popH + "," + "width=" + popW + "," + "alwaysRaised=yes" + "," + "scrollbars=no" + "," + "status=no" + "," + "toolbar= no" + "," + "resizable=yes"; //Set up the Dialogue window
   newWin_IMAGE = window.open(thefile, "Window2", appString); //Call the Window open 
   newWin_IMAGE.moveTo(leftPos,topPos);
   newWin_IMAGE.focus()
}


function showthis(theimage)
{
   var w;
   var h;
   if (document.all || document.layers) {
      w = screen.availWidth;
      h = screen.availHeight;
   } else {
        w = 1024;
        h = 768;
    }
   var popW = 670, popH = 550;
   var leftPos = (w-popW)/2, topPos = (h-popH)/2;
   appString = "height=" + popH + "," + "width=" + popW + "," + "alwaysRaised=yes" + "," + "scrollbars=no" + "," + "status=no" + "," + "toolbar= no" + "," + "resizable=yes"; //Set up the Dialogue window
   newWin = window.open("image_view.htm?image=" + theimage, "Window1", appString); //Call the Window open 
   newWin.moveTo(leftPos,topPos);
}

function checkForm() {

    var theForm;
    theForm = document.contact;    
    var notfilledin = "";
    var msg = "";
    
    if (theForm.email.value=='')            { notfilledin += "\nEmail is blank"; }
    if (theForm.password1.value=='')        { notfilledin += "\n1st Password is blank"; }
    if (theForm.password2.value=='')        { notfilledin += "\n2nd Password is blank"; }

    if (theForm.password2.value != theForm.password1.value)
        { notfilledin += "\nPasswords Do Not Match"; }
        
    if (notfilledin != '') {
       msg = notfilledin;
      }
        
    if (msg=='')    
    {
        return true;        
    }
    else
    {
        alert("The action failed with the following reasons \n" + msg );
        return false;
    }

}

function swapImage(img) {
    document.getElementById('mainimage').src=img;
}

var xmlHttp;

function getModels(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getModels.php";
url=url+"?manufacturer="+str;
url=url+"&chris=test6";
xmlHttp.onreadystatechange=stateChangedModels;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChangedModels() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("modelList").innerHTML=xmlHttp.responseText;
}
}

function getMakes(str)
{ 
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getMakes.php";
url=url+"?region="+str;
url=url+"&chris=test19";
xmlHttp.onreadystatechange=stateChangedMakes;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChangedMakes() 
{ 
if (xmlHttp.readyState==4)
{ 
document.getElementById("makeList").innerHTML=xmlHttp.responseText;
}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

function zeroPad(num,count)
{
   var numZeropad = num + '';
   while(numZeropad.length < count) {
   numZeropad = "0" + numZeropad;
   }
   return numZeropad;
}

function getTheTimeChosen( until, currentTime ) {

   var dow = new Array('SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY');

   
   
   now = new Date(currentTime);
   //y2k = new Date("Jan 1 2055 14:00:00");
   thenDate = new Date(until);
   days = (thenDate - now) / 1000 / 60 / 60 / 24;
   daysRound = Math.floor(days);
   if (daysRound >= 1)
      {
         var dayThen = thenDate.getDay();
         var day = '<span class=\"red\">' + dow[dayThen] + '</span>' ;
         return (day);

      }
   else
      {
         hours = (thenDate - now) / 1000 / 60 / 60 - (24 * daysRound);
         hoursRound = Math.floor(hours);
         minutes = (thenDate - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
         minutesRound = Math.floor(minutes);
         seconds = (thenDate - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
         secondsRound = Math.round(seconds);
         
         if (days < 0 || (hours <1 && minutes <1 && seconds < 1) )
         {
            countdown = "Closed";
            countdown_value = "";
            
         }
         else
         {
            var countdown = ' H:<span class=\"red\">' + zeroPad(hoursRound,2) + '</span>&nbsp;&nbsp;'; 
            countdown += ' M:<span class=\"red\">' + zeroPad(minutesRound,2) + '</span>&nbsp;&nbsp;'; 
            countdown += ' S:<span class=\"red\">' + zeroPad(secondsRound,2) + '</span>  '; 
         }
                 
         return ( countdown );
      }
}




function updateChosenVehicle(ids)
{
   xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="closingtimewatch_new.php";
    url=url+"?ids="+ids;
    url=url+"&unique="+randomnumber;
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            var text = xmlHttp.responseText;
            
            var ids = text.split("**");
            for (j=0; j<ids.length; j++) {
                var d = ids[j];
                var details = d.split("!!");
                if (document.getElementById('count'+details[0]) && details !='') 
                {
                  
                  var sectionA =  "";
                  var sectionB =  "";
                  var countdown =  "";
                  
                  // is it still required
                  if (details[1]=='required')
                  {
                     var sectionA =  "querying";
                     var sectionB =  "querying";  
                     var countdown =  "";    
                  } 
                  // closed
                  else if (details[2]=='closed')
                  {
                     var sectionA =  "closed";
                     var sectionB =  "closed";  
                     var countdown =  "";    
                  }
                  else 
                  {
                     
                     if (details[4]!='')
                     {
                     
                       
                     
                        // closing time 
                        countdown = '<p class=\"countdowntimer\">ENDS:&nbsp;';
                        countdown += getTheTimeChosen(details[4], details[14]);
                        
                        countdown += '</p>';
                        document.getElementById('countdown'+details[0]).innerHTML= countdown;
                        
                     }else
                     {
                        document.getElementById('count'+details[0]).innerHTML= "Please Wait" ;   
                        document.getElementById('countdown'+details[0]).innerHTML= "Please Wait" ;   
                     }
                  }
                  
                  var contents = document.getElementById('count'+details[0]).innerHTML;
                  //var contents = contents.toLowerCase();
                  
                  
                  if (details[15] =='db' ||  !( contents.match("login") || (contents.match ('BID NOW') )  ) || contents.match ('wait') )
                  {
                    // open
                   
                     
                   
                     
                     // bid buttons
                     if (details[12]!='' && details[5]!='not logged in'){
                     
                           // start 
                           var button_start = parseInt(details[12]);

                           // wrapper
                           sectionB += "<div class='vehicle_item_bid_button_holder' ><div class='vehicle_item_bid_button_bid_label'>BID NOW:</div><div class='vehicle_item_bid_buttons'>";
                           
                    
                           // buttons
                           sectionB += '<span id=\"buttons_' + details[0] + '\">';
                           
                           // + 10 button           
                           var nextbid = button_start + 10;
                           sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid2('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                           
                            // + 10 button           
                           var nextbid = button_start + 20;
                           sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid2('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                          
                           // + 10 button           
                           var nextbid = button_start + 50;
                           sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid2('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                          
                           // + 10 button           
                           var nextbid = button_start + 100;
                           sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid2('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                          
                           
                           
                           // close wrapper
                           sectionB += "</span>";
                           
                           sectionB += "</div></div>";
                              // <input style='width: 140px;' type=\"button\" onclick='javascript:popup(\"bid.php?value=" + details[0] + "\")' value='BID OTHER AMOUNT' />
                     }
                     
                     
                     // winning
                     if (details[5]=="winning")
                     {
                        sectionA += "<p id=\"winning\">You are winning this auction</p>";
                        
                     }else if (details[5]=="not winning")
                     {
                        sectionA +=  "<p id=\"notwinning\">You are losing this auction</p>";
                     }else if (details[5]=="no bid")
                     {
                        sectionA +=  "";
                     }
                     else
                     {
                       sectionA +=  "Please login to place a bid";
                     }
                   
                   
                     // wrapper
                     sectionA += "<p id=\"highest\">";
                   
                     // highest bid
                     sectionA += "Highest Bid :&nbsp;<span class=\"red\">&pound;" + details[6] + (details[10]=='1' ? ' + VAT' : '') + "</span>";
                     
                     
                     // proxy
                     if (details[8] == 1) { sectionA += "<span class=\"higher\"><img src=\"images/site_images/proxy.jpg\" alt=\"A Higher Proxy Bid Exists\" title=\"A Higher Proxy Bid Exists\" /></span>";}
                    
                    
                     // view bids
                     sectionA += " &nbsp; <a href=\"javascript:popup('bids.php?value="+ details[0] +"')\">View Bids</a> &nbsp;"; 
                     
                     
                     // close wrapper
                     sectionA += "</p>";
                     
                     
                     // wrapper
                     sectionA += "<p id=\"yourmax\" >";
                     
                     // your max
                     if (details[11]!=0)
                     { 
                        if (details[5] =="winning")
                        {
                           sectionA += "Your Max Bid" + ': &pound;' + details[11]; 
                        }
                        else
                        {
                           sectionA += "Your Last Bid" + ': &pound;' + details[11]; 
                        }
                     }
                     
                     // reserve
                     
                      if (details[9] > 0) 
                      { 
                        if (details[6] >= details[9])
                        {
                           // is bidding above reserve?
                            sectionA += "<span id=\"reserve\">Reserve Met</span>";
                        }
                        else
                        {
                           // if nothing bid then report reserve not met
                            sectionA += "<span id=\"reserve\">Reserve Not Met</span>";
                        }
                      }else
                      {
                           // if nothing bid then report reserve not met
                           // sectionA += "<span id=\"reserve\">Reserve Not Met</span>";
                      }

                     // wrapper
                     sectionA += "</p>";
                   
                     //document.getElementById('count'+details[0]).innerHTML= sectionA + sectionB ;   
                     document.getElementById('count'+details[0]).innerHTML= sectionA + sectionB ;   
                   
                  }
                  
                  //sectionA = details[11];
                
                  //document.getElementById('count'+details[0]+'a').innerHTML=sectionA;
                  //document.getElementById('count'+details[0]+'b').innerHTML=sectionB;
                 
                } 
            }
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}


 



// ==============================================================================

function getTimeWatch( id ) {

   var dow = new Array('SUNDAY','MONDAY','TUESDAY','WEDNESDAY','THURSDAY','FRIDAY','SATURDAY');

   if (document.getElementById("time_"+id) && document.getElementById("countdown_"+id))
   {
   until = document.getElementById("time_"+id).value;
   
   var sys = document.getElementById('client_time').value;
   now = new Date(sys);
     
   //y2k = new Date("Jan 1 2055 14:00:00");
   thenDate = new Date(until);
   days = (thenDate - now) / 1000 / 60 / 60 / 24;
   
   // update in last few seconds
//   var diff = thenDate - now;  
//   secondsLeft = Math.round(diff/1000);
//   document.getElementById('debug').innerHTML= secondsLeft ;
//   
//   
//   if (secondsLeft == 15) { updateOctober(id); }   
//   if (secondsLeft == 10) { updateOctober(id); }   
//   if (secondsLeft == 5) { updateOctober(id); }   
//   if (secondsLeft == 2) { updateOctober(id); }   
//   if (secondsLeft == -2) { updateOctober(id); }  
   
   daysRound = Math.floor(days);
   if (daysRound >= 1)
      {
         var dayThen = thenDate.getDay();
         var countdown = '<p class=\"countdowntimer\"> ENDS:&nbsp; <span class=\"red\">' + dow[dayThen] + '</span></p>' ;
      }
   else
      {
         hours = (thenDate - now) / 1000 / 60 / 60 - (24 * daysRound);
         hoursRound = Math.floor(hours);
         minutes = (thenDate - now) / 1000 /60 - (24 * 60 * daysRound) - (60 * hoursRound);
         minutesRound = Math.floor(minutes);
         seconds = (thenDate - now) / 1000 - (24 * 60 * 60 * daysRound) - (60 * 60 * hoursRound) - (60 * minutesRound);
         secondsRound = Math.round(seconds);
         
         if (days < 0 || (hours <1 && minutes <1 && seconds < 1) )
         {
            countdown = "Closed";
            countdown_value = "";

         }
         else
         {
            var countdown = '<p class=\"countdowntimer\"> ENDS:&nbsp; H:<span class=\"red\">' + zeroPad(hoursRound,2) + '</span>&nbsp;&nbsp;'; 
            countdown += ' M:<span class=\"red\">' + zeroPad(minutesRound,2) + '</span>&nbsp;&nbsp;'; 
            countdown += ' S:<span class=\"red\">' + zeroPad(secondsRound,2) + '</span> </p> '; 
            
            countdown_value = "";
         }  
         
         //return ( countdown );
      }
      
      document.getElementById("countdown_"+id).innerHTML = countdown;  
   } 
   
     
   
}


 

function updateWatchList(ids)
{
   xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="closingtimewatch_new.php";
    url=url+"?ids="+ids;
    url=url+"&unique="+randomnumber;
    url=url+"&clear_cache=true";
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            var text = xmlHttp.responseText;
            
            var ids = text.split("**");
            for (j=0; j<ids.length; j++) {
                var d = ids[j];
                var details = d.split("!!");
                if (document.getElementById('count'+details[0]+'a')) 
                {
                  
                  var sectionA =  "";
                  var sectionB =  "";
                  
                  // is it still required
                  if (details[1]=='required')
                  {
                     var sectionA =  "querying";
                     var sectionB =  "querying";
                      
                  } 
                  // closed
                  if (details[2]=='closed')
                  {
                     var sectionA =  "closed";
                     var sectionB =  "closed";  
                    
                  }
                  else
                  {
                     
                     theDate = new Date(details[4]); 
                     
                     nowDate = new Date(details[14]); 
                     nowDate.getTime() +1000;
                     
                     if (theDate >= nowDate)
                     {
                     
                         // closing time 
                        countdown = '<div id="countdown_' + details[0] + '" >here</div>';
                        
   //                     countdown = '
   //                     countdown += getTime(d+'_time');
                        
   //                     countdown += '';
                        countdown += '<input type=\"hidden\" id=\"time_'+details[0]+'\" name="\time_"'+details[0]+'\" value="'+details[4]+'">'; 
                        document.getElementById('countdown'+details[0]).innerHTML= countdown;
                        
                        //alert(details[4]);
                        
                      
                        bolClosed = false;
                     
                     }else
                     {
                        countdown = "";
                          
                        bolClosed =true;
                     }
                     
                     
                  }
                  
                  getTimeWatch(details[0]);
                  
                  lastUpdate = new Date(details[14]);          
                  lastUpdateDisplay = zeroPad(lastUpdate.getHours(),2) + ":" + zeroPad(lastUpdate.getMinutes(),2) + ":" + zeroPad(lastUpdate.getSeconds(),2);
                  
                  set_new_time(details[14]);
                  
                  var contents = document.getElementById('count'+details[0]+'b').innerHTML;
                  if ( details[15] !='d' ||  !( contents.match("login") || (contents.match ('BID NOW') )  )|| contents.match ('wait') )
                  {
                    
                     // bid buttons
                     if (details[12]!=''){
                     
                           if (bolClosed==false)   
                           {
                     
                              // start 
                              var button_start = parseInt(details[12]);

                              // wrapper
                              sectionB += "<div class='vehicle_item_bid_button_holder' ><div class='vehicle_item_bid_button_bid_label'>BID NOW:</div><div class='vehicle_item_bid_buttons'>";
                              
                       
                              // buttons
                              sectionB += '<span id=\"buttons_' + details[0] + '\">';
                              
                              // + 10 button           
                              var nextbid = button_start + 10;
                              sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid3('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                              
                               // + 10 button           
                              var nextbid = button_start + 20;
                              sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid3('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                             
                              // + 10 button           
                              var nextbid = button_start + 50;
                              sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid3('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                             
                              // + 10 button           
                              var nextbid = button_start + 100;
                              sectionB += "<input type=\"button\" style=\"width: 70px;\" onclick=\"placeAjaxBid3('"+ details[0] + "','" + nextbid + "');\" value=\"&pound;" + nextbid +"\" />"; 
                             
                              
                             sectionB += "</div>";  
                              // close wrapper
                              sectionB += "</span>";
                            //  sectionB += "<input style='width: 140px;' type=\"button\" onclick='javascript:popup(\"bid.php?value=" + details[0] + "\")' value='BID OTHER AMOUNT' />";
                              sectionB += "<!--bid other start-->";
                              sectionB += "<div style='clear:both;'>";
                                 sectionB += "<div class='bid_other_textbox_wrapper_watch'>";
                                    sectionB += "<strong>&pound;&nbsp;</strong>";
                                    sectionB += "<input class='bid_other_textbox_watch' onkeypress=' if (event.keyCode== 13) { placeOtherBidWatch(" + details[0] + ",document.getElementById(\"bid_other" + details[0] + "\").value );  document.getElementById(\"bid_other" + details[0] + "\").value=\"Bid Other Amount\"; return false;}' type='text' value='Bid Other Amount' id='bid_other" + details[0] + "' name='bid_other" + details[0] + "' onclick=' if (document.getElementById(\"bid_other" + details[0] + "\").value==\"Bid Other Amount\") { document.getElementById(\"bid_other" + details[0] + "\").value=\"\" };' />";
                                 sectionB += "</div>";
                                 sectionB += "<div style=\"float:left;\">";
                                    sectionB += "<input type='image' name='bid_now' id='bid_now'  src='/images/site_images/GO-Button.jpg' onclick='placeOtherBidWatch(" + details[0] + ",document.getElementById(\"bid_other" + details[0] + "\").value );  document.getElementById(\"bid_other" + details[0] + "\").value=\"Bid Other Amount\"; return false;' />";
                                 sectionB += "</div>";
                                 sectionB += "<BR>";
                              sectionB += "</div>";
                              sectionB += "<!--bid other end -->";
                              sectionB += "</div></div>";
                              
                              sectionB += "<span style='font-size:0.7em'><span onclick=\"updateWatchList("+ details[0] + ");return(false);\" style='text-decoration:none;cursor:pointer;' ><span style='color:red;font-weight:bold;'>Click Here</span></span> to REFRESH last update: <span style='color:red;font-weight:bold;'>" + lastUpdateDisplay + "</span></span>";
                              
                              
                              // bid other amount button
                              //sectionB += "<div style='clear:both;'>";                              
//                                 sectionB += "<div style='float:left; padding-left:77px;'>";
//                                    sectionB += "<strong>&pound;</strong> ";
//                                    sectionB += "<input style='width: 120px;' type=\"text\" value='Bid Other Amount' id='bid_other"+ details[0] +"' name='bid_other"+ details[0] +"' onclick=' if (document.getElementById(\"bid_other"+ details[0] +"\").value==\"Bid Other Amount\") { document.getElementById(\"bid_other"+ details[0] +"\").value=\"\" };' />";
//                                 sectionB += "</div>";
//                                 sectionB += "<div style='float:left;'>";
//                                  sectionB += "<input type='image' name='bid_now' id='bid_now'  src='/images/site_images/GO-Button.jpg' onclick='placeOtherBidWatch("+ details[0] +",document.getElementById(\"bid_other"+ details[0] +"\").value );  document.getElementById(\"bid_other"+ details[0] +"\").value=\"Bid Other Amount\"; updateOctober("+ details[0] + "); return false;' />";
//                                  sectionB += "</div>";
//                              sectionB += "</div>";
                            
                              //sectionB += " <div style='clear:both'><BR></div>";
                                 
                                  
                              
                              
                           }
                           
                           // last update
                           
                           
                           

                     }
                     
                     
                     // winning
                     if (details[5]=="winning")
                     {
                        sectionA += "<p id=\"winning\" style=\"font-size:0.6em\" >You were winning this auction at " + lastUpdateDisplay + "</p>";
                        
                     }else if (details[5]=="not winning")
                     {
                        sectionA +=  "<p id=\"notwinning\"  style=\"font-size:0.6em\">You were losing this auction at " + lastUpdateDisplay + "</p>";
                     }else if (details[5]=="no bid")
                     {
                        sectionA +=  "";
                     }
                     else
                     {
                        sectionA +=  details[5];
                     }
                   
                   
                     // wrapper
                     sectionA += "<p id=\"highest\">";
                   
                     // highest bid
                     sectionA += "Highest Bid :&nbsp;<span class=\"red\">&pound;" + details[6] + (details[10]=='1' ? ' + VAT' : '') + "</span>";
                     
                     
                     // proxy
                     if (details[8] == 1) { sectionA += "<span class=\"higher\"><img src=\"images/site_images/proxy.jpg\" alt=\"A Higher Proxy Bid Exists\" title=\"A Higher Proxy Bid Exists\" /></span>";}
                    
                    
                     // view bids
                     sectionA += " &nbsp; <a href=\"javascript:popup('bids.php?value="+ details[0] +"')\">View Bids</a> &nbsp;"; 
                     
                     
                     // close wrapper
                     sectionA += "</p>";
                     
                     
                     // wrapper
                     sectionA += "<p id=\"yourmax\" >";
                     
                     // your max
                     if (details[11]!=0)
                     { 
                        if (details[5] =="winning")
                        {
                           sectionA += "Your Max Bid" + ': &pound;' + details[11]; 
                        }
                        else
                        {
                           sectionA += "Your Last Bid" + ': &pound;' + details[11]; 
                        }
                     }
                     
                     // reserve
                     
                      if (details[9] == -1) 
                      { 
                         // if no reserve                         
                         sectionA += "";
                      }
                      if (details[9] == 0)                       
                      {
                         sectionA += "<span id=\"reserve\">Reserve Not Met</span>";
                      }
                      if (details[9] == 1) 
                      {
                           // if nothing bid then report reserve not met
                           sectionA += "<span id=\"reserve\">Reserve Met</span>";
                      }

                     // wrapper
                     sectionA += "</p>";
                   
                     //sectionA = details[11];
                
                     document.getElementById('count'+details[0]+'a').innerHTML= sectionA;
                     //document.getElementById('count'+details[0]+'b').innerHTML= sectionB + details[15] + details[14] ;
                     document.getElementById('count'+details[0]+'b').innerHTML= sectionB  ;
                   
                  }
                  
                  
                  
               
                  
                }   
            }
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}

  

function updateSearch()
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="updateSearch.php";
    url=url+"?unique="+randomnumber;
    url=url+"&SpecialistAuction="+document.getElementById("SpecialistAuction").value;
    url=url+"&region="+document.getElementById("region").value;
    url=url+"&make="+document.getElementById("make").value;
    url=url+"&fueltype="+document.getElementById("fueltype").value;
    url=url+"&transmission="+document.getElementById("transmission").value;
    url=url+"&freetext="+document.getElementById("freetext").value;
    url=url+"&orderby="+document.getElementById("orderby").value;
    url=url+"&catcode="+document.getElementById("catcode").value;
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            document.getElementById('searchBoxes').innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
}



function updateTimeLeftSingle(id)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="closingtimesingle.php";
    url=url+"?ID="+id;
    url=url+"&unique="+randomnumber;
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            document.getElementById('timeleftsingle').innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    setTimeout("updateTimeLeftSingle("+id+")",1000);
}

function updateLiveBids(member,start)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="updatelivebids.php";
    url=url+"?member="+member;
    url=url+"&start="+start;
    url=url+"&unique="+randomnumber;
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            document.getElementById('livebidsspan').innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    setTimeout("updateLiveBids("+member+","+start+")",1000);
}

function updateLiveBids2(member,start)
{
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="updatelivebids2.php";
    url=url+"?member="+member;
    url=url+"&start="+start;
    url=url+"&unique="+randomnumber;
    xmlHttp.onreadystatechange=function() { 
        if (xmlHttp.readyState==4)
        { 
            document.getElementById('livebidsspan').innerHTML=xmlHttp.responseText;
        }
    }
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);
    setTimeout("updateLiveBids2("+member+","+start+")",3000);
}

var xmlHttp2;

function placeAjaxBid(value, bid)
{
    document.getElementById('buttons_'+value).innerHTML='Please wait...';
    document.getElementById('bid_other_'+value).innerHTML='..';   
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="ajax_placebid.php";
    url=url+"?value="+value;
    url=url+"&bid="+bid;
    url=url+"&unique="+randomnumber;
    xmlHttp2.onreadystatechange=function() {
        if (xmlHttp2.readyState==4)
        {
         //   updateTimeLeft();
         
        }
    }
    
    xmlHttp2.open("GET",url,true);
    
    xmlHttp2.send(null);
}

function placeAjaxBid2(value, bid )
{
    document.getElementById('buttons_'+value).innerHTML='Please wait...';
    //document.getElementById('bid_other_'+value).innerHTML='..';
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="ajax_placebid2.php";
    url=url+"?value="+value;
    url=url+"&bid="+bid;
    
    url=url+"&unique="+randomnumber;
    xmlHttp2.onreadystatechange=function() {
        if (xmlHttp2.readyState==4)
        {
         //   updateTimeLeft();
         //document.getElementById('mpw').innerHTML=xmlHttp2.responseText; 
        }
    }
    xmlHttp2.open("GET",url,true);
    xmlHttp2.send(null);
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }


function placeOtherBid(value, bid )
{
    document.getElementById('buttons_'+value).innerHTML='Please wait...';
    //document.getElementById('bid_other_'+value).innerHTML='..';
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    
    if (!IsNumeric (bid))
    {
        alert("Your bid must be a number");
    }
    else
    {
    
       bid = parseInt(bid);
       
       if (bid%10 > 0)
       {
         alert("Your bid must be a multiple of 10");
         
       }
       else
       {
          if (bid > 0)
          {
             var randomnumber=Math.floor(Math.random()*10000000000);
             var url="ajax_placebid2.php";
             url=url+"?value="+value;
             url=url+"&bid="+bid;
             
             url=url+"&unique="+randomnumber;
             xmlHttp2.onreadystatechange=function() {
                 if (xmlHttp2.readyState==4)
                 {
                  //   updateTimeLeft();
                  //document.getElementById('mpw').innerHTML=xmlHttp2.responseText; 
                 }
             }
             xmlHttp2.open("GET",url,true);
             xmlHttp2.send(null);
          }
          else
          {
             alert ("Invalid Bid");
          }
       }
    }
    
}


function placeOtherBidWatch(value, bid )
{
    document.getElementById('buttons_'+value).innerHTML='Please wait...<BR>(or press refresh)';
    //document.getElementById('bid_other_'+value).innerHTML='..';
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    
     if (!IsNumeric (bid))
    {
        alert("Your bid must be a number");
    }
    else
    {
       bid = parseInt(bid);
       
       
       if (bid%10 > 0)
       {
         alert("Your bid must be a multiple of 10");
         
       }
       else
       {
          if (bid > 0)
          {
             var randomnumber=Math.floor(Math.random()*10000000000);
             var url="ajax_placebid2.php";
             url=url+"?value="+value;
             url=url+"&bid="+bid;
             
             url=url+"&unique="+randomnumber;
             xmlHttp2.onreadystatechange=function() {
                 if (xmlHttp2.readyState==4)
                 {
                  //   updateTimeLeft();
                  //document.getElementById('mpw').innerHTML=xmlHttp2.responseText; 
                 }
             }
             xmlHttp2.open("GET",url,true);
             xmlHttp2.send(null);
             
            
             
          }
          else
          {
             alert ("Invalid Bid");
          }
       }
    }
    
     setTimeout("check_if_waiting_watch("+value+")", 6000);
   
    setTimeout("check_if_waiting_watch("+value+")", 8000);
    
    setTimeout("check_if_waiting_watch("+value+")", 12000);
     
}




function placeAjaxBid3(value, bid )
{

   
    
    document.getElementById('buttons_'+value).innerHTML='Please wait...<BR>(or press refresh)';
    //document.getElementById('bid_other_'+value).innerHTML='..';
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="ajax_placebid2.php";
    url=url+"?value="+value;
    url=url+"&bid="+bid;
    
    url=url+"&unique="+randomnumber;
    xmlHttp2.onreadystatechange=function() {
        if (xmlHttp2.readyState==4)
        {
         //   updateTimeLeft();
         //document.getElementById('mpw').innerHTML=xmlHttp2.responseText; 
        }
    }
    xmlHttp2.open("GET",url,true);
    xmlHttp2.send(null);
    

    setTimeout("check_if_waiting_watch("+value+")", 2000);
   
    setTimeout("check_if_waiting_watch("+value+")", 8000);
    
    setTimeout("check_if_waiting_watch("+value+")", 12000);
    
    
}


function placeAjaxBid4(value, bid )
{

   
    
    document.getElementById('buttons_'+value).innerHTML='Please wait...<BR>(or press refresh)';
    //document.getElementById('bid_other_'+value).innerHTML='..';
    xmlHttp2=GetXmlHttpObject();
    if (xmlHttp2==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var randomnumber=Math.floor(Math.random()*10000000000);
    var url="ajax_placebid2.php";
    url=url+"?value="+value;
    url=url+"&bid="+bid;
    
    url=url+"&unique="+randomnumber;
    xmlHttp2.onreadystatechange=function() {
        if (xmlHttp2.readyState==4)
        {
         //   updateTimeLeft();
         //document.getElementById('mpw').innerHTML=xmlHttp2.responseText; 
        }
    }
    xmlHttp2.open("GET",url,true);
    xmlHttp2.send(null);
    

    setTimeout("check_if_waiting_list("+value+")", 2000);
    
    setTimeout("check_if_waiting_list("+value+")", 8000);
    
    setTimeout("check_if_waiting_list("+value+")", 12000);
    
    
}




function check_if_waiting_watch(value)
{
   if (document.getElementById('buttons_'+value))
   {
      if 
      (
         (document.getElementById('buttons_'+value).innerHTML == 'Please wait...<BR>(or press refresh)') ||
         (!document.getElementById('buttons_'+value).innerHTML) ||
         (document.getElementById('buttons_'+value).innerHTML == 'Please wait....')
       )
      {
      updateWatchList(value);
      }
   }
}

function check_if_waiting_list(value)
{
   if (document.getElementById('buttons_'+value))
   {
      if (document.getElementById('buttons_'+value).innerHTML == 'Please wait...<BR>(or press refresh)')
      {
      updateTimeLeftOctober(value);
      }
   }
}


function confirmDelete(item)
{
    return confirm("Are you sure you want to delete "+item+"?");
}

function showHideBids(vehicle_id, showhide) {
    
    var element = 'expand'+vehicle_id;
    var elementlabel = 'expandlink'+vehicle_id;
    var randomnumber=Math.floor(Math.random()*10000000000);
   
    if (document.getElementById(element).innerHTML=='') {
        xmlHttp=GetXmlHttpObject();
        if (xmlHttp==null)
          {
          alert ("Your browser does not support AJAX!");
          return;
          } 
        var url="getBids.php";
        url=url+"?vehicle_id="+vehicle_id;
        url=url+"&rand="+randomnumber;
        xmlHttp.onreadystatechange=function() {
            if (xmlHttp.readyState==4) {
               document.getElementById(element).innerHTML=xmlHttp.responseText;
            }
        }
        xmlHttp.open("GET",url,true);
        xmlHttp.send(null);
    } else {
        document.getElementById(element).innerHTML='';
    }

}

function confirmDelete(item)
{
    var agree = confirm("Are you sure you want to delete "+item+"?");
    if (agree) 
        return true;
    else 
        return false;
}


function confirmUnDelete(item)
{
    var agree = confirm("Are you sure you want to undelete "+item+"?");
    if (agree) 
        return true;
    else 
        return false;
}

function confirmHolding(item)
{
    var agree = confirm("Are you sure you want to move this item to the holding area?");
    if (agree) 
        return true;
    else 
        return false;
}

function confirmLive(item)
{
    var agree = confirm("Are you sure you want to move this item to the live auction?");
    if (agree) 
        return true;
    else 
        return false;
}


function set_sys_offset()
{

   current = new Date();
   
   if (document.getElementById('time_offset').value=='0')
   {
     document.getElementById('time_offset').value = current;   
   }
   
   var loaded =  new Date (document.getElementById('time_offset').value);
   var diff = (current - loaded)  ;
   var sys = new Date(document.getElementById('system_time').value);
   
   sys.setTime(sys.getTime() + diff)
   //var newTime = sys.setTime(now.getTime +diff * 10000);
   
   document.getElementById('client_time').value = sys;   
   //document.getElementById('diff').value = diff;  
   
}

function set_new_time( currentTime)
{
    document.getElementById('time_offset').value = 0;
    document.getElementById('system_time').value = currentTime;
}
