// JavaScript Document


  //StartCountDown("clock1","06/27/2010 12:33 PM -0400")
  //StartCountDown("clock2","06/27/2010 2:00 PM -0400")
  
  /*
  	Author:		Robert Hashemian (http://www.hashemian.com/)
  	Modified by:	Munsifali Rashid (http://www.munit.co.uk/)
  	Modified by:	Tilesh Khatri
  */
  
  function StartCountDown(myDiv,myTargetDate)
  {
    dthen= new Date(myTargetDate);
    dnow= new Date();
    ddiff		= new Date(dthen-dnow);
    gsecs		= Math.floor(ddiff.valueOf()/1000);
    CountBack(myDiv,gsecs);
  }
  
  function Calcage(secs, num1, num2)
  {
    s = ((Math.floor(secs/num1))%num2).toString();
    if (s.length < 2) 
    {	
      s = "0" + s;
    }
    return (s);
  }
  
  function CountBack(myDiv, secs)
  {
    var DisplayStr;
    //var DisplayFormat = "%%D%% Days %%H%%:%%M%%:%%S%%";
    var DisplayFormat = "<span class='result_clock_days'>%%D%%</span> <span class='result_clock_hours'>%%H%%</span> <span class='result_clock_minutes'>%%M%%</span> <span class='result_clock_seconds'>%%S%%</span>";
    var sdays= Calcage(secs,86400,100000);
	var shours= Calcage(secs,3600,24);
	var smin= Calcage(secs,60,60);
	var ssec= Calcage(secs,1,60);
	
	var ddays= sdays>0 ? sdays+" Days" : "";
	var dhours= shours>0 ? shours+"Hr" : "";
	var dmin= smin>0 ? smin+"m" : "";
	
	DisplayStr = DisplayFormat.replace(/%%D%%/g,	ddays);
    DisplayStr = DisplayStr.replace(/%%H%%/g,		dhours);
    DisplayStr = DisplayStr.replace(/%%M%%/g,		dmin);
    DisplayStr = DisplayStr.replace(/%%S%%/g,		ssec+"s");
    if(secs > 0)
    {	
      document.getElementById(myDiv).innerHTML = DisplayStr;
      setTimeout("CountBack('" + myDiv + "'," + (secs-1) + ");", 990);
    }
    else
    {
      document.getElementById(myDiv).innerHTML = "Auction Over";
    }
  }



