//	External Java Script File
//	Do not edit.

//----------------Variables for the browser sniffering--------------------
  var agt=navigator.userAgent.toLowerCase();
  var is_major = parseInt(navigator.appVersion); 
  var is_minor = parseFloat(navigator.appVersion); 
  var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                  && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                  && (agt.indexOf('webtv')==-1)); 
	var is_ie   = (agt.indexOf("msie") != -1);
    
  var is_nav6up = (is_nav && (is_major >= 5));
  var is_ie5up  = (is_ie  && (is_major >= 4));



//--------------- Function to check if the field is empty -----------------------------------------
			function isEmpty(theField)
			{
				if(theField == null || theField == "")
				{
					return true;
				}
				return false;
			}

//--------------- Function to check the length of the Event Title ---------------------------------
			function validateTitle(str)
			{
				len = str.length;
				if(len > 80 ) 
				{
					alert("Please enter title less than 80 characters!");
					return true;
				}
				return false;
			}

//--------------- Function to validate the length of the Event Description  -----------------------
			function validateDescription(str)
			{
				len = str.length;
				if(len > 255)
				{
					alert("Please enter description less than 255 characters!");
					return true;
				}
				else
				{
					return false;
				}
			}

//--------------- Function to validate the length of the Event Location  --------------------------
			function validateLocation(str)
			{
				len = str.length;
				if(len > 255)
				{
					alert("Please enter location less than 255 characters!");
					return true;
				}
				else
				{
					return false;
				}
			}

//--------------- Function to validate the length of the URL -----------------------
			function validateURL(str)
			{
				len = str.length;
				if(len > 255)
				{
					alert("Please enter URL less than 255 characters!");
					return true;
				}
				else
				{
					return false;
				}
			}

//------------------ function to disable radio button choice for repeat event -------------------------------------------
			function disableRepeatRadio()
			{
				//document.forms.comform.allDays[1].checked = true;
				//Select the "For the following days" option
				document.forms.comform.allDays.value = 0;
			}

//------------------- function to disable check boxes for Repeat Event ------------------------------------------------
			function disableRepeatCheckBox()
			{
				document.forms.comform.Sun.checked = false;
				document.forms.comform.Mon.checked = false;
				document.forms.comform.Tue.checked = false;
				document.forms.comform.Wed.checked = false;
				document.forms.comform.Thu.checked = false;
				document.forms.comform.Fri.checked = false;
				document.forms.comform.Sat.checked = false;
			}

//--------------------function to enable all check boxes for Repeat Event--------------------------------------------------
			function chkAllDays()
			{
				var condition = !document.forms.comform.Sun.checked;
				document.forms.comform.Sun.checked = condition;
				document.forms.comform.Mon.checked = condition;
				document.forms.comform.Tue.checked = condition;
				document.forms.comform.Wed.checked = condition;
				document.forms.comform.Thu.checked = condition;
				document.forms.comform.Fri.checked = condition;
				document.forms.comform.Sat.checked = condition;
			}

//--------------- Function to select the proper radio option for the repeatation ------------------
			function unselectBtn()
			{
				if(document.forms.comform.radRepeat[0].checked)
				{
					document.forms.comform.radAlwaysUntil[0].checked = false;
					document.forms.comform.radAlwaysUntil[1].checked = false;
					document.forms.comform.txtRepeatCount.value="";
				}
			}

// ----------------- function to disable radio box selection for reminders when the chkbox is clicked ---------------------
			
			function disableRadio(num)
			{
			  var checkBoxNum;
			  eval("checkBoxNum = document.forms.comform.chkRemind" + num + ";");
			  checkBoxNum.checked = true;
			  document.forms.comform.radRemind.checked = false;
			  if(document.forms.comform.chkRemind1.checked == false && document.forms.comform.chkRemind2.checked  == false)//if no chk box is selected then select the radio box
			  {
				document.forms.comform.radRemind.checked = true;
			  }
			}

// ----------------- function to disable check box  selection for reminders when the radiobox is clicked ---------------------
			
			function disableCheckBox()
			{
				document.forms.comform.chkRemind1.checked = false;
				document.forms.comform.chkRemind2.checked = false;
			}

//--------------- Function to set flag  for Trigger 1------------------------------------------------------------
			function chkTrig()
			{
				trgflag1 = 1;
			}

//--------------- Function to set flag  for Trigger 2------------------------------------------------------------
			function chkMltTrig()
			{
				trgflag = 1;
			}

