function hideID(id) {
      //safe function to hide an element with a specified id
      if (document.getElementById) { // DOM3 = IE5, NS6
            document.getElementById(id).style.display = 'none';
      }
      else {
            if (document.layers) { // Netscape 4
                  document.id.display = 'none';
            }
            else { // IE 4
                  document.all.id.style.display = 'none';
            }
      }
}
 
function showID(id) {
      //safe function to show an element with a specified id
              
      if (document.getElementById) { // DOM3 = IE5, NS6
            document.getElementById(id).style.display = 'inline';
      }
      else {
            if (document.layers) { // Netscape 4
                  document.id.display = 'inline';
            }
            else { // IE 4
                  document.all.id.style.display = 'inline';
            }
      }
}
 
function ShowSearch(x, v, startindex, stopindex) {
      for(i=startindex;i<=stopindex;i++) hideID(v+""+i);
      showID(v+""+x);
}
 
function check(theElement) {
 
    if (theElement.checked)
    {
        index1= theElement.name.indexOf("SubProductCheckBox");
shortname=theElement.name.substring(index1);
        hidden = document.getElementById("Hidden"+theElement.name.substring(index1));
     
	 if (hidden != null)
	 {
        index1=hidden.value.indexOf(";");
 
        startDate = hidden.value.substring(0, index1-1);
        arrStartDate=startDate.split("T");
        dateStartDate = arrStartDate[0].split("-");
        timeStartDate = arrStartDate[1].split(":");
        sDate = new Date(dateStartDate[0], dateStartDate[1]-1, dateStartDate[2], timeStartDate[0], timeStartDate[1], timeStartDate[2]);
 
        endDate = hidden.value.substring(index1+1);
        arrEndDate=endDate.split("T");
        dateEndDate = arrEndDate[0].split("-");
        timeEndDate = arrEndDate[1].split(":");
        eDate = new Date(dateEndDate[0], dateEndDate[1]-1, dateEndDate[2], timeEndDate[0], timeEndDate[1], timeEndDate[2]);
  
        z=0;
        theForm = theElement.form;
        conflict=false;
        while (z != theForm.length)
        {
            if(theForm[z].type == 'hidden')
            { 
                if (theForm[z].name.indexOf('HiddenSubProductCheckBox') >= 0)
                {
                    if (!(theForm[z].name.indexOf(shortname)>=0 )) 
                    {
						//is this session checked? if not is no conflict!
						index1= theElement.id.indexOf("SubProductCheckBox");
						name2=theElement.id.substring(0,index1);
						name2 = theForm[z].id.replace("HiddenSubProductCheckBox", name2+"SubProductCheckBox");
						element2 = document.getElementById(name2);
     
						if (element2.checked==true)
						{
						    index1=theForm[z].value.indexOf(";");
 
		                    startDateTemp = theForm[z].value.substring(0, index1-1);
				            arrStartDateTemp=startDateTemp.split("T");
						    dateStartDateTemp = arrStartDateTemp[0].split("-");
		                    timeStartDateTemp = arrStartDateTemp[1].split(":");
				            sDateTemp = new Date(dateStartDateTemp[0], dateStartDateTemp[1]-1, dateStartDateTemp[2], timeStartDateTemp[0], timeStartDateTemp[1], timeStartDateTemp[2]);
 
                            //AWWA - Fit Item #1, Changed By: Mayank Shukla; Start Date: 21/04/09
                            var string = "", index2 = 0;
                            string = theForm[z].value.substring(index1+1);
                            index2 = string.value.indexOf(";");
                            endDateTemp = string.value.substring(0,index2-1);
                            //AWWA - Fit Item #1, Changed By: Mayank Shukla; End Date: 21/04/09
						    
		                    arrEndDateTemp=endDateTemp.split("T");
				            dateEndDateTemp = arrEndDateTemp[0].split("-");
						    timeEndDateTemp = arrEndDateTemp[1].split(":");
		                    eDateTemp = new Date(dateEndDateTemp[0], dateEndDateTemp[1]-1, dateEndDateTemp[2], timeEndDateTemp[0], timeEndDateTemp[1], timeEndDateTemp[2]);
 
							if (sDate<= eDateTemp) if (eDate> sDateTemp) { conflict = true; }
		                    if (sDateTemp<= eDate) if (eDateTemp> sDate) { conflict = true; }      
						}
                }}
            }
            z++;
        }
 
        if (conflict)
        {
            alert("A session has already been selected for the same Date and time please select a different session.");
            theElement.checked = false;
        }
 	 }

    }
}
 
