// CATALOGUE
	function CatalogueImage(FileName,ImageObject) {
		document.getElementById(ImageObject).src = FileName;
		if(document.getElementById(ImageObject+'_lightbox')) {
			document.getElementById(ImageObject+'_lightbox').href = FileName.replace('l_','b_').replace('\/large\.jpg','/lightbox.jpg');
			Shadowbox.setup();
		}
	}
	
// RUNNING TOTAL
	function RunningTotal(InnerHTMLID,CheckObject) {		
		var CurrentTotal = parseFloat(document.getElementById(InnerHTMLID).innerHTML.replace('$',''));
		if(CheckObject.checked) {
			CurrentTotal += parseFloat(CheckObject.value);
		} else {
			CurrentTotal -= parseFloat(CheckObject.value);
		}				
		document.getElementById(InnerHTMLID).innerHTML = '$'+CurrentTotal.toFixed(2);	
	}
	
// PASSWORD REPLACE
	function PasswordReplace(Obj,Type,Value) {
		if (Type == 'blur' && Obj.value == '') {
			var NewPasswordObject = document.createElement('input');
			NewPasswordObject.setAttribute('type','text');
			NewPasswordObject.setAttribute('name',Obj.getAttribute('name'));
			NewPasswordObject.setAttribute('value',Value);
			NewPasswordObject.className = Obj.className;
			NewPasswordObject.onfocus = new Function("PasswordReplace(this,'','')");
			Obj.parentNode.replaceChild(NewPasswordObject,Obj);	
		} else if (Type == '') {
			var NewPasswordObject = document.createElement('input');
			NewPasswordObject.setAttribute('type','password');
			NewPasswordObject.setAttribute('name',Obj.getAttribute('name'));
			NewPasswordObject.className = Obj.className;
			NewPasswordObject.onblur = new Function("PasswordReplace(this,'blur','"+Obj.value+"')");
			Obj.parentNode.replaceChild(NewPasswordObject,Obj);
			NewPasswordObject.focus();
			NewPasswordObject.select();
		}	
	}
	
