$(
function(){
	var auctionButtons = $(".auctionButton");
	
	auctionButtons.each(
	   function(intButtonIndex,objBtn){
	       var jThis = $(this);
	       jThis.click(
	           function(objEvent){	           	   
	           	   var auctionBids = $("input[id^='bidAmount_']");	           	   
	           	   auctionBids.each(
	           	      function(){
	           	      	    var bThis = $(this);
	           	      	    var fieldName = this.name;
					        var fieldVal = $(this).val();
					        var bidsValid = false;
					        if(fieldVal != ''){
					            $.get("/common/modules/winesearch/actIsBidValid.cfm?bidAmount="+fieldVal, 
					            function(data){
					               if(trim(data)=='false'){         
					                  $('#err_'+fieldName).html('Sorry, in order to process your bid, it must conform to the <a href="/bidincrement">bidding increments</a>');
					                  bidsValid = false;
					                  
					               }else{
					               	   bidsValid =true
					               }
					            });
					       }	
					       return bidsValid;				         
				       }
	          	   )      	   
	           }
	       )
	   }	
	)
 
}
)






function areBidsValid(){ 	
   var hasValues=false;
   var isSuccess=true;
        
  $("input[id^='bidAmount_']").each(function(i) {
	   
	   
   });   
}

/*
 * var fieldName = this.name;
       var fieldVal = $(this).val();
             
       if(fieldVal != ''){
            $.get("/common/modules/winesearch/actIsBidValid.cfm?bidAmount="+fieldVal, 
            function(data){
               if(trim(data)=='false'){         
                  $('#err_'+fieldName).html('Sorry, in order to process your bid, it must conform to the <a href="/bidincrement">bidding increments</a>');
               }
            });
       }  
 * 
 */


function jumpToLot(rUri){
	 var lotId = document.getElementById('lot_no').value;
    
    if(lotId==""){
        lotId=1;
    }
    
    window.location.href= "/auction-wine-detail/jump-to-lot/" + lotId
	/*var lotId = document.getElementById('lot_no').value;
	
	if(lotId==""){
		lotId=1;
	}
	var search = window.location.search;
	
	if(search.length > 0){
		search += "&start=" + lotId;
	}else{
		search="?start=" + lotId;
	}
	
    window.location.href= rUri + search; */
}
   


function submitBids(){
	areBidsValid();	
}


function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
    return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
    return stringToTrim.replace(/\s+$/,"");
}