//--------------- Function to check whether addresee present or not in the address book --------------------------------
			function chkAddresee()
			{
				var indexAddress = document.forms.comform.remindAttendee.selectedIndex;
				if(indexAddress == -1)
				{
					alert("Please select address from the Address Book!");
				}
				else if(document.forms.comform.remindAttendee.length == 1 && document.forms.comform.remindAttendee.options[indexAddress].text == "No Addressee")
				{
					alert("No addresses present in the Address Book!");
					document.forms.comform.UI_AlarmAttendee.focus();
				}
				else
					setReminderEmailValues();
			}

//-------------- Function to get the email address from the address book to the email field ----------------------------

			function setReminderEmailValues()
			{
				var tmp_Uname,tmp_Uid,tmp_string,i,j,k;
				var sel_index = 0;
				var reminderEmail;
				var sel_invetees = new Array();
				k = 0;

//-------------- New code for multiple selection ----------------------------------
				for(i=0; i < document.forms.comform.remindAttendee.length; i++)
				{
					if(document.forms.comform.remindAttendee.options[i].selected == true)
					{
						sel_invetees[k] = i;
						k++;
					}
				}
				if(sel_invetees.length > 1)
				{
					var tmp_name,tmp_str,tmp_emlid,tmp_atndstr;
					for(i=0; i < sel_invetees.length; i++)
					{
						tmp_atndstr = document.forms.comform.UI_AlarmAttendee.value ;
						tmp_str = document.forms.comform.remindAttendee.options[sel_invetees[i]].text;
						tmp_emlid = tmp_str;

						if(tmp_atndstr.length == 0 || tmp_atndstr == "")
						{
							tmp_atndstr = tmp_emlid ;
						}
						else
						{
							tmp_atndstr = tmp_atndstr + "\n" + tmp_emlid ;
						}
						
						document.forms.comform.UI_AlarmAttendee.value = tmp_atndstr;
						tmp_str = "";
						tmp_emlid = "";
					}
				}
//-------------- End new code -----------------------------------------------------
				else
				{
					sel_index = document.forms.comform.remindAttendee.selectedIndex;
					tmp_string = document.forms.comform.remindAttendee.options[sel_index].text;
				
					if(tmp_string.length == 0 || tmp_string == "")
					{
						document.forms.comform.UI_AlarmAttendee.value = "";
					}
					
					tmp_Uid = tmp_string;

					reminderEmail = document.forms.comform.UI_AlarmAttendee.value;
					if(reminderEmail == "")				
						document.forms.comform.UI_AlarmAttendee.value = tmp_Uid;
					else
					{
						reminderEmail = reminderEmail + "\n" + tmp_Uid ;
						document.forms.comform.UI_AlarmAttendee.value = reminderEmail;
					}

				}
			}

//--------------- Function to check whether addresee present or not in the address book --------------------------------
			function chkInviteeAddresee()
			{
				var indexAddress = document.forms.comform.emailAttendee.selectedIndex;
				if(indexAddress == -1)
				{
					alert("Please select address from the Address Book!");
				}
				else if(document.forms.comform.emailAttendee.length == 1 && document.forms.comform.emailAttendee.options[indexAddress].text == "No Addressee")
				{
					alert("No addresses present in the Address Book!");
					document.forms.comform.UI_Attendee.focus();
				}
				else
					setEmailValues();
			}

//-------------------------- address book support for Attendees --------------------------

			function setEmailValues()
			{
				var tmp_Uname,tmp_Uid,tmp_string,i,j,k;
				var sel_index = 0;
				var reminderEmail;
				var sel_inveteeseml = new Array();
				k = 0;
//--------------- New code for multiple selection --------------------------
				for(i=0; i < document.forms.comform.emailAttendee.length; i++)
				{
					if(document.forms.comform.emailAttendee.options[i].selected == true)
					{
						sel_inveteeseml[k] = i;
						k++;
					}
				}
				if(sel_inveteeseml.length > 1)
				{
					var tmp_atname,tmp_atemlid,tmpat_str,tmp_atatndstr;
					for(i=0; i < sel_inveteeseml.length; i++)
					{
						tmp_atatndstr = document.forms.comform.UI_Attendee.value ;
						tmp_atstr = document.forms.comform.emailAttendee.options[sel_inveteeseml[i]].text;
						tmp_atemlid = tmp_atstr;
						if(tmp_atatndstr.length == 0 || tmp_atatndstr == "")
						{
							tmp_atatndstr = tmp_atemlid ;
						}
						else
						{
							tmp_atatndstr = tmp_atatndstr + "\n" + tmp_atemlid ;
						}

						document.forms.comform.UI_Attendee.value = tmp_atatndstr;
						tmp_atstr = "";
						tmp_atemlid = "";
					}
				}
//--------------- End new code ---------------------------------------------
				else
				{
					sel_index = document.forms.comform.emailAttendee.selectedIndex;
					tmp_string = document.forms.comform.emailAttendee.options[sel_index].text;
			
					if(tmp_string.length == 0 || tmp_string == "")
					{
						document.forms.comform.UI_Attendee.value = "";
					}
			
					tmp_Uid = tmp_string;
					
					reminderEmail = document.forms.comform.UI_Attendee.value;
					if(reminderEmail == "")				
						document.forms.comform.UI_Attendee.value = tmp_Uid;
					else
					{
						reminderEmail = reminderEmail + "\n" + tmp_Uid ;
						document.forms.comform.UI_Attendee.value = reminderEmail;
					}
				}
			}

