
function checkUncheckAll(theElement) {
  var theForm = theElement.form, z = 0;
  for(z=0; z<theForm.length;z++){
    if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
      theForm[z].checked = theElement.checked;
    }
  }
}


function Validator(frmname)
{
  this.formobj=document.forms[frmname];
	if(!this.formobj)
	{
	  alert("BUG: couldnot get Form object "+frmname);
		return;
	}
	if(this.formobj.onsubmit)
	{
	 this.formobj.old_onsubmit = this.formobj.onsubmit;
	 this.formobj.onsubmit=null;
	}
	else
	{
	 this.formobj.old_onsubmit = null;
	}
	this.formobj.onsubmit=form_submit_handler;
	this.addValidation = add_validation;
	this.setAddnlValidationFunction=set_addnl_vfunction;
	this.clearAllValidations = clear_all_validations;
}
function set_addnl_vfunction(functionname)
{
  this.formobj.addnlvalidation = functionname;
}
function clear_all_validations()
{
	for(var itr=0;itr < this.formobj.elements.length;itr++)
	{
		this.formobj.elements[itr].validationset = null;
	}
}
function form_submit_handler()
{
	for(var itr=0;itr < this.elements.length;itr++)
	{
		if(this.elements[itr].validationset &&
	   !this.elements[itr].validationset.validate())
		{
		  return false;
		}
	}
	if(this.addnlvalidation)
	{
	  str =" var ret = "+this.addnlvalidation+"()";
	  eval(str);
    if(!ret) return ret;
	}
	return true;
}
function add_validation(itemname,descriptor,errstr)
{
  if(!this.formobj)
	{
	  alert("BUG: the form object is not set properly");
		return;
	}//if
	var itemobj = this.formobj[itemname];
  if(!itemobj)
	{
	  alert("BUG: Couldnot get the input object named: "+itemname);
		return;
	}
	if(!itemobj.validationset)
	{
	  itemobj.validationset = new ValidationSet(itemobj);
	}
  itemobj.validationset.add(descriptor,errstr);
}
function ValidationDesc(inputitem,desc,error)
{
  this.desc=desc;
	this.error=error;
	this.itemobj = inputitem;
	this.validate=vdesc_validate;
}
function vdesc_validate()
{
 if(!V2validateData(this.desc,this.itemobj,this.error))
 {
    this.itemobj.focus();
		return false;
 }
 return true;
}
function ValidationSet(inputitem)
{
    this.vSet=new Array();
	this.add= add_validationdesc;
	this.validate= vset_validate;
	this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
  this.vSet[this.vSet.length]=
	  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
	 {
	   if(!this.vSet[itr].validate())
		 {
		   return false;
		 }
	 }
	 return true;
}
function validateEmailv2(email)
{
// a very simple email validation checking.
// you can add more complex email checking if it helps
    if(email.length <= 0)
	{
	  return true;
	}
    var splitted = email.match("^(.+)@(.+)$");
    if(splitted == null) return false;
    if(splitted[1] != null )
    {
      var regexp_user=/^\"?[\w-_\.]*\"?$/;
      if(splitted[1].match(regexp_user) == null) return false;
    }
    if(splitted[2] != null)
    {
      var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
      if(splitted[2].match(regexp_domain) == null)
      {
	    var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
	    if(splitted[2].match(regexp_ip) == null) return false;
      }// if
      return true;
    }
return false;
}

