function hilite_div (divName) {
      $("#"+divName).effect("highlight", {"color":"red"}, 500);
  }
function getMints(dateTime) {
	   var mints = 0;
	   var spDate = '';
	   var spDay = '';
	   var spHour = '';
	   var spMint = '';
	   if (dateTime) {
	   spDate = dateTime.split(/ /);
	   if (dateTime.indexOf('day')!=-1) {
	   	spHour = spDate[2].split(/h/); 
		spMint = spDate[3].split(/m/);
	   	mints += parseInt(spDate[0]) * 60 * 24;
	   	mints += parseInt(spHour[0]) * 60;
		mints += parseInt(spMint[0]);
	   } else if (dateTime.indexOf('h')!=-1) {
	   	spHour = spDate[0].split(/h/); 
		spMint = spDate[1].split(/m/);
	   	mints += parseInt(spHour[0]) * 60;
		mints += parseInt(spMint[0]);   
	   } else if (dateTime.indexOf('m')!=-1) {
	   	spMint = spDate[1].split(/m/);
	   	mints += parseInt(spMint[0]);   
	   }
	  }
	  return mints; 
	} 
	function trimStr(sInString) {
  sInString = sInString.replace( /^\s+/g, "" );// strip leading
  return sInString.replace( /\s+$/g, "" );// strip trailing
}
String.prototype.stripHTML = function()
{
        var matchTag = /<(?:.|\s)*?>/g;
        return this.replace(matchTag, "");
};
function call_updater(auc_id) {
	 $.post("updateaucdetail.php",{auction_id:auc_id}, 
	  	function(xml) {
         
         addMessages(xml);
        }); 
		function addMessages(xml) {
            
			$("auctionitem",xml).each(function(id) {
			auctionitem = $("auctionitem",xml).get(id);
			auctionid = $("auctionid",auctionitem).text();
			bids = $("bids",auctionitem).text();
			currentbid = $("currentbid",auctionitem).text();
			endtime = $("endtime",auctionitem).text();
			aucstatus = $("status",auctionitem).text();
            aucstatus = aucstatus.replace(/%ST%/g,"<");
			aucstatus = aucstatus.replace(/%LT%/g,">");

			highestbidder = $("highestbidder",auctionitem).text();
			highestbidder = highestbidder.replace(/%ST%/g,"<");
            highestbidder = highestbidder.replace(/%LT%/g,">");
          
			if ($("#Current_Bid").html()!=currentbid){
				   $("#Current_Bid").html(currentbid);
				   hilite_div ("Current_Bid");
				}
				
			if ($("#Bids").html()!=bids){
				   $("#Bids").html(bids);
				   hilite_div("Bids");
				}	
			
			if ($("#End_Date").html()!=endtime){
				   if (getMints(endtime)>getMints($("#End_Date").html())) {
						hilite_div ("End_Date");
					}
					$("#End_Date").html(endtime);
				}
			
			if (trimStr($("#Status").html().stripHTML())!=trimStr(aucstatus.stripHTML())){
				   $("#Status").html(aucstatus);
				   hilite_div ("Status");
				}
				
			if (trimStr($("#Highest_Bidder").html().stripHTML())!=trimStr(highestbidder.stripHTML())){
				   $("#Highest_Bidder").html(highestbidder);
				   hilite_div ("Highest_Bidder");
				}	
				
			//alert($("currentbid",auctionitem).text());	
			 });
		  
		   } 
	   
  }
