// JavaScript Document


function validate_form(thisform)
{
	with (thisform)
			{
			//alert("hello")
			
			
			var counter = 0;
			//alert(counter)
			for(var i=0; i < thisform.elements.length; i++) {
				var el_type = thisform.elements[i].type;
				//alert(el_type);
					if (el_type == 'checkbox') {
						
							if(thisform.elements[i].checked){
								//alert("found one");
								counter = counter +1;
								
														
								
								}
							}
					}
			//alert("counter =: " + counter);
			if( (counter) <= 0) {
				alert("You must check at least 1 record for updating before submitting the request");
				return false
			} else {
				//alert("You have checked: " + (counter) + "items to be updated")
				
					
					
					for(var i=0; i < thisform.elements.length; i++) {
					var el_type = thisform.elements[i].type;
					//alert(el_type);
					if (el_type == 'checkbox') {
						
							if(thisform.elements[i].checked){
								//alert("found one");
								counter = counter +1;
								var strTmp = thisform.elements[i].id
								var strId = strTmp.substring(4)
								//alert(strId)
								var locId = 'location_'+strId
								var datId = 'date_'+strId
								//alert(locId)
								//alert(datId)
								var newstr = document.getElementById(locId)
								var newstr2 = document.getElementById(datId)
								var strValue = newstr.value
								var strValue2 = newstr2.value
								//alert(strValue + ' and ' + strValue2)
								var strLength = strValue.length
								var strLength2 = strValue2.length
								if((strLength2 <= 0) || (strLength <=0)) 
									{
									
									
									alert("A date or location field is blank on line: " + strId + ".  Please correct this and resubmit.")
									return false
									
									
									} //ends the first strLength comparison 
								
														
								
								} //ends the if(thisform.elements[i].checked)
							} // ends t he if(el_type == 'checkbox')
						
					
					
					} // ends the last for loop
				
				
			
					
				} //should end the if (counter <=0) conditional
			
			} //ends the with statement
} //concludes the function

function validate_form_sa(thisform)
{
	with (thisform)
			{
			//alert("hello")
			
			
			var counter = 0;
			//alert(counter)
			for(var i=0; i < thisform.elements.length; i++) {
				var el_type = thisform.elements[i].type;
				//alert(el_type);
					if (el_type == 'checkbox') {
						
							if(thisform.elements[i].checked){
								//alert("found one");
								counter = counter +1;
								
														
								
								}
							}
					}
			//alert("counter =: " + counter);
			if( (counter) <= 0) {
				alert("You must check at least 1 record for updating before submitting the request");
				return false
			} else {
				//alert("You have checked: " + (counter) + "items to be updated")
				
					
					
					for(var i=0; i < thisform.elements.length; i++) {
					var el_type = thisform.elements[i].type;
					//alert(el_type);
					if (el_type == 'checkbox') {
						
							if(thisform.elements[i].checked){
								//alert("found one");
								counter = counter +1;
								var strTmp = thisform.elements[i].id
								var strId = strTmp.substring(4)
								//alert(strId)
								var locId = 'location_'+strId
								var datId = 'date_'+strId
								//alert(locId)
								//alert(datId)
								var newstr = document.getElementById(locId)
								var newstr2 = document.getElementById(datId)
								var strValue = newstr.value
								var strValue2 = newstr2.value
								//alert('strValue: '+strValue + ' and ' + strValue2)
								var strLength = strValue.length
								var strLength2 = strValue2.length
								if(strValue != 319)
								{
									//alert('yes');
									if((strLength2 <= 0) || (strLength <=0)) 
									{
									
									
									alert("A date or location field is blank on line: " + strId + ".  Please correct this and resubmit.")
									return false
									
									
									} //ends the first strLength comparison 
								
									
								}
								
														
								
								} //ends the if(thisform.elements[i].checked)
							} // ends t he if(el_type == 'checkbox')
						
					
					
					} // ends the last for loop
				
				
			
					
				} //should end the if (counter <=0) conditional
			
			} //ends the with statement
} 