function V2validateData(strValidateStr,objValue,strError)
{
    var epos = strValidateStr.search("=");
    var  command  = "";
    var  cmdvalue = "";
    if(epos >= 0)
    {
     command  = strValidateStr.substring(0,epos);
     cmdvalue = strValidateStr.substr(epos+1);
    }
    else
    {
     command = strValidateStr;
    }
    switch(command)
    {
        case "req":
        case "required":
         {
           if(eval(objValue.value.length) == 0)
           {
              if(!strError || strError.length ==0)
              {
                strError = objValue.name + " : Required Field";
              }//if
              alert(strError);
              return false;
           }//if
           break;
         }//case required
        case "maxlength":
        case "maxlen":
          {
             if(eval(objValue.value.length) >  eval(cmdvalue))
             {
               if(!strError || strError.length ==0)
               {
                 strError = objValue.name + " : "+cmdvalue+" characters maximum ";
               }//if
               alert(strError + "\n[Current length = " + objValue.value.length + " ]");
               return false;
             }//if
             break; 
          }//case maxlen 
        case "minlength": 
        case "minlen": 
           { 
             if(eval(objValue.value.length) <  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : " + cmdvalue + " characters minimum  "; 
               }//if               
               alert(strError + "\n[Current length = " + objValue.value.length + " ]"); 
               return false;                 
             }//if 
             break; 
            }//case minlen 
        case "alnum": 
        case "alphanumeric": 
           { 
              var charpos = objValue.value.search("[^A-Za-z0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
               if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alpha-numeric characters allowed "; 
                }//if 
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//case alphanumeric 
        case "num": 
        case "numeric": 
           { 
              var charpos = objValue.value.search("[^0-9]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only digits allowed "; 
                }//if               
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break;               
           }//numeric 
        case "alphabetic": 
        case "alpha":
           { 
              var charpos = objValue.value.search("[^A-Za-z]"); 
              if(objValue.value.length > 0 &&  charpos >= 0) 
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": Only alphabetic characters allowed "; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 
              break; 
           }//alpha 
		case "alnumhyphen":
			{
              var charpos = objValue.value.search("[^A-Za-z0-9\-_]"); 
              if(objValue.value.length > 0 &&  charpos >= 0)
              { 
                  if(!strError || strError.length ==0) 
                { 
                  strError = objValue.name+": characters allowed are A-Z,a-z,0-9,- and _"; 
                }//if                             
                alert(strError + "\n [Error character position " + eval(charpos+1)+"]"); 
                return false; 
              }//if 			
			break;
			}
        case "email":
          {
               if(!validateEmailv2(objValue.value))
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = objValue.name+": Enter a valid Email address "; 
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break; 
          }//case email
        case "banned":
          {
               var mailaddress = objValue.value;
               if(mailaddress == "mad4it@gmail.com" || mailaddress == "mad4it2@gmail.com")
               { 
                 if(!strError || strError.length ==0) 
                 { 
                    strError = "You have been banned.";
                 }//if                                               
                 alert(strError); 
                 return false; 
               }//if 
           break;
          }//case banned
        case "lt":
        case "lessthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
            if(eval(objValue.value) >=  eval(cmdvalue)) 
            { 
              if(!strError || strError.length ==0) 
              { 
                strError = objValue.name + " : value should be less than "+ cmdvalue; 
              }//if               
              alert(strError); 
              return false;                 
             }//if             
            break; 
         }//case lessthan 
        case "gt": 
        case "greaterthan": 
         { 
            if(isNaN(objValue.value)) 
            { 
              alert(objValue.name+": Should be a number "); 
              return false; 
            }//if 
             if(eval(objValue.value) <=  eval(cmdvalue)) 
             { 
               if(!strError || strError.length ==0) 
               { 
                 strError = objValue.name + " : value should be greater than "+ cmdvalue; 
               }//if               
               alert(strError); 
               return false;                 
             }//if             
            break; 
         }//case greaterthan 
        case "regexp": 
         { 
		 	if(objValue.value.length > 0)
			{
	            if(!objValue.value.match(cmdvalue)) 
	            { 
	              if(!strError || strError.length ==0) 
	              { 
	                strError = objValue.name+": Invalid characters found "; 
	              }//if                                                               
	              alert(strError); 
	              return false;                   
	            }//if 
			}
           break; 
         }//case regexp 
        case "checked":
         {
            if(objValue.checked == null)
            {
              alert("BUG: checked command for non-checkbox Item");
              return false;
            }
            if(!objValue.checked)
            {
             if(!strError || strError.length ==0)
              {
              strError = objValue.name+": Please check the box ";
              }//if
              alert(strError);
              return false;
             }
             break;
         }//case checked
         case "dontselect":
         {
            if(objValue.selectedIndex == null)
            {
              alert("BUG: dontselect command for non-select Item");
              return false;
            }
            if(objValue.selectedIndex == eval(cmdvalue))
            {
             if(!strError || strError.length ==0)
              {
              strError = objValue.name+": Please Select one option ";
              }//if
              alert(strError);
              return false;
             }
             break;
         }//case dontselect

    }//switch
    return true;
}


