		
	function resetDate() {
	  var pickupdate; 
	  var returndate;
	  var nowdate;
	  var today = new Date();
	  var thisYear = y2k(today.getYear());
	  var thisMonth = (today.getUTCMonth() + 1);
	  var thisDay = today.getUTCDate(); 
	  var dayincrement = 0;
	  var intpkday = parseInt(document.form1.PKDAY.value);
	  var intpkmon = parseInt(document.form1.PKMON.value);	 
	  var intpkyr = parseInt(document.form1.PKYR.value);
	  var intretday = parseInt(document.form1.RETDAY.value);
	  var intretmon = parseInt(document.form1.RETMON.value);
	  var intretyr = parseInt(document.form1.RETYR.value);
	 
	 	  
	   // RETURN 31 DAYS
    if (intpkmon==1 || intpkmon==3 || intpkmon==5 || intpkmon==7 || intpkmon==8 ||
        intpkmon==10 || intpkmon==12)  {
        days=31;
		
		
			if(intpkday == 31) {	
				
				
					if (intpkmon == 12) {
				
						if (document.form1.RETYR.value == thisYear + 2){
														
						}else if (document.form1.RETYR.value <= thisYear + 2){
							//document.form1.RETYR.value = intretyr + 1;
							document.form1.RETMON.selectedIndex = 0
							document.form1.RETDAY.selectedIndex = 0	
							
						}
								
					}else if(intpkmon != 12){
						
						if ((intpkyr == intretyr) && (intpkmon == intretmon)){
							document.form1.RETMON.selectedIndex = intpkmon
							document.form1.RETDAY.selectedIndex = 0	
						}	
					}
		
					//document.form1.RETDAY.selectedIndex = 0	
					dayincrement = 1
		
			}
		
				
    }
    // RETURN 30 DAYS
    else if (intpkmon==4 || intpkmon==6 || intpkmon==9 || intpkmon==11) {
        days=30;
		if(intpkday == 30) {	
			
			if ((intpkyr == intretyr) && (intpkmon == intretmon)){
				document.form1.RETDAY.selectedIndex = 0 ;
				document.form1.RETMON.selectedIndex = intretmon 
			}	
			dayincrement = 1;
		
		}
   
    }
    // RETURN 28 DAYS
    else if (intpkmon == 2)  {
             days=28;
       if(intpkday == 28) {	
			
			if ((intpkyr == intretyr) && (intpkmon == intretmon)){
				document.form1.RETDAY.selectedIndex = 0 ;
				document.form1.RETMON.selectedIndex = intretmon 
			}	
			
			dayincrement = 1;
			}            
        }
      		     
	 nowdate = calcAbsDate(thisYear,thisMonth,thisDay);
	 pickupdate = calcAbsDate(document.form1.PKYR.value,document.form1.PKMON.value,document.form1.PKDAY.value);
	 returndate = calcAbsDate(document.form1.RETYR.value,document.form1.RETMON.value,document.form1.RETDAY.value);
	  
		
	if(dayincrement == 0 ) { 
	 
			 if ((intpkday > 28 ) && (intpkmon == 2 )){
				//alert("28-1")
				document.form1.PKDAY.selectedIndex = 27;
						
					if ((intpkyr == intretyr) && (intpkmon == intretmon)){
						//alert("28-2")
						document.form1.RETDAY.selectedIndex = 0; 
						document.form1.RETMON.selectedIndex = intpkmon;
					}				
			}
			else if ((intpkday > 30) && (intpkmon==4 || intpkmon==6 || intpkmon==9 || intpkmon==11)){
				
				document.form1.PKDAY.selectedIndex = 29;
					
					if ((intpkyr == intretyr) && (intpkmon == intretmon)){				
						document.form1.RETDAY.selectedIndex = 0; 
						document.form1.RETMON.selectedIndex = intpkmon;
					}
				}
			 
			else if ((intpkday == 31) && (intpkmon==1 || intpkmon==3 || intpkmon==5 || intpkmon==7 || intpkmon==8 || 
					intpkmon==10 || intpkmon==12)){
					
					if ((intpkyr == intretyr) && (intpkmon == intretmon)){	
						document.form1.RETDAY.selectedIndex = 0; 
						document.form1.RETMON.selectedIndex = intpkmon;
					}	   
	}
	else {
		
			
			//if months are the same then the pickup day increments pickup + 1 
			if(intpkmon == intretmon) {	
				 document.form1.RETDAY.selectedIndex = intpkday;
				}	
						
		  }
	 	
	 		
	}
	
	
		//if pickup year greater than return -- set return equal 
		if(intpkyr > intretyr) {	
			 document.form1.RETYR.value = intpkyr;
			 
			
		}	
	
}
		
	
	function resetPickYrDate() {
	  var intpkyr = parseInt(document.form1.PKYR.value);
	  var intretyr = parseInt(document.form1.RETYR.value);
	
	//if pickup year greater than return -- set return equal 
		if(intpkyr > intretyr) {	
			 document.form1.RETYR.value = intpkyr;
			
		}	
	
	}
	
	
	function resetRetDayDate(){
	  var intpkmon = parseInt(document.form1.PKMON.value);	 
	  var intretmon = parseInt(document.form1.RETMON.value);
	  var intpkday = parseInt(document.form1.PKDAY.value);
	  var intretday = parseInt(document.form1.RETDAY.value);
	  	
			if (intpkmon == intretmon){
				if(intpkday > intretday) {	
					//document.form1.RETDAY.selectedIndex = intpkday - 1;
				}	 
			}			
		
	}
	
	
	function resetPickMonDate() {
	 
	  var intpkmon = parseInt(document.form1.PKMON.value);	 
	  var intretmon = parseInt(document.form1.RETMON.value);
	  var intpkday = parseInt(document.form1.PKDAY.value);
	  var intretday = parseInt(document.form1.RETDAY.value);
	  var intpkyr = parseInt(document.form1.PKYR.value);
	  var intretyr = parseInt(document.form1.RETYR.value);
	  var today = new Date();
	  var thisMonth = (today.getUTCMonth() + 1);
	  var thisYear = y2k(today.getYear());	
			
			//increment ret/pick year if pick month is less than todays date
			if(thisYear >= 	intpkyr){		 
				if ((thisMonth > intpkmon)){
					document.form1.PKYR.value = intpkyr + 1;
					document.form1.RETYR.value = intpkyr + 1;
				
				}
			 }
			 
			 
			 // pick year and return year are same then increment to be same as pickup
			 if(intpkyr == intretyr) {	
					
					 if (intpkmon > intretmon){
							document.form1.RETMON.value = intpkmon;
					 }	
					 
			 }
			
			
			//if pickup month greater than return month -- set return equal 
			 if (intpkmon == intretmon){
			 
				document.form1.PKDAY.selectedIndex = 0; 
				//document.form1.RETDAY.selectedIndex = 1; 
			 }			
	
	}
	
	
	function resetRetMonDate() {
	 var intpkmon = parseInt(document.form1.PKMON.value);	 
	  var intretmon = parseInt(document.form1.RETMON.value);
	  var intpkday = parseInt(document.form1.PKDAY.value);
	  var intretday = parseInt(document.form1.RETDAY.value);
	  var intpkyr = parseInt(document.form1.PKYR.value);
	  var intretyr = parseInt(document.form1.RETYR.value);
		
		if(intpkmon > intretmon) {	
			//document.form1.RETMON.value = intpkmon;
			document.form1.RETYR.value = intpkyr + 1;
			
		}	
	
	}
	
	
	function setPickupLocation()
	{
	  document.form1.LOCATIONTYPE.value = "Pickup";
	  //document.form1.TimeType.value = "Pickup Time";
	}
	
	
	
		function open_pickup_cal(mypage, myname, w, h, scroll) {
				var winl = (screen.width - w) / 2;
				var wint = (screen.height - h) / 2;
				winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
				win = window.open(mypage, myname, winprops)
				if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}
		
		
		function open_return_cal(mypage, myname, w, h, scroll) {
				var winl = (screen.width - w) / 2;
				var wint = (screen.height - h) / 2;
				winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
				win = window.open(mypage, myname, winprops)
				if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}

		
		function help(mypage, myname, w, h, scroll, helpid){
					var winl = (screen.width - w) / 2;
					var wint = (screen.height - h) / 2;
					mypage = mypage + "?id=" + helpid
					winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
					win = window.open(mypage, myname, winprops)
					if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
		}

	
		
	function calcAbsDate(year, month, days)
	{
	  abs_year = parseInt(year)-1997;
	  abs_months = (abs_year*12+parseInt(month)-1);
	  abs_days = abs_months*31 + parseInt(days);
	  return (abs_days);
	}

	function setContinueStatus(vsStatus)
	{
	  document.form1.CONTINUE.value = vsStatus;
	}

	function y2k(number)
	{
	  return (number < 1000) ? number + 1900 : number;
	}
	
	function setPromotionCodeReadOnly()
	{
	  var formElement;
	  
	  formElement = document.form1.SENIORPROMO
	  if (formElement[0].checked == true)
	  {
	    
	    document.form1.PROMOCD.readonly = false
	    return true;
	    
	    
	  } else {
		
	    document.form1.PROMOCD.readonly = true	  
	    return false;
	  }
	}    


		
	
	function ErrorText()
	{
	  var lsBlueChip = document.form1.BLUECHIP.value;
	  var lengthOfBlueChip = lsBlueChip.length;
	  var formElement;
	  var pickupdate; 
	  var returndate;
	  var pickuptime;
	  var returntime;

	  pickupdate = calcAbsDate(document.form1.PKYR.value,document.form1.PKMON.value,document.form1.PKDAY.value);
	  returndate = calcAbsDate(document.form1.RETYR.value,document.form1.RETMON.value,document.form1.RETDAY.value);
	  pickuptime = document.form1.PKTM.value;
	  returntime = document.form1.RETTM.value;

	  with ( document.form1 ) {
	  
	  if (document.form1.CONTINUE.value == "Y")
	  {
	    if (PKLOC.value == "" && PKLOCCD.value == "")
	    {
	      alert("Error: Please enter a Pick Up Location or Code.")
	      document.form1.PKLOC.focus()
	      return false;
	    }


	    if (isNaN(lsBlueChip) && lengthOfBlueChip > 6)
	    {
	      alert("Error: Invalid Blue Chip#. Please re-enter Blue Chip#.")
	      document.form1.BLUECHIP.focus()
	      return false;
	    }
	    else if (lengthOfBlueChip > 10)
	    {
	      alert("Error: Invalid Blue Chip#. Please re-enter Blue Chip#.")  
	      document.form1.BLUECHIP.focus()
	      return false;
	    }

	    /*if (!(lsBlueChip == "") && BLUEPWD.value == "")
	    {
	      alert("Error: Please enter your Blue Chip Password.")
	      document.form1.BLUEPWD.focus()
	      return false;
	    }*/

	       
	   
	    formElement = SENIORPROMO
	    if (PROMOCD.value == "" && formElement[0].checked == true)
	    {
	      alert("Error: Please enter a Promotion Code.")
	      document.form1.PROMOCD.focus()
	      return false;
	    }

	    formElement = SENIORPROMO
	    if (!(PROMOCD.value == "") && (formElement[1].checked == true))
	    {
	      alert("Please select either the Senior Discount Indicator or enter a Promotion Code.")
	      document.form1.PROMOCD.focus()
	      return false;
	    }
	    
	        
	    
	    if ((returndate == pickupdate) && (returntime <= pickuptime))
	    {
	      alert("Return time should be LATER than the pickup time.")
	      document.form1.RETTM.focus()
	      return false;
	    }
	    
	  }
	  }
	  return true;
	}