// COMPLETE
	function SubmitComplete(FormName,ArrayName,ErrorMessageID) { 				
		
		// VERIABLES
			var ErrorMessage = '';
			var Validation = true;
			var FieldsRequired = false;
			var Type = '';
			var PersonalInformation_MainContact = '';
			var AddressInformation_MainContact = '';
			
		// FUNCTION
			function FiledFlase(FormObject) {
				if(FormObject) {	
					FormObject.style.color = '#FF0000';	
					FormObject.onfocus = new Function("if(this.value==this.defaultValue) this.value='';this.style.color = '#4c4c4c'");
				}
			}
			
			function FiledTrue(FormObject) {
				FormObject.style.color = '#4c4c4c';	
			}
			
		// CHECK 	
			for(var i=0; i < document[FormName].length; i++) {
				if(document[FormName][i]) {	
					if (document[FormName][i].id.match(/RQ/) && document[FormName][i].id.match('Email')) {
							var ValidateEmail = document[FormName][i].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
							if (!ValidateEmail) {
									FiledFlase(document[FormName][i]);
							} else {
									FiledTrue(document[FormName][i]);		
							}
					} else if (document[FormName][i].id.match(/RQ/) && (document[FormName][i].value == '' || (document[FormName][i].value.match(/First Name|Last Name|^Street Name$|Apt #|Province\/State|Postal Code|^City$|Phone Number|Delivery Date|Delivery Time/)))) {
							FiledFlase(document[FormName][i]);
							FieldsRequired = true;
							Validation = false;
					} else {	
							FiledTrue(document[FormName][i]);
					}
				}
			}	
	
		// REQUIRED FILEDS
			if (FieldsRequired) {
				ErrorMessage += '*Please see above for required items.<br><br>';
			}
				
			
			if (!Validation) {
				document.getElementById(ErrorMessageID).innerHTML = ErrorMessage;
			} else { 
				document.getElementById(ErrorMessageID).innerHTML = '';
				
				// CLEAN DEFAULT VALUES
				for(var i=0; i < document[FormName].length; i++) {
					if (document[FormName][i].value && (document[FormName][i].value.match(/First Name|Last Name|^Street Name$|Apt #|Province\/State|Postal Code|^City$|Country|Email Address|Cardholder Name|Card Number|Card Security Number/) || document[FormName][i].value == 'Other Email')) {
							document[FormName][i].value	= '';								  
					}				
				}	
			
				// SUBMIT
				document[FormName].submit();
			}			
	}
		
	
// CHECKOUT
	function SubmitCheckout(FormName,ArrayName,ErrorMessageID) {	
		
		// VERIABLES
			var ErrorMessage = '';
			var Validation = true;
			var FieldsRequired = false;
			var Type = '';
			var PersonalInformation_MainContact = '';
			var AddressInformation_MainContact = '';
			
		// FUNCTION
			function FiledFlase(FormObject) {
				FormObject.style.color = '#FF0000';	
				FormObject.onfocus = new Function("if(this.value==this.defaultValue) this.value='';this.style.color = '#4c4c4c'");
			}
			
			function FiledTrue(FormObject) {
				FormObject.style.color = '#4c4c4c';	
			}
			
		// CHECK 	
			for(var i=0; i < document[FormName].length; i++) {
				if (document[FormName][i].id.match(/RQ/) && document[FormName][i].id.match('Email')) {
						var ValidateEmail = document[FormName][i].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
						if (!ValidateEmail) {
								FiledFlase(document[FormName][i]);
						} else {
								FiledTrue(document[FormName][i]);		
						}
				} else if (document[FormName][i].id.match(/RQ/) && (document[FormName][i].value == '' || (document[FormName][i].value.match(/First Name|Last Name|^Street Name$|Apt #|Province\/State|Postal Code|^City$|Country|Email Address|Cardholder Name|Card Number|Card Security Number/)))) {
						if (document[FormName][i].type == 'select-one' || document[FormName][i].type == 'select') {
							FiledFlase(document.getElementById(document[FormName][i].id+'_Title'));
						} else {
							FiledFlase(document[FormName][i]);	
						}
						FieldsRequired = true;
						Validation = false;
				} else {					
					if (document[FormName][i].type == 'select-one' || document[FormName][i].type == 'select') {
						FiledTrue(document.getElementById(document[FormName][i].id+'_Title'));
					} else {
						FiledTrue(document[FormName][i]);		
					}
				}
			}	
			
			
		// TERMS AND CONDITIONS
			if (!document[FormName].TermConditions.checked) {
				ErrorMessage += 'Please Check Terms and Conditions<br>';
				Validation = false;
				FieldsRequired = true;
			}	
		
		// BUY NOW ONLY
		if(document[FormName]['Checkout[DeliveryTo]']) {
			
			var CheckDelivery = '';
			for(var i=0; i < document[FormName]['Checkout[DeliveryTo]'].length; i++) {
				if(document[FormName]['Checkout[DeliveryTo]'][i].checked) {
					CheckDelivery = document[FormName]['Checkout[DeliveryTo]'][i].value;
				break;
				}
			}	
			
			if (CheckDelivery == '') {
				ErrorMessage += 'Please select deliver this gift to.<br>';
				Validation = false;
				FieldsRequired = true;
			}
			
			if(CheckDelivery == 'Gift Recipient') {
				for(var i=0; i < document[FormName].length; i++) {
					if (document[FormName][i].id.match(/SQ/) && document[FormName][i].id.match('Email')) {
							var ValidateEmail = document[FormName][i].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
							if (!ValidateEmail) {
									FiledFlase(document[FormName][i]);
							} else {
									FiledTrue(document[FormName][i]);		
							}
					} else if (document[FormName][i].id.match(/SQ/) && (document[FormName][i].value == '' || (document[FormName][i].value.match(/First Name|Last Name|^Street Name$|Apt #|Province\/State|Postal Code|^City$|Country|Email Address|Cardholder Name|Card Number|Card Security Number/)))) {
							if (document[FormName][i].type == 'select-one' || document[FormName][i].type == 'select') {
								FiledFlase(document.getElementById(document[FormName][i].id+'_Title'));
							} else {
								FiledFlase(document[FormName][i]);	
							}
							FieldsRequired = true;
							Validation = false;
					} else {					
						if (document[FormName][i].type == 'select-one' || document[FormName][i].type == 'select') {
							FiledTrue(document.getElementById(document[FormName][i].id+'_Title'));
						} else {
							FiledTrue(document[FormName][i]);		
						}
					}
				}						
			}
		}
		
		
	
		// REQUIRED FILEDS
		if (FieldsRequired) {
			ErrorMessage += '*Please see above for required items.<br><br>';
		}
			
				
			
			if (!Validation) {
				document.getElementById(ErrorMessageID).innerHTML = ErrorMessage;
			} else { 
				document.getElementById(ErrorMessageID).innerHTML = '';
				
				// CLEAN DEFAULT VALUES
				for(var i=0; i < document[FormName].length; i++) {
					if (document[FormName][i].value && (document[FormName][i].value.match(/First Name|Last Name|^Street Name$|Apt #|Province\/State|Postal Code|^City$|Country|Email Address|Cardholder Name|Card Number|Card Security Number/) || document[FormName][i].value == 'Other Email')) {
							document[FormName][i].value	= '';								  
					}				
				}	
				
				// CLEAN MESSAGE
				if (document[FormName].OrigianlMessage && document[FormName].OrigianlMessage.value == document[FormName][''+ArrayName+'[Message]'].value) {
					document[FormName][''+ArrayName+'[Message]'].value = '';
				}
			
				// SUBMIT
				document[FormName].submit();
			}			
	}
	
	
// REGISTRATION
	function SubmitRegestryRegistration(FormName,ArrayName,ErrorMessageID) {	
		
		// VERIABLES
			var ErrorMessage = '';
			var Validation = true;
			var FieldsRequired = false;
			var Type = '';
			var PersonalInformation_MainContact = '';
			var AddressInformation_MainContact = '';
			
		// FUNCTION
			function FiledFlase(FormObject) {
				FormObject.style.color = '#FF0000';	
				FormObject.onfocus = new Function("if(this.value==this.defaultValue) this.value='';this.style.color = '#4c4c4c'");
			}
			
			function FiledTrue(FormObject) {
				FormObject.style.color = '#4c4c4c';	
			}
		
		// TYPE		
			for(var i=0; i < document[FormName][''+ArrayName+'[Type]'].length; i++) {
				if(document[FormName][''+ArrayName+'[Type]'][i].checked) {
				Type = document[FormName][''+ArrayName+'[Type]'][i].value;
				break;
				}
			}	
	
			if (Type == '') {
				ErrorMessage += 'Please Select Individual or Couple<br>';
				Validation = false;
			}	
			
		
		// PERSONAL INFORMATION MAIN  CONTACT
			for(var i=0; i < document[FormName][''+ArrayName+'[Registrant][Main]'].length; i++) {
				if(document[FormName][''+ArrayName+'[Registrant][Main]'][i].checked) {
				PersonalInformation_MainContact = document[FormName][''+ArrayName+'[Registrant][Main]'][i].value;
				break;
				}
			}	

			if (PersonalInformation_MainContact == '') {
				ErrorMessage += 'Please select main personal information contact<br>';
				Validation = false;
			}
		
		// PERSONAL INFROMATION
			if (PersonalInformation_MainContact != '') {
				var PersonalInformation = Array('First Name','Last Name','Email','Phone Number');
				
				var ID = 1;
				for(var i=0; i < PersonalInformation.length; i++) {
					FiledTrue(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);
				}
				
				var ID = 2;
				for(var i=0; i < PersonalInformation.length; i++) {
					FiledTrue(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);
				}
				
				var ID = PersonalInformation_MainContact;
				for(var i=0; i < PersonalInformation.length; i++) {					
					if (document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value == '' || (document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value.match(/Registrant/gi) || document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value == 'Other Email')) {						
						FiledFlase(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);	
						FieldsRequired = true;
						Validation = false;
					} else {						
						if (PersonalInformation[i].match('Email')) {
							var ValidateEmail = document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
							if (!ValidateEmail) {
								FiledFlase(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);	
								FieldsRequired = true;
								Validation = false;
							} else {
								FiledTrue(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);		
							}
						} else {					
							FiledTrue(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);	
						}
					}
				}
				
				if (Type == 'Couple') {
					var PersonalInformation = Array('First Name','Last Name');
					if (PersonalInformation_MainContact == '1'){
						var ID = 2;
					} else {
						var ID = 1;
					}
					for(var i=0; i < PersonalInformation.length; i++) {
						if (document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value == '' || (document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value.match(/Registrant/gi) || document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']'].value == 'Other Email')) {
							FiledFlase(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);
							FieldsRequired = true;
							Validation = false;
						}	else {
							FiledTrue(document[FormName][''+ArrayName+'[Registrant]['+ID+']['+PersonalInformation[i]+']']);
						}			
					}	
				}				
			}
			
		// EVENT TYPE
			var Checked = false;
			for(var i=0; i < document[FormName][''+ArrayName+'[Event Type]'].length; i++) {
				if(document[FormName][''+ArrayName+'[Event Type]'][i].checked) {
				Checked = true;
				break;
				}
			}	
	
			if (!Checked) {
				ErrorMessage += 'Please select event type<br>';
				Validation = false;
			}
			
			var Fields = Array('Event Day','Event City','Event Country','Closing Date');
			for(var i=0; i < Fields.length; i++) {
				if (document[FormName][''+ArrayName+'['+Fields[i]+']'].value == '' || (document[FormName][''+ArrayName+'['+Fields[i]+']'].value.match(/Registrant|Other Email|City|Country|Event Day|Closing Date/gi) || document[FormName][''+ArrayName+'['+Fields[i]+']'].value == 'Other Email')) {
					FiledFlase(document[FormName][''+ArrayName+'['+Fields[i]+']']);
					FieldsRequired = true;
					Validation = false;
				} else {
					FiledTrue(document[FormName][''+ArrayName+'['+Fields[i]+']']);
				}
			}
			
		// ADDRESS MAIN CONTACT
			for(var i=0; i < document[FormName][''+ArrayName+'[Address][Main]'].length; i++) {
				if(document[FormName][''+ArrayName+'[Address][Main]'][i].checked) {
				AddressInformation_MainContact = document[FormName][''+ArrayName+'[Address][Main]'][i].value;
				break;
				}
			}	

			if (AddressInformation_MainContact == '') {
				ErrorMessage += 'Please select main address contact<br>';
				Validation = false;
			}
			
		// ADDRESS
			if (AddressInformation_MainContact != '') {
				var AddressInformation = Array('Street','City','Province','Postal Code');
				
				var ID = 1;
				for(var i=0; i < AddressInformation.length; i++) {					
					FiledTrue(document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']']);
				}	
				
				var ID = 2;
				for(var i=0; i < AddressInformation.length; i++) {					
					FiledTrue(document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']']);
				}	
				
				var ID = 3;
				for(var i=0; i < AddressInformation.length; i++) {					
					FiledTrue(document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']']);
				}				
				
				var ID = AddressInformation_MainContact;
				for(var i=0; i < AddressInformation.length; i++) {
					if (document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']'].value == '' || (document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']'].value.match(/Registrant/gi) || document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']'].value == 'Other Email')) {
						FiledFlase(document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']']);
						FieldsRequired = true;
						Validation = false;
					} else {
						FiledTrue(document[FormName][''+ArrayName+'[Address]['+ID+']['+AddressInformation[i]+']']);
					}
				}					
			}	
			
		// LOGIN	
			if (ArrayName != 'UpdateInfo') {
				var Fields = Array('Login ID','Confirm Login ID','Login Password','Confirm Login Password');
				for(var i=0; i < Fields.length; i++) {
					if (document[FormName][''+ArrayName+'['+Fields[i]+']'].value == '' || (document[FormName][''+ArrayName+'['+Fields[i]+']'].value.match(/Registrant|Login Password|Login ID/gi) || document[FormName][''+ArrayName+'['+Fields[i]+']'].value == 'Other Email')) {
						FiledFlase(document[FormName][''+ArrayName+'['+Fields[i]+']']);
						FieldsRequired = true;
						Validation = false;
					} else {
						if (Fields[i].match('Email')) {
							var ValidateEmail = document[FormName][''+ArrayName+'['+Fields[i]+']'].value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
							if (!ValidateEmail) {
								FiledFlase(document[FormName][''+ArrayName+'['+Fields[i]+']']);
								FieldsRequired = true;
								Validation = false;
							} else {							
								FiledTrue(document[FormName][''+ArrayName+'['+Fields[i]+']']);	
							}
						} else {						
							FiledTrue(document[FormName][''+ArrayName+'['+Fields[i]+']']);
						}	
					}
				}
			}
			
		// VERIFICATION
			if (ArrayName != 'UpdateInfo') {
				if (!FieldsRequired && document[FormName][''+ArrayName+'[Login ID]'].value != document[FormName][''+ArrayName+'[Confirm Login ID]'].value) {
					FiledFlase(document[FormName][''+ArrayName+'[Confirm Login ID]']);
					ErrorMessage += 'Login ID dosen\'t match.<br>';
					Validation = false;
				}
				
				if (!FieldsRequired && document[FormName][''+ArrayName+'[Login Password]'].value != document[FormName][''+ArrayName+'[Confirm Login Password]'].value) {
					FiledFlase(document[FormName][''+ArrayName+'[Confirm Login Password]']);
					ErrorMessage += 'Login Password dosen\'t match.<br>';
					Validation = false;
				}
			}
			
		// REQUIRED FILEDS
		if (FieldsRequired) {
			ErrorMessage += '*Please see above for required items.<br>';
		}
		
		if (!Validation) {
			document.getElementById(ErrorMessageID).innerHTML = ErrorMessage;
		} else { 
			
			// CLEAN DEFAULT VALUES
			for(var i=0; i < document[FormName].length; i++) {
				if (document[FormName][i].value && (document[FormName][i].value.match(/Registrant/gi) || document[FormName][i].value == 'Other Email')) {
						document[FormName][i].value	= '';								  
				}				
			}		
		
			// SUBMIT
			document[FormName].submit();
		}
		
	}
	
// CLEAN DEFUALT VALUES
	function CleanDefaults(FormName) {		
		for(var i=0; i < document[FormName].length; i++) {
			if (document[FormName][i].value && (document[FormName][i].value.match(/Registrant|Event City|Registry Number/gi) || document[FormName][i].value == 'Other Email')) {
					document[FormName][i].value	= '';								  
			}				
		}		
	}
	
// CLEAN DEFUALT VALUES
	function AddToCart(URL,InputBox) {
		if (document.getElementById(InputBox).value != '') {
			location.href= URL+document.getElementById(InputBox).value;	
		} else {
			document.getElementById(InputBox+'_Title').style.color = '#FF0000';		
		}
	}	

// CALENDAR

	// VERIABLES
	var CalendarThisDate = 1;
	var CalendarWordMoth = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
	var CalendarToday = new Date();
	var CalendarTodaysDay = CalendarToday.getDay()+1;
	var CalendarTodaysDate = CalendarToday.getDate();
	var CalendarTodaysMonth = CalendarToday.getUTCMonth() + 1;
	var CalendarTodaysYear = CalendarToday.getFullYear();
	var CalendarMonthNum = CalendarTodaysMonth;
	var CalendarYearNum = CalendarTodaysYear;
	var CalendarFirstDate = new Date(String(CalendarMonthNum)+"/1/"+String(CalendarYearNum));
	var CalendarFirstDay = CalendarFirstDate.getUTCDay();
	var CalendarLastDate = new Date(String(CalendarMonthNum+1)+"/0/"+String(CalendarYearNum));
	var CalendarNumbDays = 1;
	var CalendarCurrentID = null;
	
	// CHANGE MONTH
	function CalendarChangeMonth(Direction) {
		if (Direction == "prev") {
		CalendarMonthNum--;
		} else if (Direction == "next") {
		CalendarMonthNum++;
		} else if (Direction == "return") { 
		CalendarMonthNum = CalendarTodaysMonth;
		CalendarYearNum = CalendarTodaysYear;
		}
		if (CalendarMonthNum == 0) {
		CalendarMonthNum = 12;
		CalendarYearNum--;
		} else if (CalendarMonthNum == 13) {
		CalendarMonthNum = 1;
		CalendarYearNum++
		}
		CalendarLastDate = new Date(CalendarYearNum, CalendarMonthNum, 0);
		CalendarNumbDays = CalendarLastDate.getDate();
		CalendarFirstDate = new Date(String(CalendarMonthNum)+"/1/"+String(CalendarYearNum));
		CalendarFirstDay = CalendarFirstDate.getDay() + 1;
		CalendarInsert();
		return;		
	}
	
	
	// INSERT	
	function CalendarInsert() {
		var writeCalendar = '';			
		writeCalendar += '<div class="CalendarPrev" onclick="javascript:CalendarChangeMonth(\'prev\')">&lt;&lt;</div>';
		writeCalendar += '<div class="CalendarTitle">'+CalendarWordMoth[CalendarMonthNum-1]+'&nbsp;&nbsp;'+CalendarYearNum+'</div>';
		writeCalendar += '<div class="CalendarNext" onclick="javascript:CalendarChangeMonth(\'next\')">&gt;&gt;</div>';
		writeCalendar += '<div style="clear:both"></div>';
		writeCalendar += '<span class="CalendarDay">S</span><span class="CalendarDay">M</span><span class="CalendarDay">T</span><span class="CalendarDay">W</span><span class="CalendarDay">Th</span><span class="CalendarDay">F</span><span class="CalendarDay">S</span>'
		for (var i = 1; i <= 42; i++) {
			if ((i==1)|| (i==8)|| (i==15)|| (i==22)|| (i==29)|| (i==36)) {
			writeCalendar +=  '<br style="clear:both" />';				
			}
			if ((CalendarThisDate <= CalendarNumbDays) && (i >= (CalendarFirstDay))) {
				if ((CalendarThisDate == CalendarTodaysDate) && (CalendarTodaysMonth == CalendarMonthNum) && (CalendarTodaysYear == CalendarYearNum)) {					 
				writeCalendar += '<a class="CalendarDateToday" onfocus="if(this.blur)this.blur();" href="javascript:CalendarSetDate(' + CalendarThisDate + ',' + CalendarMonthNum + ',' + CalendarYearNum + ');CalendarClose();">' + CalendarThisDate + '</a>';
				} else {
					
				writeCalendar += '<a class="CalendarDate" onfocus="if(this.blur)this.blur();" href="javascript:CalendarSetDate(' + CalendarThisDate + ',' + CalendarMonthNum + ',' + CalendarYearNum + ');CalendarClose();">' + CalendarThisDate + '</a>';
				}
			CalendarThisDate++;					
			} else { 
			writeCalendar += '<span class="CalendarEmpty">&nbsp;</span>';
			}
		}
		var object=document.getElementById('CalendarHolder');
		object.innerHTML= writeCalendar;
		CalendarThisDate = 1;
	}
		
	
	// SET DATE	
	function CalendarSetDate(dayVal,monthVal,yearVal) {
		CalendarCurrentID.value = monthVal+'/'+dayVal+'/'+yearVal;	
		if (typeof CalendarCurrentID.onchange == "function" ) {
			CalendarCurrentID.onchange();
		}
		CalendarTodaysDay = dayVal;
		CalendarTodaysDate = dayVal;
		CalendarTodaysMonth = monthVal;
		CalendarTodaysYear = yearVal;		
		CalendarMonthNum = CalendarTodaysMonth;
		CalendarYearNum = CalendarTodaysYear;
		CalendarFirstDate = new Date(String(CalendarMonthNum)+"/1/"+String(CalendarYearNum));
		CalendarFirstDay = CalendarFirstDate.getUTCDay();
		CalendarLastDate = new Date(String(CalendarMonthNum+1)+"/0/"+String(CalendarYearNum));
		CalendarChangeMonth('return');
	}	
		
	// GET SCROLLING	
	function getScrollingPosition() {
		var position = [0, 0];
		if (typeof window.pageYOffset != 'undefined')
		{
		position = [
		window.pageXOffset,
		window.pageYOffset
		];
		}
		else if (typeof document.documentElement.scrollTop
		!= 'undefined' && document.documentElement.scrollTop > 0)
		{
		position = [
		document.documentElement.scrollLeft,
		document.documentElement.scrollTop
		];
		}
		else if (typeof document.body.scrollTop != 'undefined')
		{
		position = [
		document.body.scrollLeft,
		document.body.scrollTop
		];
		}
		return position;
	}	
		
	// LOAD	
	function CalendarLoad(ObjectID,evt) {
		evt = (evt) ? evt : ((window.event) ? event : null);
		var Height = 207;
		var Width = 173;
		
		var NewWindow = document.createElement("DIV");		
		NewWindow.setAttribute("id","Calendar");
		NewWindow.className = 'PopupWindow';
		NewWindow.innerHTML = '<div class="CalendarArea"><div id="CalendarHolder"></div></div>';
		document.body.appendChild(NewWindow);
		
		var Scroll = getScrollingPosition();
		
		var PosX = evt.clientX-80+Scroll[0];
		var PosY = evt.clientY-100+Scroll[1];
		document.getElementById("Calendar").style.top =  PosY+"px";
		document.getElementById("Calendar").style.left =  PosX+"px";	
		document.getElementById("Calendar").style.display = "block";	
		CalendarCurrentID = ObjectID;		
		var DateArray = Array ();	
			if (ObjectID.value != '' && ObjectID.value != 'n/a' && ObjectID.value.match('/')) {	
			DateArray = ObjectID.value.split('/');	
			} else {
			var CalendarToday = new Date();
			DateArray[0] = CalendarToday.getUTCMonth() + 1;
			DateArray[1] = CalendarToday.getDate();
			DateArray[2] = CalendarToday.getFullYear();
			}		
		CalendarSetDate(parseInt(DateArray[1]),parseInt(DateArray[0]),parseInt(DateArray[2]));	
	}
		
		
	// CLOSE 	
	function CalendarClose() {	
		var RemoveWindow = document.getElementById("Calendar");
		RemoveWindow.parentNode.removeChild(RemoveWindow);	
		CalendarCurrentID = null;
	}	