//
// Drop down lists dynamic control
//


function fillStartHourList(){
// Used to fill the list on page load
addOption(document.form1.hourStart1, "07:00", "7:00", "");
addOption(document.form1.hourStart1, "07:30", "7:30", "");
addOption(document.form1.hourStart1, "08:00", "8:00", "");
addOption(document.form1.hourStart1, "08:30", "8:30", "");
addOption(document.form1.hourStart1, "09:00", "9:00", "");
addOption(document.form1.hourStart1, "09:30", "9:30", "");
addOption(document.form1.hourStart1, "10:00", "10:00", "");
addOption(document.form1.hourStart1, "10:30", "10:30", "");
addOption(document.form1.hourStart1, "11:00", "11:00", "");
addOption(document.form1.hourStart1, "11:30", "11:30", "");
addOption(document.form1.hourStart1, "12:00", "12:00", "");
addOption(document.form1.hourStart1, "12:30", "12:30", "");
addOption(document.form1.hourStart1, "13:00", "13:00", "");
addOption(document.form1.hourStart1, "13:30", "13:30", "");
addOption(document.form1.hourStart1, "14:00", "14:00", "");
addOption(document.form1.hourStart1, "14:30", "14:30", "");
addOption(document.form1.hourStart1, "15:00", "15:00", "");
addOption(document.form1.hourStart1, "15:30", "15:30", "");
addOption(document.form1.hourStart1, "16:00", "16:00", "");
addOption(document.form1.hourStart1, "16:30", "16:30", "");
addOption(document.form1.hourStart1, "17:00", "17:00", "");
addOption(document.form1.hourStart1, "17:30", "17:30", "");
addOption(document.form1.hourStart1, "18:00", "18:00", "");
addOption(document.form1.hourStart1, "18:30", "18:30", "");
addOption(document.form1.hourStart1, "19:00", "19:00", "");
addOption(document.form1.hourStart1, "19:30", "19:30", "");
addOption(document.form1.hourStart1, "20:00", "20:00", "");
addOption(document.form1.hourStart1, "20:30", "20:30", "");
addOption(document.form1.hourStart1, "21:00", "21:00", "");
addOption(document.form1.hourStart1, "21:30", "21:30", "");

addOption(document.form1.hourStart2, "07:00", "7:00", "");
addOption(document.form1.hourStart2, "07:30", "7:30", "");
addOption(document.form1.hourStart2, "08:00", "8:00", "");
addOption(document.form1.hourStart2, "08:30", "8:30", "");
addOption(document.form1.hourStart2, "09:00", "9:00", "");
addOption(document.form1.hourStart2, "09:30", "9:30", "");
addOption(document.form1.hourStart2, "10:00", "10:00", "");
addOption(document.form1.hourStart2, "10:30", "10:30", "");
addOption(document.form1.hourStart2, "11:00", "11:00", "");
addOption(document.form1.hourStart2, "11:30", "11:30", "");
addOption(document.form1.hourStart2, "12:00", "12:00", "");
addOption(document.form1.hourStart2, "12:30", "12:30", "");
addOption(document.form1.hourStart2, "13:00", "13:00", "");
addOption(document.form1.hourStart2, "13:30", "13:30", "");
addOption(document.form1.hourStart2, "14:00", "14:00", "");
addOption(document.form1.hourStart2, "14:30", "14:30", "");
addOption(document.form1.hourStart2, "15:00", "15:00", "");
addOption(document.form1.hourStart2, "15:30", "15:30", "");
addOption(document.form1.hourStart2, "16:00", "16:00", "");
addOption(document.form1.hourStart2, "16:30", "16:30", "");
addOption(document.form1.hourStart2, "17:00", "17:00", "");
addOption(document.form1.hourStart2, "17:30", "17:30", "");
addOption(document.form1.hourStart2, "18:00", "18:00", "");
addOption(document.form1.hourStart2, "18:30", "18:30", "");
addOption(document.form1.hourStart2, "19:00", "19:00", "");
addOption(document.form1.hourStart2, "19:30", "19:30", "");
addOption(document.form1.hourStart2, "20:00", "20:00", "");
addOption(document.form1.hourStart2, "20:30", "20:30", "");
addOption(document.form1.hourStart2, "21:00", "21:00", "");
addOption(document.form1.hourStart2, "21:30", "21:30", "");

addOption(document.form1.hourStart3, "07:00", "7:00", "");
addOption(document.form1.hourStart3, "07:30", "7:30", "");
addOption(document.form1.hourStart3, "08:00", "8:00", "");
addOption(document.form1.hourStart3, "08:30", "8:30", "");
addOption(document.form1.hourStart3, "09:00", "9:00", "");
addOption(document.form1.hourStart3, "09:30", "9:30", "");
addOption(document.form1.hourStart3, "10:00", "10:00", "");
addOption(document.form1.hourStart3, "10:30", "10:30", "");
addOption(document.form1.hourStart3, "11:00", "11:00", "");
addOption(document.form1.hourStart3, "11:30", "11:30", "");
addOption(document.form1.hourStart3, "12:00", "12:00", "");
addOption(document.form1.hourStart3, "12:30", "12:30", "");
addOption(document.form1.hourStart3, "13:00", "13:00", "");
addOption(document.form1.hourStart3, "13:30", "13:30", "");
addOption(document.form1.hourStart3, "14:00", "14:00", "");
addOption(document.form1.hourStart3, "14:30", "14:30", "");
addOption(document.form1.hourStart3, "15:00", "15:00", "");
addOption(document.form1.hourStart3, "15:30", "15:30", "");
addOption(document.form1.hourStart3, "16:00", "16:00", "");
addOption(document.form1.hourStart3, "16:30", "16:30", "");
addOption(document.form1.hourStart3, "17:00", "17:00", "");
addOption(document.form1.hourStart3, "17:30", "17:30", "");
addOption(document.form1.hourStart3, "18:00", "18:00", "");
addOption(document.form1.hourStart3, "18:30", "18:30", "");
addOption(document.form1.hourStart3, "19:00", "19:00", "");
addOption(document.form1.hourStart3, "19:30", "19:30", "");
addOption(document.form1.hourStart3, "20:00", "20:00", "");
addOption(document.form1.hourStart3, "20:30", "20:30", "");
addOption(document.form1.hourStart3, "21:00", "21:00", "");
addOption(document.form1.hourStart3, "21:30", "21:30", "");

addOption(document.form1.hourStart4, "07:00", "7:00", "");
addOption(document.form1.hourStart4, "07:30", "7:30", "");
addOption(document.form1.hourStart4, "08:00", "8:00", "");
addOption(document.form1.hourStart4, "08:30", "8:30", "");
addOption(document.form1.hourStart4, "09:00", "9:00", "");
addOption(document.form1.hourStart4, "09:30", "9:30", "");
addOption(document.form1.hourStart4, "10:00", "10:00", "");
addOption(document.form1.hourStart4, "10:30", "10:30", "");
addOption(document.form1.hourStart4, "11:00", "11:00", "");
addOption(document.form1.hourStart4, "11:30", "11:30", "");
addOption(document.form1.hourStart4, "12:00", "12:00", "");
addOption(document.form1.hourStart4, "12:30", "12:30", "");
addOption(document.form1.hourStart4, "13:00", "13:00", "");
addOption(document.form1.hourStart4, "13:30", "13:30", "");
addOption(document.form1.hourStart4, "14:00", "14:00", "");
addOption(document.form1.hourStart4, "14:30", "14:30", "");
addOption(document.form1.hourStart4, "15:00", "15:00", "");
addOption(document.form1.hourStart4, "15:30", "15:30", "");
addOption(document.form1.hourStart4, "16:00", "16:00", "");
addOption(document.form1.hourStart4, "16:30", "16:30", "");
addOption(document.form1.hourStart4, "17:00", "17:00", "");
addOption(document.form1.hourStart4, "17:30", "17:30", "");
addOption(document.form1.hourStart4, "18:00", "18:00", "");
addOption(document.form1.hourStart4, "18:30", "18:30", "");
addOption(document.form1.hourStart4, "19:00", "19:00", "");
addOption(document.form1.hourStart4, "19:30", "19:30", "");
addOption(document.form1.hourStart4, "20:00", "20:00", "");
addOption(document.form1.hourStart4, "20:30", "20:30", "");
addOption(document.form1.hourStart4, "21:00", "21:00", "");
addOption(document.form1.hourStart4, "21:30", "21:30", "");

addOption(document.form1.hourStart5, "07:00", "7:00", "");
addOption(document.form1.hourStart5, "07:30", "7:30", "");
addOption(document.form1.hourStart5, "08:00", "8:00", "");
addOption(document.form1.hourStart5, "08:30", "8:30", "");
addOption(document.form1.hourStart5, "09:00", "9:00", "");
addOption(document.form1.hourStart5, "09:30", "9:30", "");
addOption(document.form1.hourStart5, "10:00", "10:00", "");
addOption(document.form1.hourStart5, "10:30", "10:30", "");
addOption(document.form1.hourStart5, "11:00", "11:00", "");
addOption(document.form1.hourStart5, "11:30", "11:30", "");
addOption(document.form1.hourStart5, "12:00", "12:00", "");
addOption(document.form1.hourStart5, "12:30", "12:30", "");
addOption(document.form1.hourStart5, "13:00", "13:00", "");
addOption(document.form1.hourStart5, "13:30", "13:30", "");
addOption(document.form1.hourStart5, "14:00", "14:00", "");
addOption(document.form1.hourStart5, "14:30", "14:30", "");
addOption(document.form1.hourStart5, "15:00", "15:00", "");
addOption(document.form1.hourStart5, "15:30", "15:30", "");
addOption(document.form1.hourStart5, "16:00", "16:00", "");
addOption(document.form1.hourStart5, "16:30", "16:30", "");
addOption(document.form1.hourStart5, "17:00", "17:00", "");
addOption(document.form1.hourStart5, "17:30", "17:30", "");
addOption(document.form1.hourStart5, "18:00", "18:00", "");
addOption(document.form1.hourStart5, "18:30", "18:30", "");
addOption(document.form1.hourStart5, "19:00", "19:00", "");
addOption(document.form1.hourStart5, "19:30", "19:30", "");
addOption(document.form1.hourStart5, "20:00", "20:00", "");
addOption(document.form1.hourStart5, "20:30", "20:30", "");
addOption(document.form1.hourStart5, "21:00", "21:00", "");
addOption(document.form1.hourStart5, "21:30", "21:30", "");

}