//--------------- Function to compare the start date and end date of the event --------------------
			function dateComp()
			{
				var sDay,sMonth,sYear,sHr,sMin,eDay,eMonth,eYear,eHr,eMin;
				sDay = document.forms.comform.selDay.selectedIndex;
				sMonth = document.forms.comform.selMonth.selectedIndex;
				sYear = document.forms.comform.selYear.selectedIndex;
				sHr = document.forms.comform.selHr.selectedIndex;
				sMin = document.forms.comform.selMin.selectedIndex;
				eDay = document.forms.comform.selEDay.selectedIndex;
				eMonth = document.forms.comform.selEMonth.selectedIndex;
				eYear = document.forms.comform.selEYear.selectedIndex;
				eHr = document.forms.comform.selEHr.selectedIndex;
				eMin = document.forms.comform.selEMin.selectedIndex;

				//check for the type of the clock i.e 12/24

				if(clkHours == "12")
				{
					if(document.forms.comform.clkAmPm.options[0].selected == true)
					{
						if(document.forms.comform.selHr.options[11].selected == true)
						{
							var tmp_hour = "00";
							tmp_hour = parseFloat(tmp_hour);
						}
						else
						{
							var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
							tmp_hour = parseFloat(tmp_hour);
						}
					}
					else if(document.forms.comform.clkAmPm.options[1].selected == true)
					{
						if(document.forms.comform.selHr.options[11].selected == true)
						{
							var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
							tmp_hour = parseFloat(tmp_hour);
						}
						else
						{
							var tmp_hour = document.forms.comform.selHr.options[document.forms.comform.selHr.selectedIndex].value;
							tmp_hour = parseFloat(tmp_hour);
							tmp_hour = tmp_hour + 12;
							if(tmp_hour > 23)
							{
								tmp_hour = 0;
							}
						}
					}

					if(document.forms.comform.clkEAmPm.options[0].selected == true)
					{
						if(document.forms.comform.selEHr.options[11].selected == true)
						{
							var tmp_ehour = "00";
							tmp_ehour = parseFloat(tmp_ehour);
						}
						else
						{
							var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
							tmp_ehour = parseFloat(tmp_ehour);
						}
					}
					else if(document.forms.comform.clkEAmPm.options[1].selected == true)
					{
						if(document.forms.comform.selEHr.options[11].selected == true)
						{
							var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
							tmp_ehour = parseFloat(tmp_ehour);
						}
						else
						{
							var tmp_ehour = document.forms.comform.selEHr.options[document.forms.comform.selEHr.selectedIndex].value;
							tmp_ehour = parseFloat(tmp_ehour);
							tmp_ehour = tmp_ehour + 12;
							if(tmp_ehour > 23)
							{
								tmp_ehour = 0;
							}
						}
					}

					if(eYear < sYear)
					{
						return true;
					}
					else if(eYear == sYear && eMonth < sMonth)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay < sDay)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay == sDay && tmp_ehour < tmp_hour)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay == sDay && tmp_ehour == tmp_hour && eMin < sMin)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
				else   //for 24 hr clock
				{					
					if(eYear < sYear)
					{
						return true;
					}
					else if(eYear == sYear && eMonth < sMonth)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay < sDay)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay == sDay && eHr < sHr)
					{
						return true;
					}
					else if(eYear == sYear && eMonth == sMonth && eDay == sDay && eHr == sHr && eMin < sMin)
					{
						return true;
					}
					else
					{
						return false;
					}
				} //for 24 hr clock
			}