function validate_check(check)
{	

					var strTmp = check.id
					var strId = strTmp.substring(4)
					//alert(strId)
					var locId = 'location_'+strId
					//alert(locId)
					var newstr = document.getElementById(locId)
					//alert(newstr.disabled)
					var tmpdateId = 'date_'+strId
					var tmpdatestr = document.getElementById(tmpdateId)
					var cboStatus = newstr.disabled
					var timeId = 'time_'+strId
					var newtimeId = document.getElementById(timeId)
					//alert(timeId);
					var sportsauthority = false
					if(newtimeId)
						{
					//		alert('true');
							var cboDelTimeStatus = newtimeId.disabled
							sportsauthority = true;
							
						}
					//var newtimeId = document.getElementById(timeId)
					//var newtimeIDStatus = newtimeId.disabled;
					//alert(newtimeId.disabled);
					
					var url_starting_point = window.location.href
					//alert(url_starting_point)
					var url_starting_point = url_starting_point.substr(30,8)
					//alert(url_starting_point)
	
	if(check.checked) 
	{
		 if (url_starting_point == 'delivery') 
		  {
			
			//alert(sportsauthority);
			//alert('equals');
			var deldateId = 'date_'+strId
			//alert(deldateId)
			var newstr_2 = document.getElementById(deldateId)
			//alert(newstr.disabled)
			var cboDelDateStatus = newstr_2.disabled
			if(cboDelDateStatus) 
			{
				newstr_2.disabled = false
				//alert(newstr_2.parentNode.name);
				newstr_2.parentNode.style.background = "#009900";
			}
			if( (sportsauthority = true) && cboDelTimeStatus) 
			{
				newtimeId.disabled = false
				//alert(newstr_2.parentNode.name);
				newtimeId.parentNode.style.background = "#009900";
			}
							  
		  }
							
		//var cboStatus = newstr.disabled
			if(cboStatus) 
			{
				 newstr.disabled = false
				 newstr.parentNode.style.background = "#009900";
				//alert(newstr.parentNode.name);
			}
		
				} else {
					//alert('not checked')
					//alert(check.id)
					//var strTmp = check.id
					//var strId = strTmp.substring(4)
					//alert(strId)
					//var locId = 'location_'+strId
					//alert(locId)
					//var newstr = document.getElementById(locId)
					//alert(newstr.disabled)
					//var cboStatus = newstr.disabled
									
						 if (url_starting_point == 'delivery')
						 {
							  
							  	//alert('equals -2nd try');
							  	var deldateId = 'date_'+strId
								//alert(deldateId)
								var newstr_2 = document.getElementById(deldateId)
								//alert(newstr_2.disabled)
								var cboDelDateStatus = newstr_2.disabled
								if(!cboDelDateStatus)
								{
									newstr_2.disabled = true
									newstr_2.parentNode.style.background = "#ffffff";
								}
								
								if(!cboStatus) 
								{
								newstr.disabled = true
						 		newstr.parentNode.style.background = "#ffffff";
								}
								//alert(sportsauthority);
								if( (sportsauthority = true) && !cboDelTimeStatus) 
								{
									newtimeId.disabled = true
									//alert(newstr_2.parentNode.name);
									newtimeId.parentNode.style.background = "#ffffff";
								}
							  
						  }
						
						
						
					
					
				}
	
	
}


function confirmTableCancel() {
	var url = window.location.href
	//alert(window.location.href)
	window.location.href = url;
}

function dropLotDropDown(tmp)
{
	//determine if the selected value is drop lot
	var value = tmp.value
	var name = tmp.name
	var strId = name.substring(8)
	//alert(strId);
	var dtime = 'time'+strId
	var ddate = 'date'+strId
	var lastfreeday = 'lfd'+strId
	//alert(dtime);
	var delTime = document.getElementById(dtime);
	var delDate = document.getElementById(ddate);
	var lfd = document.getElementById(lastfreeday);
	//alert($value);
	if(value == '319')
	{
		
		delDate.value == delDate.parentNode.previousSibling.innerText;
		//alert(delDate.value);
		delTime.disabled = true;
		delDate.disabled = true;
	//	alert(delDate.parentNode.previousSibling.innerText);
		
		
	} else {
		delTime.disabled = false;
		delDate.disabled = false;
	}
}

function saDate(val)
{
	alert(val);
	
}