function FillEndHourList1(){
  // ON selection of category this function will work

  removeAllOptions(document.form1.hourEnd1);
  addOption(document.form1.hourEnd1, "", "Select slot end time...", "");

  var st1 = document.form1.hourStart1.value;

  var stHour = parseFloat(st1.substring(0,2));
  var stMin = parseFloat(st1.substring(3,5));

  var startTime = new Date();
  startTime.setHours(stHour);
  startTime.setMinutes(stMin);

  var endTime1 = new Date(); endTime1.setHours(stHour); endTime1.setMinutes(stMin+30);
  var endTime2 = new Date(); endTime2.setHours(stHour); endTime2.setMinutes(stMin+60);
  var endTime3 = new Date(); endTime3.setHours(stHour); endTime3.setMinutes(stMin+90);
  var endTime4 = new Date(); endTime4.setHours(stHour); endTime4.setMinutes(stMin+120);

  if  (endTime1.getMinutes() > 9) {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes();
  } else {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes() + "0";
  }

  if  (endTime2.getMinutes() > 9) {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes();
  } else {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes() + "0";
  }

  if  (endTime3.getMinutes() > 9) {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes();
  } else {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes() + "0";
  }

  if  (endTime4.getMinutes() > 9) {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes();
  } else {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes() + "0";
  }

  addOption(document.form1.hourEnd1, timeString1, timeString1);
  addOption(document.form1.hourEnd1, timeString2, timeString2);
  addOption(document.form1.hourEnd1, timeString3, timeString3);
  addOption(document.form1.hourEnd1, timeString4, timeString4);

}

function FillEndHourList2(){
  // ON selection of category this function will work

  removeAllOptions(document.form1.hourEnd2);
  addOption(document.form1.hourEnd2, "", "Select slot end time...", "");

  var st1 = document.form1.hourStart2.value;

  var stHour = parseFloat(st1.substring(0,2));
  var stMin = parseFloat(st1.substring(3,5));

  var startTime = new Date();
  startTime.setHours(stHour);
  startTime.setMinutes(stMin);

  var endTime1 = new Date(); endTime1.setHours(stHour); endTime1.setMinutes(stMin+30);
  var endTime2 = new Date(); endTime2.setHours(stHour); endTime2.setMinutes(stMin+60);
  var endTime3 = new Date(); endTime3.setHours(stHour); endTime3.setMinutes(stMin+90);
  var endTime4 = new Date(); endTime4.setHours(stHour); endTime4.setMinutes(stMin+120);

  if  (endTime1.getMinutes() > 9) {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes();
  } else {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes() + "0";
  }

  if  (endTime2.getMinutes() > 9) {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes();
  } else {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes() + "0";
  }

  if  (endTime3.getMinutes() > 9) {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes();
  } else {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes() + "0";
  }

  if  (endTime4.getMinutes() > 9) {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes();
  } else {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes() + "0";
  }

  addOption(document.form1.hourEnd2, timeString1, timeString1);
  addOption(document.form1.hourEnd2, timeString2, timeString2);
  addOption(document.form1.hourEnd2, timeString3, timeString3);
  addOption(document.form1.hourEnd2, timeString4, timeString4);

}

function FillEndHourList3(){
  // ON selection of category this function will work

  removeAllOptions(document.form1.hourEnd3);
  addOption(document.form1.hourEnd3, "", "Select slot end time...", "");

  var st1 = document.form1.hourStart3.value;

  var stHour = parseFloat(st1.substring(0,2));
  var stMin = parseFloat(st1.substring(3,5));

  var startTime = new Date();
  startTime.setHours(stHour);
  startTime.setMinutes(stMin);

  var endTime1 = new Date(); endTime1.setHours(stHour); endTime1.setMinutes(stMin+30);
  var endTime2 = new Date(); endTime2.setHours(stHour); endTime2.setMinutes(stMin+60);
  var endTime3 = new Date(); endTime3.setHours(stHour); endTime3.setMinutes(stMin+90);
  var endTime4 = new Date(); endTime4.setHours(stHour); endTime4.setMinutes(stMin+120);

  if  (endTime1.getMinutes() > 9) {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes();
  } else {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes() + "0";
  }

  if  (endTime2.getMinutes() > 9) {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes();
  } else {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes() + "0";
  }

  if  (endTime3.getMinutes() > 9) {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes();
  } else {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes() + "0";
  }

  if  (endTime4.getMinutes() > 9) {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes();
  } else {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes() + "0";
  }

  addOption(document.form1.hourEnd3, timeString1, timeString1);
  addOption(document.form1.hourEnd3, timeString2, timeString2);
  addOption(document.form1.hourEnd3, timeString3, timeString3);
  addOption(document.form1.hourEnd3, timeString4, timeString4);

}

function FillEndHourList4(){
  // ON selection of category this function will work

  removeAllOptions(document.form1.hourEnd4);
  addOption(document.form1.hourEnd4, "", "Select slot end time...", "");

  var st1 = document.form1.hourStart4.value;

  var stHour = parseFloat(st1.substring(0,2));
  var stMin = parseFloat(st1.substring(3,5));

  var startTime = new Date();
  startTime.setHours(stHour);
  startTime.setMinutes(stMin);

  var endTime1 = new Date(); endTime1.setHours(stHour); endTime1.setMinutes(stMin+30);
  var endTime2 = new Date(); endTime2.setHours(stHour); endTime2.setMinutes(stMin+60);
  var endTime3 = new Date(); endTime3.setHours(stHour); endTime3.setMinutes(stMin+90);
  var endTime4 = new Date(); endTime4.setHours(stHour); endTime4.setMinutes(stMin+120);

  if  (endTime1.getMinutes() > 9) {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes();
  } else {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes() + "0";
  }

  if  (endTime2.getMinutes() > 9) {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes();
  } else {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes() + "0";
  }

  if  (endTime3.getMinutes() > 9) {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes();
  } else {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes() + "0";
  }

  if  (endTime4.getMinutes() > 9) {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes();
  } else {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes() + "0";
  }

  addOption(document.form1.hourEnd4, timeString1, timeString1);
  addOption(document.form1.hourEnd4, timeString2, timeString2);
  addOption(document.form1.hourEnd4, timeString3, timeString3);
  addOption(document.form1.hourEnd4, timeString4, timeString4);

}

function FillEndHourList5(){
  // ON selection of category this function will work

  removeAllOptions(document.form1.hourEnd5);
  addOption(document.form1.hourEnd5, "", "Select slot end time...", "");

  var st1 = document.form1.hourStart5.value;

  var stHour = parseFloat(st1.substring(0,2));
  var stMin = parseFloat(st1.substring(3,5));

  var startTime = new Date();
  startTime.setHours(stHour);
  startTime.setMinutes(stMin);

  var endTime1 = new Date(); endTime1.setHours(stHour); endTime1.setMinutes(stMin+30);
  var endTime2 = new Date(); endTime2.setHours(stHour); endTime2.setMinutes(stMin+60);
  var endTime3 = new Date(); endTime3.setHours(stHour); endTime3.setMinutes(stMin+90);
  var endTime4 = new Date(); endTime4.setHours(stHour); endTime4.setMinutes(stMin+120);

  if  (endTime1.getMinutes() > 9) {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes();
  } else {
    timeString1 = endTime1.getHours() + ":" + endTime1.getMinutes() + "0";
  }

  if  (endTime2.getMinutes() > 9) {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes();
  } else {
    timeString2 = endTime2.getHours() + ":" + endTime2.getMinutes() + "0";
  }

  if  (endTime3.getMinutes() > 9) {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes();
  } else {
    timeString3 = endTime3.getHours() + ":" + endTime3.getMinutes() + "0";
  }

  if  (endTime4.getMinutes() > 9) {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes();
  } else {
    timeString4 = endTime4.getHours() + ":" + endTime4.getMinutes() + "0";
  }

  addOption(document.form1.hourEnd5, timeString1, timeString1);
  addOption(document.form1.hourEnd5, timeString2, timeString2);
  addOption(document.form1.hourEnd5, timeString3, timeString3);
  addOption(document.form1.hourEnd5, timeString4, timeString4);

}


function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}


function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}

